Re: [R] lm on matrix data

2012-10-11 Thread Jean V Adams
Baoqiang, Here's an approach that should work: (1) Make sure that the column names of trainx and testx are the same. (2) Combine trainy and trainx into a data frame for fitting the model. (2) Use the newdata= argument in the predict() function. (3) Convert testx from matrix to data frame. # some

Re: [R] lm on matrix data

2012-10-10 Thread R. Michael Weylandt
On Wed, Oct 10, 2012 at 3:35 PM, Baoqiang Cao wrote: > 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 "t

[R] lm on matrix data

2012-10-10 Thread Baoqiang Cao
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 49