SimSSMFixed {simStateSpace} | R Documentation |
Simulate Data from a State Space Model (Fixed Parameters)
Description
This function simulates data using a state space model. It assumes that the parameters remain constant across individuals and over time.
Usage
SimSSMFixed(
n,
time,
delta_t = 1,
mu0,
sigma0_l,
alpha,
beta,
psi_l,
nu,
lambda,
theta_l,
type = 0,
x = NULL,
gamma = NULL,
kappa = NULL
)
Arguments
n |
Positive integer. Number of individuals. |
time |
Positive integer. Number of time points. |
delta_t |
Numeric.
Time interval.
The default value is |
mu0 |
Numeric vector.
Mean of initial latent variable values
( |
sigma0_l |
Numeric matrix.
Cholesky factorization ( |
alpha |
Numeric vector.
Vector of constant values for the dynamic model
( |
beta |
Numeric matrix.
Transition matrix relating the values of the latent variables
at the previous to the current time point
( |
psi_l |
Numeric matrix.
Cholesky factorization ( |
nu |
Numeric vector.
Vector of intercept values for the measurement model
( |
lambda |
Numeric matrix.
Factor loading matrix linking the latent variables
to the observed variables
( |
theta_l |
Numeric matrix.
Cholesky factorization ( |
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 |
gamma |
Numeric matrix.
Matrix linking the covariates to the latent variables
at current time point
( |
kappa |
Numeric matrix.
Matrix linking the covariates to the observed variables
at current time point
( |
Details
Type 0
The measurement model is given by
where
,
,
and
are random variables
and
,
,
and
are model parameters.
represents a vector of observed random variables,
a vector of latent random variables,
and
a vector of random measurement errors,
at time
and individual
.
denotes a vector of intercepts,
a matrix of factor loadings,
and
the covariance matrix of
.
An alternative representation of the measurement error is given by
where
is a vector of
independent standard normal random variables and
The dynamic structure is given by
where
,
,
and
are random variables,
and
,
,
and
are model parameters.
Here,
is a vector of latent variables
at time
and individual
,
represents a vector of latent variables
at time
and individual
,
and
represents a vector of dynamic noise
at time
and individual
.
denotes a vector of intercepts,
a matrix of autoregression
and cross regression coefficients,
and
the covariance matrix of
.
An alternative representation of the dynamic noise is given by
where
Type 1
The measurement model is given by
The dynamic structure is given by
where
represents a vector of covariates
at time
and individual
,
and
the coefficient matrix
linking the covariates to the latent variables.
Type 2
The measurement model is given by
where
represents the coefficient matrix
linking the covariates to the observed variables.
The dynamic structure is given by
Value
Returns an object of class simstatespace
which is a list with the following elements:
-
call
: Function call. -
args
: Function arguments. -
data
: Generated data which is a list of lengthn
. Each element ofdata
is a list with the following elements:-
id
: A vector of ID numbers with lengthl
, wherel
is the value of the function argumenttime
. -
time
: A vector time points of lengthl
. -
y
: Al
byk
matrix of values for the manifest variables. -
eta
: Al
byp
matrix of values for the latent variables. -
x
: Al
byj
matrix of values for the covariates (when covariates are included).
-
-
fun
: Function used.
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()
,
SimSSMIVary()
,
SimSSMLinGrowth()
,
SimSSMLinGrowthIVary()
,
SimSSMLinSDEFixed()
,
SimSSMLinSDEIVary()
,
SimSSMOUFixed()
,
SimSSMOUIVary()
,
SimSSMVARFixed()
,
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))
## measurement model
k <- 3
nu <- rep(x = 0, times = k)
lambda <- diag(k)
theta <- 0.001 * diag(k)
theta_l <- t(chol(theta))
## 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)
kappa <- diag(x = 0.10, nrow = k, ncol = j)
# Type 0
ssm <- SimSSMFixed(
n = n,
time = time,
mu0 = mu0,
sigma0_l = sigma0_l,
alpha = alpha,
beta = beta,
psi_l = psi_l,
nu = nu,
lambda = lambda,
theta_l = theta_l,
type = 0
)
plot(ssm)
# Type 1
ssm <- SimSSMFixed(
n = n,
time = time,
mu0 = mu0,
sigma0_l = sigma0_l,
alpha = alpha,
beta = beta,
psi_l = psi_l,
nu = nu,
lambda = lambda,
theta_l = theta_l,
type = 1,
x = x,
gamma = gamma
)
plot(ssm)
# Type 2
ssm <- SimSSMFixed(
n = n,
time = time,
mu0 = mu0,
sigma0_l = sigma0_l,
alpha = alpha,
beta = beta,
psi_l = psi_l,
nu = nu,
lambda = lambda,
theta_l = theta_l,
type = 2,
x = x,
gamma = gamma,
kappa = kappa
)
plot(ssm)