Xu, Xiuli (NIH/NHLBI) [E]
2006-Jul-11 22:12 UTC
[R] least square fit with non-negativity constraints for absorption spectra fitting
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
Dieter Menne
2006-Jul-14 12:43 UTC
[R] least square fit with non-negativity constraints for absorption spectra fitting
Xu, Xiuli (NIH/NHLBI) [E] <xux3 <at> nhlbi.nih.gov> writes:> > 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.I don't see much reasons to use lm() to fit a spectrum, but if you want to do that, negative coefficients simply mean a shift by pi, sothe sign can be discarded for most practical purposed. But better look at one of the specialized packages like spectrino. Dieter
Joerg van den Hoff
2006-Jul-14 12:46 UTC
[R] least square fit with non-negativity constraints for absorption spectra fitting
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
Lu Yuefeng
2006-Jul-14 14:34 UTC
[R] least square fit with non-negativity constraints for absorption spectra fitting
Were you doing blind deconvolution or the spectrum basis are assummed to be known? As for blind deconvolution, alternatively you might consider alternating least square, non-negative matrix factorization, or independent component analysis + alternating least square as the post-processing. yfl On 7/11/06, Xu, Xiuli (NIH/NHLBI) [E] <xux3@nhlbi.nih.gov> 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 > > ______________________________________________ > 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 >[[alternative HTML version deleted]]
Possibly Parallel Threads
- Deconvolution of a spectrum
- Chromatogram deconvolution and peak matching
- Any R function for self-controlled case series method /effect absorption?
- Hyperspec package: need to change spectra names in a stacked plot
- Suggestions: Terminology & Pkgs for following spectra over time