SimSSMLinGrowth {simStateSpace} | R Documentation |
Simulate Data from the Linear Growth Curve Model
Description
This function simulates data from the linear growth curve model.
Usage
SimSSMLinGrowth(
n,
time,
mu0,
sigma0_l,
theta_l,
type = 0,
x = NULL,
gamma = NULL,
kappa = NULL
)
Arguments
n |
Positive integer. Number of individuals. |
time |
Positive integer. Number of time points. |
mu0 |
Numeric vector. A vector of length two. The first element is the mean of the intercept, and the second element is the mean of the slope. |
sigma0_l |
Numeric matrix.
Cholesky factorization ( |
theta_l |
Numeric. Square root of the common measurement error variance. |
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
is a model parameter.
is the observed random variable
at time
and individual
,
(intercept)
and
(slope)
form a vector of latent random variables
at time
and individual
,
and
a vector of random measurement errors
at time
and individual
.
is the variance of
.
The dynamic structure is given by
The mean vector and covariance matrix of the intercept and slope are captured in the mean vector and covariance matrix of the initial condition given by
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()
,
SimSSMFixed()
,
SimSSMIVary()
,
SimSSMLinGrowthIVary()
,
SimSSMLinSDEFixed()
,
SimSSMLinSDEIVary()
,
SimSSMOUFixed()
,
SimSSMOUIVary()
,
SimSSMVARFixed()
,
SimSSMVARIVary()
,
TestPhi()
,
TestStability()
,
TestStationarity()
Examples
# prepare parameters
set.seed(42)
## number of individuals
n <- 5
## time points
time <- 5
## dynamic structure
p <- 2
mu0 <- c(0.615, 1.006)
sigma0 <- matrix(
data = c(
1.932,
0.618,
0.618,
0.587
),
nrow = p
)
sigma0_l <- t(chol(sigma0))
## measurement model
k <- 1
theta <- 0.50
theta_l <- sqrt(theta)
## covariates
j <- 2
x <- lapply(
X = seq_len(n),
FUN = function(i) {
return(
matrix(
data = rnorm(n = j * time),
nrow = j
)
)
}
)
gamma <- diag(x = 0.10, nrow = p, ncol = j)
kappa <- diag(x = 0.10, nrow = k, ncol = j)
# Type 0
ssm <- SimSSMLinGrowth(
n = n,
time = time,
mu0 = mu0,
sigma0_l = sigma0_l,
theta_l = theta_l,
type = 0
)
plot(ssm)
# Type 1
ssm <- SimSSMLinGrowth(
n = n,
time = time,
mu0 = mu0,
sigma0_l = sigma0_l,
theta_l = theta_l,
type = 1,
x = x,
gamma = gamma
)
plot(ssm)
# Type 2
ssm <- SimSSMLinGrowth(
n = n,
time = time,
mu0 = mu0,
sigma0_l = sigma0_l,
theta_l = theta_l,
type = 2,
x = x,
gamma = gamma,
kappa = kappa
)
plot(ssm)