UKDriverDeaths is a time series giving the monthly totals
of car drivers in
Great Britain killed or seriously injured Jan 1969 to Dec 1984.
Compulsory wearing of seat belts was introduced on 31 Jan 1983.
Seatbelts is more information on the same problem.
Usage
UKDriverDeaths
Seatbelts
Format
Seatbelts is a multiple time series, with columns
DriversKilled
car drivers killed.
drivers
same as UKDriverDeaths.
front
front-seat passengers killed or seriously injured.
rear
rear-seat passengers killed or seriously injured.
kms
distance driven.
PetrolPrice
petrol price.
VanKilled
number of van (‘light goods vehicle’)
drivers.
law
0/1: was the law in effect that month?
Source
Harvey, A.C. (1989)
Forecasting, Structural Time Series Models and the Kalman Filter.
Cambridge University Press, pp. 519–523.
Durbin, J. and Koopman, S. J. (2001) Time Series Analysis by
State Space Methods. Oxford University Press.
http://www.ssfpack.com/dkbook/
References
Harvey, A. C. and Durbin, J. (1986) The effects of seat belt
legislation on British road casualties: A case study in structural
time series modelling. Journal of the Royal Statistical Society
series B, 149, 187–227.
Examples
require(stats); require(graphics)
## work with pre-seatbelt period to identify a model, use logs
work <- window(log10(UKDriverDeaths), end = 1982+11/12)
par(mfrow = c(3, 1))
plot(work); acf(work); pacf(work)
par(mfrow = c(1, 1))
(fit <- arima(work, c(1, 0, 0), seasonal = list(order = c(1, 0, 0))))
z <- predict(fit, n.ahead = 24)
ts.plot(log10(UKDriverDeaths), z$pred, z$pred+2*z$se, z$pred-2*z$se,
lty = c(1, 3, 2, 2), col = c("black", "red", "blue", "blue"))
## now see the effect of the explanatory variables
X <- Seatbelts[, c("kms", "PetrolPrice", "law")]
X[, 1] <- log10(X[, 1]) - 4
arima(log10(Seatbelts[, "drivers"]), c(1, 0, 0),
seasonal = list(order = c(1, 0, 0)), xreg = X)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(datasets)
> png(filename="/home/ddbj/snapshot/RGM3/R_rel/result/datasets/UKDriverDeaths.Rd_%03d_medium.png", width=480, height=480)
> ### Name: UKDriverDeaths
> ### Title: Road Casualties in Great Britain 1969-84
> ### Aliases: UKDriverDeaths Seatbelts
> ### Keywords: datasets
>
> ### ** Examples
>
> require(stats); require(graphics)
> ## work with pre-seatbelt period to identify a model, use logs
> work <- window(log10(UKDriverDeaths), end = 1982+11/12)
> par(mfrow = c(3, 1))
> plot(work); acf(work); pacf(work)
> par(mfrow = c(1, 1))
> (fit <- arima(work, c(1, 0, 0), seasonal = list(order = c(1, 0, 0))))
Call:
arima(x = work, order = c(1, 0, 0), seasonal = list(order = c(1, 0, 0)))
Coefficients:
ar1 sar1 intercept
0.4378 0.6281 3.2274
s.e. 0.0764 0.0637 0.0131
sigma^2 estimated as 0.00157: log likelihood = 300.85, aic = -593.7
> z <- predict(fit, n.ahead = 24)
> ts.plot(log10(UKDriverDeaths), z$pred, z$pred+2*z$se, z$pred-2*z$se,
+ lty = c(1, 3, 2, 2), col = c("black", "red", "blue", "blue"))
>
> ## now see the effect of the explanatory variables
> X <- Seatbelts[, c("kms", "PetrolPrice", "law")]
> X[, 1] <- log10(X[, 1]) - 4
> arima(log10(Seatbelts[, "drivers"]), c(1, 0, 0),
+ seasonal = list(order = c(1, 0, 0)), xreg = X)
Call:
arima(x = log10(Seatbelts[, "drivers"]), order = c(1, 0, 0), seasonal = list(order = c(1,
0, 0)), xreg = X)
Coefficients:
ar1 sar1 intercept kms PetrolPrice law
0.3348 0.6672 3.3539 0.0082 -1.2224 -0.0963
s.e. 0.0775 0.0612 0.0441 0.0902 0.3839 0.0166
sigma^2 estimated as 0.001476: log likelihood = 349.73, aic = -685.46
>
>
>
>
>
> dev.off()
null device
1
>