[R] Odp: Help me with prediction in linear model
Petr PIKAL
petr.pikal at precheza.cz
Mon Jul 26 08:22:48 CEST 2010
Hi
r-help-bounces at r-project.org napsal dne 24.07.2010 11:48:11:
>
> Thanks Murphy and pikal,
>
> I need another help,for fitting first fourier transformation ,i used
> following thing .Please advise on this
>
>
> beer_monthl has 400+ records
>
> EXample:
> > head(beer_monthly)
> beer
> 1 93.2
> 2 96.0
> 3 95.2
> 4 77.1
> 5 70.9
> 6 64.8
>
>
>
>
> time<-seq(1956,1995.2,length=length(beer_monthly))
Even this is "not working"
time<-seq(1956,1995.2,length=length(beer_monthly))
Error in seq.default(1956, 1995.2, length = length(beer_monthly)) :
object 'beer_monthly' not found
> sin.t<-sin(2*pi*time)
> cos.t<-cos(2*pi*time)
> beer_fit_fourier=lm(beer_monthly[,1]~poly(time,2)+sin.t+cos.t) #this is
not
> working
gives me result without error
> beer_fit_fourier=lm(beer_monthly[,1]~time+time2+sin.t+cos.t) #it is
working
>
>
> #prediction is not workinng
>
> tpred_four <- data.frame(time = seq(1995, 1998, length = 20))
> predict(beer_fit_fourier, newdata = tpred_four)
>
You'd rather read some documentation about lm and predict. You do not have
variables sin.t and cos.t in your newdata.
Please do read docs, posting guide and provide reproducible example.
> Is there any way to fit first fourier frequency ,
>
> Please assist.
>
> Thanks in advance
>
>
>
>
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Help-me-with-
> prediction-in-linear-model-tp2297313p2300991.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