Skip to content
Prev 70767 / 398526 Next

simple predict question

Alternatively, one can convert dat to a data frame first (?lm states that data is "an optional data frame containing the variables in the model."):

dat<-matrix(c(0,0,10,20),2,byrow=T)
dat <- as.data.frame(dat)
lm1<-lm(V2~V1, dat)
predict(lm1, data.frame(V1=seq(0,10,1)))
 1  2  3  4  5  6  7  8  9 10 11 
 0  2  4  6  8 10 12 14 16 18 20 

Cheers .........

Peter Alspach
On 5/31/05, sms13+ at pitt.edu <sms13+ at pitt.edu> wrote:
I think the names are confusing it.  Try:

x <- dat[,1]; y <- dat[,2]
lm1 <- lm(y ~ x)
predict(lm1, data.frame(x = 1:10))

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________________

The contents of this e-mail are privileged and/or confidenti...{{dropped}}