[R] about R, RMSEP, R2, PCR
Bjørn-Helge Mevik
bhs2 at mevik.net
Fri Jul 6 14:27:58 CEST 2007
Nitish Kumar Mishra wrote:
> I want to calculate PLS package in R. Now I want to calculate R, MSEP,
> RMSEP and R2 of PLSR and PCR using this.
> I also add this in library of R. How I can calculate R, MSEP, RMSEP and R2
> of PLSR and PCR in R.
> I s any other method then please also suggest me. Simply I want to
> calculate these value.
I'm not entirely sure what you are asking about, but if you want to
calculate R, MSEP, RMSEP and R2 for PLSRs and PCRs with the pls
package, this should work:
library(pls)
data(yarn)
mymodel <- plsr(density ~ NIR, ncomp = 10, data = yarn) # or pcr()
See ?plsr for further options, especially "validation" for using
cross-validation.
## R2:
R2(mymodel)
## MSEP:
MSEP(mymodel)
## RMSEP:
RMSEP(mymodel)
See ?R2, etc. for further arguments, especially "estimate" for
selecting the estimator (test set, CV, or train).
The objects returned by these functions have a plot method, som
plot(RMSEP(...)) does "what you'd expect". See ?R2 for details about
the returned objects.
To get R (I presume you mean the correlation between predicted and
measured values), you can use
sqrt(R2(mymodel)$val)
--
HTH,
Bjørn-Helge Mevik
More information about the R-help
mailing list