> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Stephan Kolassa
> Sent: Tuesday, August 17, 2010 5:25 AM
> To: R-help@r-project.org
> Subject: [R] predict.lm, matrix in formula and newdata
>
> Dear a
Of Stephan Kolassa
Sent: 17 August 2010 14:25
To: R-help@r-project.org
Subject: [R] predict.lm, matrix in formula and newdata
Dear all,
I am stumped at what should be a painfully easy task: predicting from an lm
object. A toy example would be this:
XX <- matrix(runif(8),ncol=2)
yy <- runif(4
try it better this way:
XX <- matrix(runif(8), ncol = 2)
DF <- as.data.frame(XX)
DF$yy <- runif(4)
model <- lm(yy ~ ., DF)
XX.pred <- as.data.frame(matrix(runif(6), ncol = 2))
predict(model, XX.pred)
I hope it helps.
Best,
Dimitris
On 8/17/2010 2:24 PM, Stephan Kolassa wrote:
Dear all,
I
Dear all,
I am stumped at what should be a painfully easy task: predicting from an lm
object. A toy example would be this:
XX <- matrix(runif(8),ncol=2)
yy <- runif(4)
model <- lm(yy~XX)
XX.pred <- data.frame(matrix(runif(6),ncol=2))
colnames(XX.pred) <- c("XX1","XX2")
predict(model,newdata=XX.p
4 matches
Mail list logo