state space models - jyväskylän yliopistousers.jyu.fi/~jovetale/posters/kfasposter.pdf ·...
TRANSCRIPT
Jouni HelskeUniversity of Jyvaskyla, Department of Mathematics and [email protected]
generalizedlinear modelsdynamic
factoranalysis
ARIMA
modelscubicsplines
structural
time series
dynamic
linear
regression
exponentialsmoothing
mixed
modelsgenera
lized
linear m
ixed
models
state space models
multivariate
linear models
Exponential family state space model with p time series:
p∏i=1
pi(yt | Ztαt) pi =
GaussianPoissonBinomialNegative binomialGamma
αt+1 = Ttαt +Rtηt, ηt ∼ N(0, Qt), α1 ∼ N(a1, P1)
Main features of KFAS
•Kalman filtering and smoothing•Simulation smoothing for Gaussian models• Importance sampling and Laplace approximation for
non-Gaussian models•Exact diffuse initialization of unknown states•Multivariate models with different distributions for each series•Maximum likelihood estimation•Prediction intervals•Multiple types of residuals
ReferencesJ. Durbin and S. J. Koopman. Time series analysis by state space methods (Second edition). Oxford
University Press, New York, 2012.J. Helske. KFAS: Exponential family state space models in R. Submitted, 2015.
github.com/helske/KFAS tinyurl.com/KFASvignette tinyurl.com/KFASposter
Alcohol related deaths in Finlandp(yt|θt) = Poisson(uteθt) ut = population at time t
θt = µt + εt, εt ∼ N(0, Qnoise) εt = additional white noiseµt+1 = µt + νt + ξt, ξt ∼ N(0, Qlevel) µt = random walk with driftνt+1 = νt νt = constant slope
Parameter estimation and prediction
alcoholPred <- window(alcohol, start = 1969, end = 2007)# build modelmod <- SSModel(alcoholPred[,1:4] ˜
SSMtrend(2, Q = list(matrix(NA,4,4), diag(0,4))) +SSMcustom(Z = diag(4), T = diag(0,4),
Q = matrix(NA,4,4), P1 = matrix(NA,4,4)),distribution = "poisson", u = alcoholPred[,5:8])
# model updating function for fitSSMupdatefn <- function(pars, model, ...){Q <- diag(exp(pars[1:4])); Q[upper.tri(Q)] <- pars[5:10]model["Q", etas = "level"] <- crossprod(Q)Q <- diag(exp(pars[11:14])); Q[upper.tri(Q)] <- pars[15:20]model["Q", etas = "custom"] <- model["P1", states = "custom"] <-crossprod(Q)
model}model <- fitSSM(mod, updatefn = updatefn, inits = init,
method = "BFGS")$model# predictionpred <- predict(model, newdata =
SSModel(ts(matrix(NA,6,4), start = 2008) ˜ -1+ SSMcustom(Z = model$Z, T = model$T,
R = model$R, Q = model$Q),distribution = "poisson"),interval = "prediction", nsim = 10000)
out <- KFS(model, nsim = 1000)trend <- exp(signal(out, states = "trend")$signal)
death at age 30−39
1970 1980 1990 2000 2010
1015
2025
3035
death at age 40−49
1970 1980 1990 2000 2010
2040
6080
death at age 50−59
1970 1980 1990 2000 2010
5010
015
020
0
death at age 60−69
1970 1980 1990 2000 2010
5010
015
0
Num
ber
of a
lcoh
ol r
elat
ed d
eath
s pe
r 10
0,00
0 pe
rson
s in
Fin
land
Year
Figure 1: Observed number of alcohol related deaths per 100,000 persons in Finland (blue),smoothed trend (orange), and count predictions for years 2008–2012 together with 95% pre-diction intervals (green).
AcknowledgementsAuthor is grateful for the financial support of Emil Aaltonen Foundation.