k <- 10 # Number of artificial coefficients
tt <- 1000 # Number of observations
set.seed(1234) # Set RNG seed
# Generate artificial data according to a random walk
a <- matrix(rnorm(k), k, tt + 1)
for (i in 2:(tt + 1)) {
a[, i] <- a[, i - 1] + rnorm(k, 0, sqrt(1 / 100))
}
a_init <- matrix(a[, 1]) # Define initial state
a <- matrix(a[, -1]) # Drop initial state from main sample and make vector
# Define priors
shape_prior <- matrix(1, k)
rate_prior <- matrix(.0001, k)
# Obtain posterior draw
post_gamma_state_variance(a, a_init, shape_prior, rate_prior, inverse = FALSE)
Run the code above in your browser using DataLab