I would like to process some spectroscopic data with R, and I was hoping
some people might have some example code on how to do this.
I would like to be able to do the following things:
* Detect outlier-spectra -> This can be done by using scoreplot from the
* Determine the range of the spectrum to be used -> For this, I should
be able to calculate the regression coefficients
* Determine the optimal number of elements in a model
* Anything else that you guys think could be useful :-)
> * Determine the range of the spectrum to be used -> For this, I should
> be able to calculate the regression coefficients
You can get the regression coefficients from a PLSR/PCR with the
coef() function. See ?coef.mvr However, using the regression
coefficients alone for selecting variables/regions, can be 'dangerous'
because the variables are highly correlated.
One alternative is 'variable importance' measures, e.g. VIP (variable
importance in projections) as described in Chong, Il-Gyo & Jun,
Chi-Hyuck, 2005, Performance of some variable selection methods when
multicollinearity is present, Chemometrics and Intelligent Laboratory
Systems 78, 103--112. A crude implementation of VIP can be found in
Another alternative is to use jackknife-estimated uncertainties of the
regression coefficients in significance tests. (I don't have any
reference or implementation, sorry. :-)
The correlation loadings can also give valuable information about
which variables that might be important for the regression. See
?corrplot in the pls package.
In the biophysics group of Vrije Universiteit Amsterdam we are working on
an R package implementing a problem solving environment for multi-way
spectroscopic modeling. We do not have a public version yet, but one will
be made available in the future. We plan to describe the package at
To reply to one of your questions, for determination of the optimal number
of spectrally distinct components, you could simply take the SVD of your
measurements and plot the singular values. The number of values that
"stand out" may be used as an estimate of the number of components.
Feel free to contact me for more information. We look forward to
providing a complete and powerful package soon!
Department of Physics and Astronomy
Faculty of Sciences
Vrije Universiteit Amsterdam
de Boelelaan 1081
1081 HV Amsterdam
tel: +31 205987870
fax: +31 205987992
e-mail: [hidden email] http://www.nat.vu.nl/~kate/