Re: [R] Problem with predict.lm()

2015-04-29 Thread ARNAB KR MAITY via R-help
-0.079174316 -0.193161949 -0.137517175   Arnab Kumar Maity Graduate Teaching Assistant Division of Statistics Northern Illinois University DeKalb, Illinois 60115 U.S.A From: Martin Spindler To: r-help@r-project.org Sent: Wednesday, April 29, 2015 9:21 AM Subject: [R] Problem with predict.lm()

Re: [R] Problem with predict.lm()

2015-04-29 Thread Martin Spindler
Thank you! I think I now understand where the problem was. Best, Martin     Gesendet: Mittwoch, 29. April 2015 um 16:50 Uhr Von: "David L Carlson" An: "Martin Spindler" , "r-help@r-project.org" Betreff: RE: [R] Problem with predict.lm() Since you passed a matrix

Re: [R] Problem with predict.lm()

2015-04-29 Thread Martin Spindler
on: "ARNAB KR MAITY" An: "Martin Spindler" , "r-help@r-project.org" Betreff: Re: [R] Problem with predict.lm() Hi,   It seems to be working in my R. Although it is throwing the warning message   Warning message:   'newdata' had 200 rows but vari

Re: [R] Problem with predict.lm()

2015-04-29 Thread David Winsemius
On Apr 29, 2015, at 7:21 AM, Martin Spindler wrote: > Dear all, > > the following example somehow uses the "old data" (X) to make the > predictions, but not the new data Xnew as intended. > > y <- rnorm(100) > X <- matrix(rnorm(100*10), ncol=10) > lm <- lm(y~X) > Xnew <- matrix(rnorm(100*20)

Re: [R] Problem with predict.lm()

2015-04-29 Thread David L Carlson
niversity College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Martin Spindler Sent: Wednesday, April 29, 2015 9:21 AM To: r-help@r-project.org Subject: [R] Problem with predict.lm() Dear all,   the following example somehow us

[R] Problem with predict.lm()

2015-04-29 Thread Martin Spindler
Dear all,   the following example somehow uses the "old data" (X) to make the predictions, but not the new data Xnew as intended.   y <- rnorm(100) X <- matrix(rnorm(100*10), ncol=10) lm <- lm(y~X) Xnew <- matrix(rnorm(100*20), ncol=10) ynew <- predict(lm, newdata=as.data.frame(Xnew)) #prediction