Message-ID: <CACpbbiLEA+ehfG0MtYCOXs8mQj9oNOg9Qt7bSdLmZ5V5JL6F0g@mail.gmail.com>
Date: 2012-10-10T14:35:47Z
From: Baoqiang Cao
Subject: lm on matrix data
Hi,
I have a question about using lm on matrix, have to admit it is very
trivial but I just couldn't find the answer after searched the mailing
list and other online tutorial. It would be great if you could help.
I have a matrix "trainx" of 492(rows) by 220(columns) that is my x,
and trainy is 492 by 1. Also, I have the newdata testx which is 240
(rows) by 220 (columns). Here is what I got:
py <- predict(lm(trainy ~ trainx ), data.frame(testx))
Warning message:
'newdata' had 240 rows but variable(s) found have 492 rows
The fitting formula I intended is: trainy ~ trainx[,1] + trainx[,2] +
.. +trainx[,220].
Any help, please?
Best,
Baoqiang