Age of Death of Successive Kings of England.Starting with William the Conqueror

Source: McNeill, “Interactive Data Analysis”

(1)Plot the data

kings<-read.table("kings.dat.txt",skip = 3)
tk<-ts(kings)
plot.ts(tk,xlab="Time",ylab="years",main="Age of death of succissive kings in England")

(2)Test for the stationary(plotting auto-corelation function)

acf(tk,lag=30)

(3)Plot the partial auto-coretaliton function

pacf(tk,lag=30)

(4)Model Identification

Tentative models:One significance spike in ACF and one significance spike in PACF

(5)Tentative models

ACF for MA and PAFC for AR

  • MA(1) model
  • AR(1) model
  • ARMA(1,1) model

(6)Parameter estimation

  • For MA(1) model:
fit.ma1<-arima(tk,order=c(0,0,1))
fit.ma1
## 
## Call:
## arima(x = tk, order = c(0, 0, 1))
## 
## Coefficients:
##          ma1  intercept
##       0.3308    55.3263
## s.e.  0.1278     3.1159
## 
## sigma^2 estimated as 233:  log likelihood = -174.12,  aic = 354.24
  • For AR(1) model:
fit.ar1<-arima(tk,order=c(1,0,0))
fit.ar1
## 
## Call:
## arima(x = tk, order = c(1, 0, 0))
## 
## Coefficients:
##          ar1  intercept
##       0.3921    55.3666
## s.e.  0.1392     3.7503
## 
## sigma^2 estimated as 224.9:  log likelihood = -173.41,  aic = 352.82
  • For ARIMA(1,1) model:
fit.ar1.ma1<-arima(tk,order=c(1,0,1))
fit.ar1.ma1
## 
## Call:
## arima(x = tk, order = c(1, 0, 1))
## 
## Coefficients:
##          ar1      ma1  intercept
##       0.8341  -0.5740    56.0862
## s.e.  0.1696   0.2527     5.4798
## 
## sigma^2 estimated as 216.1:  log likelihood = -172.63,  aic = 353.25

(7)Selecting the best model

Best modl is the minimum AIC model.(i.e. AR(1) model)

(8)Testing adequacy of the model(Residual checking)

res.fit.ar1<-residuals(fit.ar1)
res.fit.ar1
## Time Series:
## Start = 1 
## End = 42 
## Frequency = 1 
##  [1]   4.26228680 -14.18354185  16.48282801  -9.92851767   2.73785219
##  [6] -13.61498424  -0.12503259  11.73785219   8.85576113 -17.32065708
## [11]  14.48282801 -25.14423887   0.01208264 -18.08572960   2.01208264
## [16] -11.87000841 -36.73289318  -3.75298989   5.61994324   1.56143397
## [21] -39.61498424   3.07059190  18.48282801  -1.71279648  -8.79140245
## [26]   6.52213099  29.20859755 -12.37916634  12.77715517  -9.32065708
## [31] -20.65428722   2.40422204  14.12999159  17.07148233  17.15008829
## [36]   1.58153068  11.07148233  19.50292471   2.58153068   9.67934292
## [41]  15.89506412  -7.84991171
  • (8.1)Residual histogram
hist(res.fit.ar1,col="light blue")

  • (8.2)Residual plot
plot.ts(res.fit.ar1,ylab="Residuals")
points(res.fit.ar1,pch=16)
abline(0,0,col="red",lwd=2)

  • (8.3)Auto-corretlation function for residual plot
acf(res.fit.ar1)

  • (8.3) Partial auto-corelation function for residual plot
pacf(res.fit.ar1)

(9)Diagnostick checking

  • Box-Pierce test:
Box.test(res.fit.ar1,type="Box-Pierce")
## 
##  Box-Pierce test
## 
## data:  res.fit.ar1
## X-squared = 0.031555, df = 1, p-value = 0.859
  • Ljung-Box test:
Box.test(res.fit.ar1,type="Ljung-Box")
## 
##  Box-Ljung test
## 
## data:  res.fit.ar1
## X-squared = 0.033864, df = 1, p-value = 0.854

Both Box-Pierce and Ljung-Box are not rejected the NULL HYPOTHESIS at alpha=0.05.So, AR(1) model is the best model