SimSSMVARFixed {simStateSpace}R Documentation

Simulate Data from the Vector Autoregressive Model (Fixed Parameters)

Description

This function simulates data from the vector autoregressive model using a state space model parameterization. It assumes that the parameters remain constant across individuals and over time.

Usage

SimSSMVARFixed(
  n,
  time,
  mu0,
  sigma0_l,
  alpha,
  beta,
  psi_l,
  type = 0,
  x = NULL,
  gamma = NULL
)

Arguments

n

Positive integer. Number of individuals.

time

Positive integer. Number of time points.

mu0

Numeric vector. Mean of initial latent variable values (μη0\boldsymbol{\mu}_{\boldsymbol{\eta} \mid 0}).

sigma0_l

Numeric matrix. Cholesky factorization (t(chol(sigma0))) of the covariance matrix of initial latent variable values (Ση0\boldsymbol{\Sigma}_{\boldsymbol{\eta} \mid 0}).

alpha

Numeric vector. Vector of constant values for the dynamic model (α\boldsymbol{\alpha}).

beta

Numeric matrix. Transition matrix relating the values of the latent variables at the previous to the current time point (β\boldsymbol{\beta}).

psi_l

Numeric matrix. Cholesky factorization (t(chol(psi))) of the covariance matrix of the process noise (Ψ\boldsymbol{\Psi}).

type

Integer. State space model type. See Details for more information.

x

List. Each element of the list is a matrix of covariates for each individual i in n. The number of columns in each matrix should be equal to time.

gamma

Numeric matrix. Matrix linking the covariates to the latent variables at current time point (Γ\boldsymbol{\Gamma}).

Details

Type 0

The measurement model is given by

yi,t=ηi,t \mathbf{y}_{i, t} = \boldsymbol{\eta}_{i, t}

where yi,t\mathbf{y}_{i, t} represents a vector of observed variables and ηi,t\boldsymbol{\eta}_{i, t} a vector of latent variables for individual ii and time tt. Since the observed and latent variables are equal, we only generate data from the dynamic structure.

The dynamic structure is given by

ηi,t=α+βηi,t1+ζi,t,withζi,tN(0,Ψ) \boldsymbol{\eta}_{i, t} = \boldsymbol{\alpha} + \boldsymbol{\beta} \boldsymbol{\eta}_{i, t - 1} + \boldsymbol{\zeta}_{i, t}, \quad \mathrm{with} \quad \boldsymbol{\zeta}_{i, t} \sim \mathcal{N} \left( \mathbf{0}, \boldsymbol{\Psi} \right)

where ηi,t\boldsymbol{\eta}_{i, t}, ηi,t1\boldsymbol{\eta}_{i, t - 1}, and ζi,t\boldsymbol{\zeta}_{i, t} are random variables, and α\boldsymbol{\alpha}, β\boldsymbol{\beta}, and Ψ\boldsymbol{\Psi} are model parameters. Here, ηi,t\boldsymbol{\eta}_{i, t} is a vector of latent variables at time tt and individual ii, ηi,t1\boldsymbol{\eta}_{i, t - 1} represents a vector of latent variables at time t1t - 1 and individual ii, and ζi,t\boldsymbol{\zeta}_{i, t} represents a vector of dynamic noise at time tt and individual ii. α\boldsymbol{\alpha} denotes a vector of intercepts, β\boldsymbol{\beta} a matrix of autoregression and cross regression coefficients, and Ψ\boldsymbol{\Psi} the covariance matrix of ζi,t\boldsymbol{\zeta}_{i, t}.

An alternative representation of the dynamic noise is given by

ζi,t=Ψ12zi,t,withzi,tN(0,I) \boldsymbol{\zeta}_{i, t} = \boldsymbol{\Psi}^{\frac{1}{2}} \mathbf{z}_{i, t}, \quad \mathrm{with} \quad \mathbf{z}_{i, t} \sim \mathcal{N} \left( \mathbf{0}, \mathbf{I} \right)

where (Ψ12)(Ψ12)=Ψ. \left( \boldsymbol{\Psi}^{\frac{1}{2}} \right) \left( \boldsymbol{\Psi}^{\frac{1}{2}} \right)^{\prime} = \boldsymbol{\Psi} .

Type 1

The measurement model is given by

yi,t=ηi,t. \mathbf{y}_{i, t} = \boldsymbol{\eta}_{i, t} .

The dynamic structure is given by

ηi,t=α+βηi,t1+Γxi,t+ζi,t,withζi,tN(0,Ψ) \boldsymbol{\eta}_{i, t} = \boldsymbol{\alpha} + \boldsymbol{\beta} \boldsymbol{\eta}_{i, t - 1} + \boldsymbol{\Gamma} \mathbf{x}_{i, t} + \boldsymbol{\zeta}_{i, t}, \quad \mathrm{with} \quad \boldsymbol{\zeta}_{i, t} \sim \mathcal{N} \left( \mathbf{0}, \boldsymbol{\Psi} \right)

where xi,t\mathbf{x}_{i, t} represents a vector of covariates at time tt and individual ii, and Γ\boldsymbol{\Gamma} the coefficient matrix linking the covariates to the latent variables.

Value

Returns an object of class simstatespace which is a list with the following elements:

Author(s)

Ivan Jacob Agaloos Pesigan

References

Chow, S.-M., Ho, M. R., Hamaker, E. L., & Dolan, C. V. (2010). Equivalence and differences between structural equation modeling and state-space modeling techniques. Structural Equation Modeling: A Multidisciplinary Journal, 17(2), 303–332. doi:10.1080/10705511003661553

See Also

Other Simulation of State Space Models Data Functions: LinSDE2SSM(), SimBetaN(), SimPhiN(), SimSSMFixed(), SimSSMIVary(), SimSSMLinGrowth(), SimSSMLinGrowthIVary(), SimSSMLinSDEFixed(), SimSSMLinSDEIVary(), SimSSMOUFixed(), SimSSMOUIVary(), SimSSMVARIVary(), TestPhi(), TestStability(), TestStationarity()

Examples

# prepare parameters
set.seed(42)
## number of individuals
n <- 5
## time points
time <- 50
## dynamic structure
p <- 3
mu0 <- rep(x = 0, times = p)
sigma0 <- 0.001 * diag(p)
sigma0_l <- t(chol(sigma0))
alpha <- rep(x = 0, times = p)
beta <- 0.50 * diag(p)
psi <- 0.001 * diag(p)
psi_l <- t(chol(psi))
## covariates
j <- 2
x <- lapply(
  X = seq_len(n),
  FUN = function(i) {
    matrix(
      data = stats::rnorm(n = time * j),
      nrow = j,
      ncol = time
    )
  }
)
gamma <- diag(x = 0.10, nrow = p, ncol = j)

# Type 0
ssm <- SimSSMVARFixed(
  n = n,
  time = time,
  mu0 = mu0,
  sigma0_l = sigma0_l,
  alpha = alpha,
  beta = beta,
  psi_l = psi_l,
  type = 0
)

plot(ssm)

# Type 1
ssm <- SimSSMVARFixed(
  n = n,
  time = time,
  mu0 = mu0,
  sigma0_l = sigma0_l,
  alpha = alpha,
  beta = beta,
  psi_l = psi_l,
  type = 1,
  x = x,
  gamma = gamma
)

plot(ssm)


[Package simStateSpace version 1.2.2 Index]