Learn R Programming

shrinkTVP (version 1.0.0)

simTVP: Generate synthetic data from a time-varying parameter model

Description

simTVP generates synthetic data from a time-varying parameter model. The covariates are always generated i.i.d. from a Normal(0,1) distribution.

Usage

simTVP(N = 200, d = 3, sv = FALSE, sigma2 = 1, theta, beta_mean)

Arguments

N

integer > 2. Indicates the length of the time series to be generated. The default value is 200.

d

positive integer. Indicates the number of covariates to simulate. The default value is 3.

sv

logical value. If set to TRUE, the data will be generated with stochastic volatility for the errors of the observation equation using svsim. The default value is FALSE.

sigma2

positive real number. Determines the variance on the errors of the observation equation. Ignored if sv is TRUE. The default value is 1.

theta

(optional) vector containing positive real numbers. If supplied, these determine the variances of the innovations of the state equation. Otherwise, the elements of theta are generated from a ChiSq(1) distribution. Has to be of length d or an error will be thrown.

beta_mean

(optional) vector containing real numbers. If supplied, these determine the mean of the initial value of the state equation. Otherwise, the elements of beta_mean are generated from a Normal(0,1) distribution. Has to be of length d or an error will be thrown.

Value

The value returned is a list object containing:

data

a data frame that holds the simulated data.

true_vals

a list object containing:

  • theta: the values of theta used in the data generating process.

  • beta_mean: the values of beta_mean used in the data generating process.

  • beta: the true paths of beta used for the data generating process.

  • sigma2: the value(s) of sigma2 used in the data generating process.

Examples

Run this code
# NOT RUN {
# Generate a time series of length 300
res <- simTVP(N = 300)

# Extract the generated data
data <- res$data

# Now with stochastic volatility
res_sv <- simTVP(N = 300, sv = TRUE)
# }

Run the code above in your browser using DataLab