RE: [R] "mvr" function

From: McGehee, Robert <>
Date: Thu 02 Jun 2005 - 09:14:03 EST

I had some of the same difficulties. The NIR data frame consists of a column of y variables and a matrix of X variables (and until looking at this dataset, I had not realized that data frames could hold matrices). So, after consulting the R-help sages, I turned by data into an identical structure using something like this:

dataSet <- data.frame(y = vol[, 12])
dataSet$X <- data.matrix(vol[, 1:11])

ans.pcr <- pcr(y ~ X, 6, data = dataSet, validation = "CV")

If there's a more elegant way of doing this without using data frames of matrices, I'd be interested as well.


-----Original Message-----
From: Jim BRINDLE [] Sent: Wednesday, June 01, 2005 5:03 PM
Subject: [R] "mvr" function


I am trying to understand how to utilize the "mvr" function in the pls Package of R. I am utilizing the R "pls Package" document dated 18 May 2005
as guidance. My data set consists of a 12 x 12 data frame created from reading in a table of values. I have read the data in via the command:

volumes <- read.table("THA_vol.txt", header = TRUE)

and then created a data.frame called "vol". My response variable is in the
last column of the "vol" data frame and my dependent variables are in columns 1 through 11.

To familiarize myself with this approach I have utilized the NIR data set
(included in the pls Package). I get the following command to work with the
NIR data set:

NIR.pcr <- pcr(y ~ X,6,data=NIR,validation="CV")

However, when I run the following script which effectively substitutes my
data set (& modify variable names accordingly) into the above equation:

y <- vol[,12]
X <- vol[,1:11]
ans.pcr <- pcr(y ~ X,6,data=vol,validation="CV")

I get the following error:

Error in model.frame(formula, rownames, variables, varnames, extras, extranames, :

       invalid variable type

I have looked at the NIR data set in the pls Package and tried to see how it
"structurally" differs from my data-set "structure" (other than in its size).

Does anyone have any insight they might be willing to share?

Thank you kindly. mailing list PLEASE do read the posting guide! mailing list PLEASE do read the posting guide! Received on Thu Jun 02 09:21:21 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:21 EST