[R] LM Model

Mark Lyman mark.lyman at gmail.com
Fri Feb 9 17:49:11 CET 2007


Simon P. Kempf <simon.kempf <at> web.de> writes:

[SNIP]
> 
> But I want to skip the lm function and specify my own regression equation
> RENT= 15 -0.15*AGE1 and then use the predict.lm function. However, in order
> to use the predict.lm function I need an object of class lm. Is there any
> way to do so? Or maybe somebody has another solution? 
> 
> Thanks in advance,
> 
> Simon

Here is one way. Take a look at help(offset), help(lm), and help(lm.predict).
> xx <- runif(30)
> yy <- rnorm(30)
> mydata<-data.frame(xx,yy)
> lm(yy~offset(15*rep(1,30))+offset(-0.15*xx)-1,mydata)


Mark Lyman



More information about the R-help mailing list