Dear all,
 
I am having difficulty to built a model of quarter sales of spirits data, and 
deciding which is the best model. The yfit2, yfit3, and yfit4 lines was not 
appeared right at the end. The data and script is enclosed with this email.
 
I am using the harmonic regression model to exam the periodogram of the 
residuals. I am not sure this step is right or not? Which is the best formula 
to analysis the trend and seasonality for this data set? AR, MA or ARMA and how 
to decide?  
 
Please help!!
 
many thanks and regard,
Cathy Wong
 
                                          
_________________________________________________________________
Send us your Hotmail stories and be featured in our newsletter

'SPIRITS SALES' :
 40 :
 82  59 107 221 102  75 122 278 140 103
163 335 166 113 175 354 172 113 179 417
229 127 157 462 225 156 271 592 290 196
334 617 339 219 343 724 383 255 409 703
:
options(windowsBuffered=FALSE)
y=scan('F:/Math355/SPIRITS.txt',skip=2,nline=4)
yts=ts(log(y))
plot(yts,main="Log Quarterly Sales of Alcoholic Spirits",type='b',col=2)

n=length(y)
time=seq(1:n)
quarter=c(rep(seq(1:4),10))
quarter
fquarter=as.factor(quarter)

ymod1=lm(yts~time+fquarter)
summary(ymod1)
yfit1=ymod1$fitted
lines(yfit1,col=3)

yres1=ymod1$res
plot(yres1)

ymod2=lm(y~time+cos(2*pi*time/4)+sin(2*pi*time/4))
summary(ymod2)
yfit2=ymod2$fitted
plot(yts,main="Quarterly Sales of Alcoholic Spirits in Log 
Transcations",type='p',col=2)
lines(yfit2,col=4)

ymod3=lm(y~time+cos(2*pi*time/4)+sin(2*pi*time/4)+cos(2*pi*time/2)+sin(2*pi*time/2))
summary(ymod3)
yfit3=ymod3$fitted
plot(yts,main="Quarterly Sales of Alcoholic Spirits in Log 
Transcations",type='p',col=2)
lines(yfit2,col=4)

ymod3=lm(y~time+cos(2*pi*time/4)+sin(2*pi*time/4)+cos(2*pi*time/1)+sin(2*pi*time/1))
summary(ymod3)
yfit3=ymod3$fitted
plot(yts,main="Quarterly Sales of Alcoholic Spirits in Log 
Transcations",type='p',col=2)
lines(yfit2,col=4)

yspec=spec.pgram(yts,pad=4,detrend=TRUE)
plot(yspec$freq,yspec$spec,type='l',col=5)

resspec=spec.pgram(ymod3$res,pad=4,detrend=FALSE)
plot(resspec$freq,resspec$spec,type='l',col=5)

acf(ymod3$res,lag.max=20,col=6)
pacf(ymod3$res,lag.max=20,col=6)
______________________________________________
R-help@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.

Reply via email to