Simulate a fake data set that can be used to test mixed frequency code.
SimulateFakeMixedFrequencyData(nweeks,
xdim,
number.nonzero = xdim,
start.date = as.Date("2009-01-03"),
sigma.obs = 1.0,
sigma.slope = .5,
sigma.level = .5,
beta.sd = 10)
Returns a list with the following components
A zoo time series containing the
monthly values to be modeled.
A zoo time series containing the
weekly observations that aggregate to coarse.target.
A zoo matrix corresponding to
fine.target containing the set of predictors variables to use
in bsts.mixed prediction.
The vector of "true" regression coefficients used to
simulate fine.target.
The residual standard deviation that was used to
simulate fine.target.
The value of sigma.slope used to
simulate fine.target.
The value of sigma.level use to
simulate fine.target.
The combined contribution of the simulated latent
state on fine.target, including regression effects.
A matrix containin the fine-scale state of the model
being simulated. Columns represent time (weeks). Rows correspond
to regression (a constant 1), the local linear trend level, the
local linear trend slope, the values of fine.target, and the
weekly partial aggregates of coarse.target.
The number of weeks of data to simulate.
The dimension of the predictor variables to be simulated.
The number nonzero coefficients. Must be
less than or equal to xdim.
The date of the first simulated week.
The residual standard deviation for the fine time scale model.
The standard deviation of the slope component of the local linear trend model for the fine time scale data.
The standard deviation of the level component fo the local linear trend model for the fine time scale data.
The standard deviation of the regression coefficients to be simulated.
Steven L. Scott steve.the.bayesian@gmail.com
The simulation begins by simulating a local linear trend model for
nweeks to get the trend component.
Next a nweeks by xdim matrix of predictor variables is
simulated as IID normal(0, 1) deviates, and a xdim-vector of
regression coefficients is simulated as IID normal(0, beta.sd).
The product of the predictor matrix and regression coefficients is
added to the output of the local linear trend model to get
fine.target.
Finally, fine.target is aggregated to the month level to get
coarse.target.
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.
bsts.mixed,
AddLocalLinearTrend,
fake.data <- SimulateFakeMixedFrequencyData(nweeks = 100, xdim = 10)
plot(fake.data$coarse.target)
Run the code above in your browser using DataLab