s-news
[Top] [All Lists]

[S] argument for predict()

To: s-news@wubios.wustl.edu
Subject: [S] argument for predict()
From: fan@katan.cybercom.net
Date: Fri, 30 Jul 1999 18:09:30 -0400 (EDT)
Sender: owner-s-news@wubios.wustl.edu
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

<Prev in Thread] Current Thread [Next in Thread>
  • [S] argument for predict(), fan <=