[R] Odp: Help me with prediction in linear model

Petr PIKAL petr.pikal at precheza.cz
Thu Jul 22 09:48:24 CEST 2010


Hi

r-help-bounces at r-project.org napsal dne 21.07.2010 17:46:02:

> 
> Hi R-community,
> I have the code as follows,i Fitted model as follows
> lbeer<-log(beer_monthly)
> t<-seq(1956,1995.2,length=length(beer_monthly)) #beer_monthly contains 
400+
> entries

not needed
> t2=t^2

> beer_fit_parabola=lm(lbeer~t+t2)

beer_fit_parabola=lm(lbeer~t+I(t^2))

you can use poly(t,2) but coefficients are not directly applicable in 
equation.

> 
> Below is not working for me.
> Please help me in preparing the new data set for the below prediction
> 
> 
> 
> 
predict(beer_fit_parabola,newdata=data.frame(t=seq(1995,1998,length=20),t2=seq
> (1995,1998,length=20))

predict(beer_fit_parabola,newdata=data.frame(t=seq(1995,1998,length=20))

shall be enough
Regards
Petr


> 
> #it is listing all 400+ entries ,but not 20 ahead prediction.
> 
> Thanks In advance for your help
> -- 
> View this message in context: 
http://r.789695.n4.nabble.com/Help-me-with-
> prediction-in-linear-model-tp2297313p2297313.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list