Fit the First-Order Discrete-Time Vector Autoregressive Model
Source:R/fitDTVARMx-fit-dt-var-mx.R
FitDTVARMx.Rd
The function uses a multigroup model to fit the first-order discrete-time vector autoregressive model.
Usage
FitDTVARMx(
data,
observed,
id,
alpha_fixed = FALSE,
alpha_values = NULL,
alpha_free = NULL,
alpha_lbound = NULL,
alpha_ubound = NULL,
beta_values = NULL,
beta_free = NULL,
beta_lbound = NULL,
beta_ubound = NULL,
psi_diag = FALSE,
psi_values = NULL,
psi_free = NULL,
psi_lbound = NULL,
psi_ubound = NULL,
theta_fixed = FALSE,
theta_values = NULL,
theta_free = NULL,
theta_lbound = NULL,
theta_ubound = NULL,
mu0_fixed = FALSE,
mu0_values = NULL,
mu0_free = NULL,
mu0_lbound = NULL,
mu0_ubound = NULL,
sigma0_fixed = FALSE,
sigma0_diag = FALSE,
sigma0_values = NULL,
sigma0_free = NULL,
sigma0_lbound = NULL,
sigma0_ubound = NULL,
try = 1000,
ncores = NULL,
...
)
Arguments
- data
Data frame. A data frame object of data for potentially multiple subjects that contain a column of subject ID numbers (i.e., an ID variable), and at least one column of observed values.
- observed
Character vector. A vector of character strings of the names of the observed variables in the data.
- id
Character string. A character string of the name of the ID variable in the data.
- alpha_fixed
Logical. If
alpha_fixed = TRUE
, the dynamic model intercept vectoralpha
is fixed. Ifalpha_fixed = FALSE
, the dynamic model intercept vectoralpha
is estimated.- alpha_values
Optional starting values for
alpha
. Ifalpha_fixed = TRUE
,alpha_values
will be used as fixed values. Ifalpha_fixed = FALSE
,alpha_values
will be used as starting values. Ifalpha_values = NULL
, a vector of zeroes is used.- alpha_free
Optional logical vector representing free parameters for
alpha
.- alpha_lbound
Optional lower bound for
alpha
. Ignored ifalpha_fixed = TRUE
.- alpha_ubound
Optional upper bound for
alpha
. Ignored ifalpha_fixed = TRUE
.- beta_values
Numeric matrix. Optional starting values for
beta
.- beta_free
Optional logical matrix representing free parameters for
beta
.- beta_lbound
Numeric matrix. Optional lower bound for
beta
.- beta_ubound
Numeric matrix. Optional upper bound for
beta
.- psi_diag
Logical. If
psi_diag = TRUE
,psi
is a diagonal matrix.- psi_values
Numeric matrix. Optional starting values for
psi
.- psi_free
Optional logical matrix representing free parameters for
psi
.- psi_lbound
Numeric matrix. Optional lower bound for
psi
.- psi_ubound
Optional upper bound for
psi
.- theta_fixed
Logical. If
theta_fixed = TRUE
, the measurement error matrixtheta
is fixed to zero. Iftheta_fixed = FALSE
, estimate the diagonal measurement error matrixtheta
.- theta_values
Optional starting values for
theta
. Ignored iftheta_fixed = TRUE
.- theta_free
Optional logical matrix representing free parameters for
theta
.- theta_lbound
Optional lower bound for
theta
. Ignored iftheta_fixed = TRUE
.- theta_ubound
Optional upper bound for
theta
. Ignored iftheta_fixed = TRUE
.- mu0_fixed
Logical. If
mu0_fixed = TRUE
, initial mean vectormu0
is fixed. Ifmu0_fixed = FALSE
, initial mean vectormu0
is estimated.- mu0_values
Optional starting values for
mu0
. Ifmu0_fixed = TRUE
,mu0_values
will be used as fixed values. Ifmu0_fixed = FALSE
,mu0_values
will be used as starting values. Ifmu0_values = NULL
, a vector of zeroes is used.- mu0_free
Optional logical vector representing free parameters for
mu0
.- mu0_lbound
Optional lower bound for
mu0
. Ignored ifmu0_fixed = TRUE
.- mu0_ubound
Optional upper bound for
mu0
. Ignored ifmu0_fixed = TRUE
.- sigma0_fixed
Logical. If
sigma0_fixed = TRUE
, initial mean vectorsigma0
is fixed. Ifsigma0_fixed = FALSE
, initial mean vectorsigma0
is estimated.- sigma0_diag
Logical. If
sigma0_diag = TRUE
,sigma0
is a diagonal matrix.- sigma0_values
Optional starting values for
sigma0
. Ifsigma0_fixed = TRUE
,sigma0_values
will be used as fixed values. Ifsigma0_fixed = FALSE
,sigma0_values
will be used as starting values. Ifsigma0_values = NULL
, an identity matrix is used.- sigma0_free
Optional logical matrix representing free parameters for
sigma0
.- sigma0_lbound
Optional lower bound for
sigma0
. Ignored ifsigma0_fixed = TRUE
.- sigma0_ubound
Optional upper bound for
sigma0
. Ignored ifsigma0_fixed = TRUE
.- try
Positive integer. Number of extra optimization tries.
- ncores
Positive integer. Number of cores to use.
- ...
Additional optional arguments to pass to
mxTryHardctsem
.
Value
Returns an object of class dtvarmx
which is
a list with the following elements:
- call
Function call.
- args
List of function arguments.
- fun
Function used ("FitDTVARMx").
- output
A fitted OpenMx model.
Details
The measurement model is given by $$ \mathbf{y}_{i, t} = \boldsymbol{\Lambda} \boldsymbol{\eta}_{i, t} + \boldsymbol{\varepsilon}_{i, t}, \quad \mathrm{with} \quad \boldsymbol{\varepsilon}_{i, t} \sim \mathcal{N} \left( \mathbf{0}, \boldsymbol{\Theta} \right) $$ where \(\mathbf{y}_{i, t}\), \(\boldsymbol{\eta}_{i, t}\), and \(\boldsymbol{\varepsilon}_{i, t}\) are random variables and \(\boldsymbol{\Lambda}\), and \(\boldsymbol{\Theta}\) are model parameters. \(\mathbf{y}_{i, t}\) represents a vector of observed random variables, \(\boldsymbol{\eta}_{i, t}\) a vector of latent random variables, and \(\boldsymbol{\varepsilon}_{i, t}\) a vector of random measurement errors, at time \(t\) and individual \(i\). \(\boldsymbol{\Lambda}\) denotes a matrix of factor loadings, and \(\boldsymbol{\Theta}\) the covariance matrix of \(\boldsymbol{\varepsilon}\). In this model, \(\boldsymbol{\Lambda}\) is an identity matrix and \(\boldsymbol{\Theta}\) is a diagonal matrix.
The dynamic structure is given by $$ \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 \(\boldsymbol{\eta}_{i, t}\), \(\boldsymbol{\eta}_{i, t - 1}\), and \(\boldsymbol{\zeta}_{i, t}\) are random variables, and \(\boldsymbol{\alpha}\), \(\boldsymbol{\beta}\), and \(\boldsymbol{\Psi}\) are model parameters. Here, \(\boldsymbol{\eta}_{i, t}\) is a vector of latent variables at time \(t\) and individual \(i\), \(\boldsymbol{\eta}_{i, t - 1}\) represents a vector of latent variables at time \(t - 1\) and individual \(i\), and \(\boldsymbol{\zeta}_{i, t}\) represents a vector of dynamic noise at time \(t\) and individual \(i\). \(\boldsymbol{\alpha}\) denotes a vector of intercepts, \(\boldsymbol{\beta}\) a matrix of autoregression and cross regression coefficients, and \(\boldsymbol{\Psi}\) the covariance matrix of \(\boldsymbol{\zeta}_{i, t}\).
References
Hunter, M. D. (2017). State space modeling in an open source, modular, structural equation modeling environment. Structural Equation Modeling: A Multidisciplinary Journal, 25(2), 307–324. doi:10.1080/10705511.2017.1369354
Neale, M. C., Hunter, M. D., Pritikin, J. N., Zahery, M., Brick, T. R., Kirkpatrick, R. M., Estabrook, R., Bates, T. C., Maes, H. H., & Boker, S. M. (2015). OpenMx 2.0: Extended structural equation and statistical modeling. Psychometrika, 81(2), 535–549. doi:10.1007/s11336-014-9435-8
See also
Other DTVAR Functions:
FitDTVARIDMx()
Examples
if (FALSE) { # \dontrun{
# Generate data using the simStateSpace package------------------------------
set.seed(42)
sim <- simStateSpace::SimSSMVARFixed(
n = 5,
time = 100,
mu0 = rep(x = 0, times = 3),
sigma0_l = t(chol(diag(3))),
alpha = rep(x = 0, times = 3),
beta = matrix(
data = c(
0.7, 0.5, -0.1,
0.0, 0.6, 0.4,
0, 0, 0.5
),
nrow = 3
),
psi_l = t(chol(diag(3)))
)
data <- as.data.frame(sim)
# Fit the model--------------------------------------------------------------
library(fitDTVARMx)
fit <- FitDTVARMx(
data = data,
observed = c("y1", "y2", "y3"),
id = "id"
)
print(fit)
summary(fit)
coef(fit)
vcov(fit)
} # }