[R] Help in using PCR

Bjørn-Helge Mevik b.h.mevik at usit.uio.no
Tue Jul 1 10:41:04 CEST 2008


Gavin Simpson <gavin.simpson at ucl.ac.uk> writes:

> You can do this another way though, that I feel is more natural. So lets
> assume that your data frame contains columns that are named, and that
> one of these is the response variable, the remaining columns are the
> predictors. Further assume that this response is called 'myresp', then
> you can proceed by the following:
>
> cancerv1.pcr <- pcr(myresp ~ . , ncomp = 6, data = cancerv1,
>                     validation = "CV")

This works fine as long as the number of (predictor) variables is not
too large.  With many variables (>> 1000), R will spend a very long time
dealing with the formula.

-- 
Bjørn-Helge Mevik



More information about the R-help mailing list