180 Handbook of Discrete-Valued Time Series
8.5.2.1 Computation Details
For MCMC, we use a single-move Gibbs sampler to draw values of the states λ
t
and
s
t
in both cases. We run the MCMC algorithm for 700,000 iterations. We discard the
rst 100,000 iterations as a burn-in period. Next, in order to reduce the autocorrelation
between successive values of the simulated chain, only every 100th value of the chain was
stored.
For SMC, we ran the adaptive random walk Metropolis for 300,000 iterations and
discarded the rst 100,000, while the particle lter was run with 2,000 particles.
For INLA, the R commands required for the analysis are described in the Appendix.
8.5.2.2 Results
The results obtained with the different approximating schemes are summarized later in
this chapter. They show reasonable agreement for both models between the different
approximating schemes.
The main results for the system variances are summarized in Tables 8.3 and 8.4.
Figure 8.4 shows the posterior smoothed mean of the mean rates λ
t
for model with
overdisperssion.
TABLE 8.3
Summary of the posterior distribution of the Poisson model without
overdispersion applied to the Polio data set
Poisson without Overdispersion
Parameter MCMC SMC INLA
W
1
0.0841 0.0889 0.0853
(0.0201, 0.1953) (0.0281, 0.2012) (0.0273, 0.1939)
W
2
0.0209 0.0215 0.0206
(0.0034, 0.0689) (0.0039, 0.0679) ( 0.0039, 0.0637)
TABLE 8.4
Summary of the posterior distribution of the Poisson model with
overdispersion applied to the Polio data set
Poisson without Overdispersion
Parameter MCMC SMC INLA
W
1
0.0490 0.0472 0.0460
(0.0089, 0.1485) (0.0109, 0.1261) (0.0107, 0.1187)
W
2
0.0162 0.0157 0.0146
(0.0028, 0.0601) (0.0032, 0.0502) (0.0031, 0.0442)
W
3
0.2526 0.2648 0.2345
(0.0185, 0.6822) (0.0256, 0.6022) ( 0.0319, 0.5339)
181 Dynamic Bayesian Models for Discrete-Valued Time Series
λ
t
10
15
5
0
MCMC
SMC
INLA
1970 1972 1974 1976 1978 1980 1982 1984
Year
FIGURE 8.4
Polio counts (points) in the United States, January 1970–December 1983, and posterior smoothed mean sequence,
λ
t
, of the tted seasonal Poisson SSM with overdispersion.
8.6 Final Remarks
This chapter presents an overview of the possibilities associated with the analysis of
discrete time series with SSM under the Bayesian perspective. A number of frequently
used model components are described, including autoregressive dependence, seasonality,
overdispersion, and transfer functions. The techniques most commonly used nowadays
(MCMC, SMC, INLA) to analyze these models are also described and illustrated.
INLA is by far the fastest method for Bayesian data analysis, but suffers from a lack of
measures to quantify and assess the errors committed. Also, it is not trivial to set the grid of
values for computation of the integrals involved. This shortcoming is largely mitigated by
the availability of the software R-INLA, but users become restricted to the options available
there and are unable to easily introduce their own building blocks into the software.
SMC enables fairly fast generation of online posterior distributions of the state param-
eters and the hyperparameters. If one is interested in their smoothed distributions, as we
showed in our illustrations, then their processing time becomes nonnegligible. This is still
a lively area of research, and we may see in the near future ways to avoid the currently
high computing cost of smoothed distributions. Some of the techniques associating SMC
with MCMC seem to be promising.
Finally, MCMC is the standard approach for Bayesian data analysis these days. It is time
consuming and requires nontrivial tuning when full conditionals are not available, but
is well documented and has been used by many users under a large variety of settings.
182 Handbook of Discrete-Valued Time Series
Further, there are several reliable MCMC software that are equipped to handle a variety of
sophisticated models.
The results that we present in the two applications show some discrepancies between the
methods. These are to be expected since there are errors involved in the approximations.
However, we believe that these differences did not interfere with the overall analysis in any
meaningful way. In summary, the message is that all these approaches can be safely used
(especially in the linear realm) with the guidance provided in this chapter.
8A Appendix
This Appendix contains the commands required for the analysis of the datasets of Section
5 with the R package INLA.
8A.1 Deep Brain Stimulation
The rst step is to load the R package INLA and set-up a data.frame that will be used
within the inla() function.
require(INLA)
# Create data.frame
data_frame = data.frame(y = y, z = z, time = 1:length(y))
head(data_frame, 3)
y z1 z2 time
10 1 1 1
21 1 1 2
30 3 1 3
The response variable y takes the value 1 to indicate a REM sleep cycle and zero oth-
erwise. z1 and z2 stand for the z covariates described in Section 8.5.1 and time assumes
the values t = 1, ..., n, where n is the number of observations, and will be used to model
the time-specic effect x
t
on the observed process. The model can then be tted with the
command line
inla1 <- inla(formula = y ˜ 1 + z1 + z2 +
f(time, model = "ar1", hyper = hyper.ar1),
family = ’binomial’,
data = data_frame,
control.fixed = control.fixed(prec.intercept=0.001,
prec = 0.001),
control.family = list(link = "probit"),
control.predictor = list(compute = TRUE))
183 Dynamic Bayesian Models for Discrete-Valued Time Series
The formula argument of our model assumes that our linear predictor has an intercept,
two covariates z1 and z2 and a time-specic effect indexed by time.Thecontrol.fixed
argument was used to set the precision of the priors for the xed-effects equal to 0.001,
which leads to a variance equal to 1000. The model for the time-specic effect was set to
follow an autoregressive model of order 1 and the priors for its hyperparameters δ and τ
were set by hyper = hyper.ar1 inside the f() function, where
hyper.ar1 = list(prec = list(prior="loggamma",
param = c(0.01, 0.01)),
rho = list(prior = table))
and table was dened in such a way to encode δ N
(1,1)
(0.95, 100). For detailed
information on how to set priors, please visit http://www.r-inla.org/models/priors.
The family argument indicates that we are dealing with binomial data. The
control.family tells INLA that we want a probit link function. Lastly, besides the
marginal posterior distribution of the latent eld x and the elements of hyperparameters
θ, control.predictor sets INLA to compute the marginal posterior distribution of the
linear predictors η(x) as well, which is not done by default.
8A.2 Poliomyelitis in the U.S.
Our data.frame contains the following columns: y, time, seasonal and iid, which
represent the response variable y
t
and the indexes for the time-specic effect μ
t
, the seasonal
effect s
t
and the i.i.d. random-effects γ
t
, respectively.
n = length(y)
data_frame = data.frame(y = y, time = 1:n,
seasonal = 1:n, iid = 1:n)
Notice that although time, seasonal,andiid assume identical values, the inla() func-
tion require the denition of a different index for each random-effect dened through the
f() functions.
We rst t the model without accounting for overdispersion with command line
n.seas = 12
formula1 = y ˜ -1 +
f(time, model = "rw1", constr=FALSE, hyper = hyper.rw1) +
f(seasonal, model = "seasonal", season.length = n.seas,
hyper = hyper.sea)
inla1 = inla(formula = formula1,
data = data_frame,
family="Poisson",
control.predictor = control.predictor(compute=TRUE))
In the model denition, -1 stands for the absence of an intercept in the model, the time-
specic random-effects were chosen to follow a random-walk model of order 1 (rw1)
without a sum-to-zero constrain t (constr=FALSE) and for the seasonal effect we spec-
ied that we were interested in a monthly frequency by setting season.length = 12.
The priors for the hyperparameter of the rw1 and the seasonal model were dened using a
184 Handbook of Discrete-Valued Time Series
similar syntax as the one displayed in Section 8.4.2. family="Poisson" indicates we are
dealing with count data and that we will use a Poisson likelihood in our model.
We now proceed to a model that also includes random-effects to account for overdis-
persion. We have only redened the arguments that change from one model to the other
in order to save space, while the arguments that remain the same as in inla1 have been
represented by *. The command line becomes
formula2 = y ˜ -1 +
f(time, model = "rw1", constr=FALSE, hyper = hyper.rw1) +
f(seasonal, model = "seasonal", season.length = n.seas,
hyper = hyper.sea) +
f(iid, model = "iid", hyper = hyper.iid)
inla2 = inla(formula = formula2, *)
The only new feature of this model is the addition of the i.i.d. random-effects to account
for overdispersion.
Acknowledgments
The authors thank an anonymous reviewer and the editors for their careful reading of this
work, and for their comments and suggestions that helped to improve the presentation.
Dani Gamerman was supported by a grant from CNPq-Brazil. Carlos A. Abanto-Valle
was supported by grants from CNPq-Brazil and FAPERJ. Ralph S. Silva was supported
by grants from CNPq-Brazil and FAPERJ.
References
Abanto-Valle, C. A. and Dey, D. K. (2014), State space mixed models for binary responses with scale
mixture of normal distributions links, Computational Statistics & Data Analysis, 71, 274–287.
Albert, J. and Chib, S. (1993), Bayesian analysis of binary and polychotomous response data, Journal
of the American Statistical Association, 88, 669–679.
Andrieu, C., Doucet, A., and Holenstein, R. (2010), Particle Markov chain Monte Carlo methods,
Journal of Royal Statistical Society, Series B, 72, 1–33.
Carlin, B. P., Polson, N. G., and Stoffer, D. S. (1992), A Monte Carlo approach to nonnormal and
nonlinear state-space modeling, Journal of the American Statistical Association, 87, 493–500.
Carter, C. K. and Kohn, R. (1994), On Gibbs sampler for State space models, Biometrika, 81, 541–553.
Carter, C. K. and Kohn, R. (1996), Markov chain Monte Carlo in conditionally Gaussian state space
models, Biometrika, 81, 589–601.
Carvalho, C., Johannes, M., Lopes, H., and Polson, N. (2010), Particle learning and smoothing,
Statistical Science, 25, 88–106.
Chan, K. S. and Ledolter, J. (1995), Monte Carlo EM estimation for time series models involving
counts, Journal of the American Statistical Association, 90, 242–252.
Chib, S. and Greenberg, E. (1995), Understanding the Metropolis-Hastings algorithm, The American
Statistician, 49, 327–335.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset