Xu, Xiuli (NIH/NHLBI) [E] wrote:
> I would really appreciate it if someone can give suggestions on how to
> do spectra fitting in R using ordinary least square fitting and
> non-negativity constraints. The lm() function works well for ordinary
> least square fitting, but how to specify non-negativity constraints? It
> wouldn't make sense if the fitting coefficients coming out as negative
> in absorption spectra deconvolution.
> 
> Thanks. 
> 
> Xiuli
> 

I'm not sure, but would presume that constraints could not be imposed on 
a linear least squares fit. maybe someone can correct me.

if you move to `nls', i.e. non-linear least squares fitting, you should 
be able to transform your model function. say, you want some parameter 
`a' to stay positive. then you could e.g. substitute

`a = exp(b)' in the model function and fit `b' without constraints in 
the "new" model and calculate `a' afterwards (which obviously is 
guaranteed now to be positive). note that error estimates would than 
have to be computed by gaussian error propagation from `b' to `a'.


joerg

______________________________________________
R-help@stat.math.ethz.ch 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 via email to