[18804] in s-news-athena
[S] argument for predict()
daemon@ATHENA.MIT.EDU (fan@katan.cybercom.net)
Fri Jul 30 18:19:05 1999
From: fan@katan.cybercom.net
Date: Fri, 30 Jul 1999 18:09:30 -0400 (EDT)
To: s-news@wubios.wustl.edu
Message-Id: <Pine.LNX.4.04.9907301759560.4138-100000@katan.cybercom.net>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
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