This should be a simple usage problem on lm.
I just did not get direct examples from the references.
What I want to do is prediction based on a linear model, or some other
model. I use matrix, instead of a data.frame. I did not expect the grammar
is a bit complex here.
#Example: regression
a<-1:10
b<-a+rnorm(10)
mod <- lm(b~a)
#what's the prediction when x=11?
predict(mod, 11) #but I get 10 fitted values
predict(mod, data.frame(11)) #still 10 values
#multivariate regression
a2<-a^2
mod <- lm(b~cbind(a,a2))
#next several lines gives errors
predict(mod, c(10,20))
predict(mod, data.frame(10,20))
predict(mod, data.frame(c(10,20)))
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|