Dear all,

 

I found really difficult with the time series questions, please help me with 
this monthly airline series!

 

I have run the following r code, and there is an error appeared at the end.  
The data files was enclosed in the email.

I'm sorry the errors message appeared in chinese, but it says 
"plot.xy(xy.coords(x, y), type = type, ...) :

errors in argument has more than 3 matches"

 

> y=scan('F:/Math355/AIRLINE.txt',skip=2,nlines=18)
Read 144 items
> yts=ts(log(y))
> plot(yts,main="LOG AIRLINE TOTALS",type='p',col=2)
> n=length(y)
> time=seq(1:n)
> 
> month=c(rep(seq(1:12),12))
> fmonth=as.factor(month)
> ymod1=lm(yts~time+fmonth)
> summary(ymod1)

 

> yfit1=ymod1$fitted
> lines(yfit1,c=3)
错误于 plot.xy(xy.coords(x, y), type = type, ...) : 
  变元3有多个与之相对应的正式变元


Also, for a similar data set quarterly sales of spirits series, what is the 
best model to use?? Should I use ARIMA??

 

 

 

Many thanks and regard,

Cathy Wong
                                          
_________________________________________________________________
Got a cool Hotmail story? Tell us now
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=40,col=6)

'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
:
______________________________________________
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