# NOT RUN {
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("2008-01-01"),
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)
# }
Run the code above in your browser using DataLab