[R] Dataframes in PLS package
westland
westland at uic.edu
Tue Feb 21 03:28:07 CET 2012
I have been working with the pls procedure and have problems getting the
procedure to work with matrix or frame data. I suspect the problem lies in
my understanding of frames, but can't find anything in the documentation
that will help.
Here is what I have done:
I read in an 10000 x 8 table of data, and assign the first four columns to
matrix A and the second four to matrix B
pls <- read.table("C:/Users/Chris/Desktop/SEM Book/SEM Stat
Example/Simple Header Data for SEM.csv", header=TRUE, sep=",",
na.strings="NA", dec=".", strip.white=TRUE)
A <- c(pls[1],pls[2],pls[3],pls[4])
B <- c(pls[5],pls[6],pls[7],pls[8])
I then put these into the data.fram C, retaining the matrix structure per
guidelines in the JSS article on the pls package
C <- data.frame(h = I(as.matrix(A)), c = I(as.matrix(B)))
showData(C, placement='-20+200', font=getRcmdr('logFont'), maxwidth=80,
maxheight=30)
63 55 1 0 44 37200 4 0
145 52 1 1 33 69300 4 1
104 32 0 1 68 56900 3 1
109 69 1 1 94 44300 6 1
221 61 0 1 72 79800 6 0
110 40 1 1 48 17600 5 1
194 41 0 0 85 58100 4 0
120 76 1 1 19 76700 3 0
210 61 0 0 41 37600 1 0
243 101 1 1 57 40800 5 1
163 62 0 1 64 400 3 0
So the h. and the c. columns should be matrices that I can regress in plsr
function:
apls <- plsr(h ~ c, data = C)
summary(apls)
But this gives me: [34] ERROR: invalid type (list) for variable 'h'
I can get the plsr function to work with scalars for both predictor and
response. Can anyone tell me where I have gone wrong on the pls input?
apls <- plsr(w ~ h, data = pls)
summary(apls)
Data: X dimension: 10000 1
Y dimension: 10000 1
Fit method: kernelpls
Number of components considered: 1
TRAINING: % variance explained
1 comps
X 100.000
w 2.293
--
View this message in context: http://r.789695.n4.nabble.com/Dataframes-in-PLS-package-tp4405798p4405798.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list