# if 'xts' is not installed you can still do this
tsplot(timex(lap.xts), lap.xts, ncolm=3, col=astsa.col(4,wheel=TRUE,num=11), scale=.9)
# differencing (on its own) loses an obs
dCmort = diff(log(lap.xts[,'Cmort']))
tsplot(timex(lap.xts)[-1], dCmort, col=4, gg=TRUE)
# classic IMA(1,1)
acf2(dCmort, col=2:7, lwd=4)
if (FALSE) {
library(xts) # assumes package has been installed
plot(lap.xts$Cmort, col=4)
lapw = apply.weekly(lap.xts, FUN=colMeans) # get weekly averages
plot(lapw[,c('Cmort', 'Temp', 'Part')], col=astsa.col(2:4, .7), main=NA)
addLegend(col=2:4, lty=1, lwd=2, ncol=3, bty="white")
sarima(lapw$Cmort, 0,1,1, no.constant=TRUE) # fit ARIMA(0,1,1) to weekly Cmort
}
Run the code above in your browser using DataLab