Constrained least squares

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Constrained least squares

Domenico Vistocco
Is there a function in R for constrained linear least squares?

I used the matlab function LSQLIN: my aim is to obtain
non-negative regression coefficients which sum 1.

Thanks in advance,
domenico vistocco


       

       
               
___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Constrained least squares

Ben Bolker
Domenico Vistocco <vistocco <at> unicas.it> writes:

>
> Is there a function in R for constrained linear least squares?
>
> I used the matlab function LSQLIN: my aim is to obtain
> non-negative regression coefficients which sum 1.
>
> Thanks in advance,
> domenico vistocco

  I haven't tried it, but it looks like constrOptim()
[plus your own objective function that calculates sums of squares,
something like

f <- function(param1,param2) {
   y.exp <- ... [function of param1 and param2]
   sum((y.exp-y)^2)
}

(or substitute -sum(dnorm(y,mean=y.exp,sd=param3,log=TRUE)) for
the last line)

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html