There's also the "nnls" (non-negative least squares) package on CRAN that might be useful, although I'm puzzled by the negative sign in front of c in Alex post...
Cheers, Andy From: Berwin A Turlach > > G'day Alex, > > On Wed, 27 May 2009 11:51:39 +0200 > Alex van der Spek <[email protected]> wrote: > > > I wonder whether R has methods for constrained fitting of linear > > models. > > > > I am trying fm<-lm(y~x+I(x^2), data=dat) which most of the > time gives > > indeed the coefficients of an inverted parabola. I know in advance > > that it has to be an inverted parabola with the maximum > constrained to > > positive (or zero) values of x. > > > > The help pages for lm do not contain any info on > constrained fitting. > > > > Does anyone know how to? > > Look at the package nnls on CRAN. > > According to your subject line, you are trying to solve what is known > as a quadratic program, and there are at least two quadratic > programming solvers (ipop in kernlab and solve.qp in quadprog) > available for R. > > HTH. > > Cheers, > > Berwin > > =========================== Full address ============================= > Berwin A Turlach Tel.: +65 6516 4416 (secr) > Dept of Statistics and Applied Probability +65 6516 6650 (self) > Faculty of Science FAX : +65 6872 3919 > National University of Singapore > 6 Science Drive 2, Blk S16, Level 7 e-mail: [email protected] > Singapore 117546 http://www.stat.nus.edu.sg/~statba > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > Notice: This e-mail message, together with any attachme...{{dropped:12}} ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

