simulate.fake.mixed.frequency.data {bsts}R Documentation

Simulate fake mixed frequency data

Description

Simulate a fake data set that can be used to test mixed frequency code.

Usage

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)

Arguments

nweeks

The number of weeks of data to simulate.

xdim

The dimension of the predictor variables to be simulated.

number.nonzero

The number nonzero coefficients. Must be less than or equal to xdim.

start.date

The date of the first simulated week.

sigma.obs

The residual standard deviation for the fine time scale model.

sigma.slope

The standard deviation of the slope component of the local linear trend model for the fine time scale data.

sigma.level

The standard deviation of the level component fo the local linear trend model for the fine time scale data.

beta.sd

The standard deviation of the regression coefficients to be simulated.

Details

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.

Value

Returns a list with the following components

coarse.target

A zoo time series containing the monthly values to be modeled.

fine.target

A zoo time series containing the weekly observations that aggregate to coarse.target.

predictors

A zoo matrix corresponding to fine.target containing the set of predictors variables to use in bsts.mixed prediction.

true.beta

The vector of "true" regression coefficients used to simulate fine.target.

true.sigma.obs

The residual standard deviation that was used to simulate fine.target.

true.sigma.slope

The value of sigma.slope used to simulate fine.target.

true.sigma.level

The value of sigma.level use to simulate fine.target.

true.trend

The combined contribution of the simulated latent state on fine.target, including regression effects.

true.state

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.

Author(s)

Steven L. Scott steve.the.bayesian@gmail.com

References

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.

See Also

bsts.mixed, AddLocalLinearTrend,

Examples

  fake.data <- SimulateFakeMixedFrequencyData(nweeks = 100, xdim = 10)
  plot(fake.data$coarse.target)

[Package bsts version 0.9.10 Index]