dirm {bsts}  R Documentation 
A dynamic intercept regression is a regression model where the
intercept term is a state space model. This model differs from
bsts
in that there can be multiple observations per time
point.
dirm(formula, state.specification, data, prior = NULL, contrasts = NULL, na.action = na.pass, niter, ping = niter / 10, model.options = DirmModelOptions(), timestamps = NULL, seed = NULL, ...)
formula 
A formula, as you would supply to 
state.specification 
A list with elements created by
The state specification describes the dynamic intercept term in the regression model. 
data 
An optional data frame, list or environment (or object
coercible by 
prior 
A prior distribution for the regression component of the
model, as created by 
contrasts 
An optional list containing the names of contrast
functions to use when converting factors numeric variables in a
regression formula. This argument works exactly as it does in

na.action 
What to do about missing values. The default is to allow missing responses, but no missing predictors. Set this to na.omit or na.exclude if you want to omit missing responses altogether. 
niter 
A positive integer giving the desired number of MCMC draws. 
ping 
A scalar giving the desired frequency of status messages.
If ping > 0 then the program will print a status message to the
screen every 
model.options 
An object created by

timestamps 
The timestamp associated with each value of the
response. This is most likely a 
seed 
An integer to use as the random seed for the underlying
C++ code. If 
... 
Extra arguments to be passed to

The fitted model is a regression model with an intercept term given by
a structural time series model. This is similar to the model fit by
bsts
, but it allows for multiple observations per time
period.
Currently dirm
only supports Gaussian observation errors, but
look for that to change in future releases.
An object of class bsts
which is a list with the
following components
coefficients 
A 
sigma.obs 
A vector of length 
The returned object will also contain named elements holding the MCMC
draws of model parameters belonging to the state models. The names of
each component are supplied by the entries in
state.specification
. If a model parameter is a scalar, then
the list element is a vector with niter
elements. If the
parameter is a vector then the list element is a matrix with
niter
rows. If the parameter is a matrix then the list element
is a 3way array with first dimension niter
.
Finally, if a model formula was supplied, then the returned object will contain the information necessary for the predict method to build the design matrix when a new prediction is made.
Steven L. Scott steve.the.bayesian@gmail.com
Harvey (1990), "Forecasting, structural time series, and the Kalman filter", Cambridge University Press.
Durbin and Koopman (2001), "Time series analysis by state space methods", Oxford University Press.
George and McCulloch (1997) "Approaches for Bayesian variable selection", Statistica Sinica pp 339–374.
bsts
,
AddLocalLevel
,
AddLocalLinearTrend
,
AddSemilocalLinearTrend
,
AddSeasonal
AddDynamicRegression
SpikeSlabPrior
,
SdPrior
.
SimulateDirmData < function(observation.sd = 1, trend.sd = .1, time.dimension = 100, nobs.per.period = 3, xdim = 4) { trend < cumsum(rnorm(time.dimension, 0, trend.sd)) total.sample.size < nobs.per.period * time.dimension predictors < matrix(rnorm(total.sample.size * xdim), nrow = total.sample.size) coefficients < rnorm(xdim) expanded.trend < rep(trend, each = nobs.per.period) response < expanded.trend + predictors %*% coefficients + rnorm( total.sample.size, 0, observation.sd) timestamps < seq.Date(from = as.Date("20080101"), len = time.dimension, by = "day") extended.timestamps < rep(timestamps, each = nobs.per.period) return(list(response = response, predictors = predictors, timestamps = extended.timestamps, trend = trend, coefficients = coefficients)) } data < SimulateDirmData(time.dimension = 20) ss < AddLocalLevel(list(), data$response) # In real life you'd want more than 50 MCMC iterations. model < dirm(data$response ~ data$predictors, ss, niter = 50, timestamps = data$timestamps)