[R] Problem with predict.lm()
Martin Spindler
Martin.Spindler at gmx.de
Wed Apr 29 16:21:16 CEST 2015
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 in not made for Xnew
How can I foce predict.lm to use use the new data?
Thank you very much for your efforts in advance!
Best,
Martin
More information about the R-help
mailing list