Skip to contents

Dynamics Description

The Stable Persistence with Baseline-Moderated Autoregression process represents a bivariate dynamic system in which two latent psychological constructs (e.g., positive and negative affect) exhibit within-construct persistence over time through autoregressive dynamics. The transition matrix is diagonal, implying that each construct evolves according to its own self-regulatory process and there are no cross-lagged (reciprocal) influences between the constructs in the systematic dynamics.

Between-person heterogeneity in persistence is captured via a time-invariant baseline covariate xi∈{0,1}x_i \in \left\{ 0, 1 \right\} with one value per individual. The individual-specific transition matrix is modeled as vec(𝛃i)=vec(𝛃(xi))=vec(𝛃0)+vec(𝛃1)xi,\begin{equation} \mathrm{vec} \left( \boldsymbol{\beta}_i \right) = \mathrm{vec} \left( \boldsymbol{\beta} \left( x_i \right) \right) = \mathrm{vec} \left( \boldsymbol{\beta}_0 \right) + \mathrm{vec} \left( \boldsymbol{\beta}_1 \right) x_i, \end{equation} so that individuals with xi=0x_i = 0 follows 𝛃0\boldsymbol{\beta}_0, whereas individuals with xi=1x_i = 1 follow 𝛃0+𝛃1\boldsymbol{\beta}_0 + \boldsymbol{\beta}_1. Under the current specification, 𝛃1\boldsymbol{\beta}_1 increases the diagonal autoregressive parameters, implying that the xi=1x_i = 1 group exhibits greater persistenceβ€”deviations from an individual’s equilibrium decay more slowlyβ€”while remaining dynamically stable.

Between-person heterogeneity in baseline levels is also captured via the same time-invariant covariate xi∈{0,1}x_i \in \left\{ 0, 1 \right\} through the person-specific set-point vector 𝛍i=𝛍(xi)=𝛍0+𝛍1xi,\begin{equation} \boldsymbol{\mu}_i = \boldsymbol{\mu} \left( x_i \right) = \boldsymbol{\mu}_{0} + \boldsymbol{\mu}_{1} x_i, \end{equation} so that individuals with xi=0x_i = 0 follow 𝛍0\boldsymbol{\mu}_{0}, whereas individuals with xi=1x_i = 1 follow 𝛍0+𝛍1\boldsymbol{\mu}_{0} + \boldsymbol{\mu}_{1}.

In addition to explaining between-person differences in the DT-VAR parameters via the baseline covariate xix_i, we also include a distal outcome ziz_i measured once per individual. Conceptually, ziz_i can be interpreted as a later outcome (e.g., symptom severity, functioning, or substance use) whose between-person differences are partly explained by (a) each person’s estimated set-point and dynamic parameters and (b) xix_i.

The process noise covariance allows for small disturbances that may be correlated across constructs, permitting coordinated innovations even though the lagged dynamics are decoupled. Measurement errors are assumed to be minimal and symmetric across indicators.

Model

The measurement model is given by 𝐲i,t=πš²π›ˆi,t+𝛆i,t,with𝛆i,tβˆΌπ’©(𝟎,𝚯)\begin{equation} \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) \end{equation} where 𝐲i,t\mathbf{y}_{i, t}, π›ˆi,t\boldsymbol{\eta}_{i, t}, and 𝛆i,t\boldsymbol{\varepsilon}_{i, t} are random variables and 𝚲\boldsymbol{\Lambda}, and 𝚯\boldsymbol{\Theta} are model parameters. 𝐲i,t\mathbf{y}_{i, t} represents a vector of observed random variables, π›ˆi,t\boldsymbol{\eta}_{i, t} a vector of latent random variables, and 𝛆i,t\boldsymbol{\varepsilon}_{i, t} a vector of random measurement errors, at time tt and individual ii. 𝚲\boldsymbol{\Lambda} denotes a matrix of factor loadings, and 𝚯\boldsymbol{\Theta} the covariance matrix of 𝛆\boldsymbol{\varepsilon} that is invariant across individuals. In this model, 𝚲\boldsymbol{\Lambda} is an identity matrix and 𝚯\boldsymbol{\Theta} is a symmetric matrix.

The dynamic structure is given by π›ˆi,t=𝛂i+𝛃iπ›ˆi,tβˆ’1+𝛇i,t,with𝛇i,tβˆΌπ’©(𝟎,𝚿)\begin{equation} \boldsymbol{\eta}_{i, t} = \boldsymbol{\alpha}_{i} + \boldsymbol{\beta}_{i} \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) \end{equation} where π›ˆi,t\boldsymbol{\eta}_{i, t}, π›ˆi,tβˆ’1\boldsymbol{\eta}_{i, t - 1}, and 𝛇i,t\boldsymbol{\zeta}_{i, t} are random variables, and 𝛃i\boldsymbol{\beta}_{i}, 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,tβˆ’1\boldsymbol{\eta}_{i, t - 1} represents a vector of latent variables at time tβˆ’1t - 1 and individual ii, and 𝛇i,t\boldsymbol{\zeta}_{i, t} represents a vector of dynamic noise at time tt and individual ii. 𝛃i\boldsymbol{\beta}_{i} is a matrix of autoregression and cross regression coefficients for individual ii, and 𝚿\boldsymbol{\Psi} the covariance matrix of 𝛇i,t\boldsymbol{\zeta}_{i, t} that is invariant across all individuals. In this model, 𝚿\boldsymbol{\Psi} is a symmetric matrix.

Alternative Parameterization

An alternative parameterization of the dynamic structure that directly estimates the set-point vector 𝛍i\boldsymbol{\mu}_{i} is given by π›ˆi,t=𝛍i+𝛃i(π›ˆi,tβˆ’1βˆ’π›i)+𝛇i,t.\begin{equation} \boldsymbol{\eta}_{i, t} = \boldsymbol{\mu}_{i} + \boldsymbol{\beta}_{i} \left( \boldsymbol{\eta}_{i, t - 1} - \boldsymbol{\mu}_{i} \right) + \boldsymbol{\zeta}_{i, t} . \end{equation}

Algebraic manipulation of the equation results in the following π›ˆi,t=𝛍iβˆ’π›ƒi𝛍i+𝛃iπ›ˆi,tβˆ’1+𝛇i,t,\begin{equation} \boldsymbol{\eta}_{i, t} = \boldsymbol{\mu}_{i} - \boldsymbol{\beta}_{i} \boldsymbol{\mu}_{i} + \boldsymbol{\beta}_{i} \boldsymbol{\eta}_{i, t - 1} + \boldsymbol{\zeta}_{i, t} , \end{equation} where we can see that the intercept vector 𝛂i\boldsymbol{\alpha}_{i} is implied by 𝛍iβˆ’π›ƒi𝛍i\boldsymbol{\mu}_{i} - \boldsymbol{\beta}_{i} \boldsymbol{\mu}_{i}.

Distal outcome model

Let ziz_i denote a distal outcome observed once per individual ii. We model ziz_i as a linear function of (a) the person-specific DT-VAR parameters and (b) the baseline covariate xix_i: zi=ΞΊ+π›Ÿβ€²π°i+Ο‰xi+ΞΎi,withΞΎiβˆΌπ’©(0,ψ),\begin{equation} z_i = \kappa + \boldsymbol{\phi}^{\prime} \mathbf{w}_i + \omega x_i + \xi_i, \quad \mathrm{with} \quad \xi_i \sim \mathcal{N}(0, \psi), \end{equation} where ΞΊ\kappa is an intercept, π›Ÿ\boldsymbol{\phi} is a vector of regression coefficients, Ο‰\omega is the direct effect of xix_i on ziz_i, and ψ\psi is the residual variance of the distal outcome. The predictor vector 𝐰i\mathbf{w}_i stacks the person-specific DT-VAR coefficients and intercepts used for prediction. In this vignette we use 𝐰i=[vec(𝛃i)β€²,π›Žiβ€²]β€²,\begin{equation} \mathbf{w}_i = \left[ \mathrm{vec}(\boldsymbol{\beta}_i)^{\prime}, \; \boldsymbol{\nu}_i^{\prime} \right]^{\prime}, \end{equation} so 𝐰i\mathbf{w}_i has length p2+pp^2 + p (here 4+2=64 + 2 = 6).

Data Generation

Notation

Let t=1000t = 1000 be the number of time points and n=1000n = 1000 be the number of individuals. We simulate a total of time =11000= 11000 points per individual, discarding the first 1000010000 as burn-in. The analysis uses the final 10001000 measurement occasions.

Let the factor loadings matrix 𝚲\boldsymbol{\Lambda} be given by 𝚲=(1001).\begin{equation} \boldsymbol{\Lambda} = \left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \\ \end{array} \right) . \end{equation}

Let the measurement error covariance matrix 𝚯\boldsymbol{\Theta} be given by 𝚯=(0.5000.5).\begin{equation} \boldsymbol{\Theta} = \left( \begin{array}{cc} 0.5 & 0 \\ 0 & 0.5 \\ \end{array} \right) . \end{equation}

Let the initial condition π›ˆ0\boldsymbol{\eta}_{0} be given by π›ˆ0βˆΌπ’©(π›π›ˆβˆ£0,πšΊπ›ˆβˆ£0).\begin{equation} \boldsymbol{\eta}_{0} \sim \mathcal{N} \left( \boldsymbol{\mu}_{\boldsymbol{\eta} \mid 0}, \boldsymbol{\Sigma}_{\boldsymbol{\eta} \mid 0} \right) . \end{equation}π›π›ˆβˆ£0\boldsymbol{\mu}_{\boldsymbol{\eta} \mid 0} and πšΊπ›ˆβˆ£0\boldsymbol{\Sigma}_{\boldsymbol{\eta} \mid 0} are functions of 𝛂\boldsymbol{\alpha} and 𝛃\boldsymbol{\beta}.

Let the intercept vector 𝛂\boldsymbol{\alpha} when X=0X = 0 be (0.5βˆ’0.5).\begin{equation} \left( \begin{array}{c} 0.5 \\ -0.5 \\ \end{array} \right) . \end{equation} Let the intercept vector 𝛂\boldsymbol{\alpha} when X=1X = 1 be (0.75βˆ’0.75).\begin{equation} \left( \begin{array}{c} 0.75 \\ -0.75 \\ \end{array} \right) . \end{equation} Let the covariance matrix be (0.1βˆ’0.05βˆ’0.050.1).\begin{equation} \left( \begin{array}{cc} 0.1 & -0.05 \\ -0.05 & 0.1 \\ \end{array} \right) . \end{equation}

Let the transition matrix 𝛃\boldsymbol{\beta} when X=0X = 0 be (0.5000.5).\begin{equation} \left( \begin{array}{cc} 0.5 & 0 \\ 0 & 0.5 \\ \end{array} \right) . \end{equation} Let the transition matrix 𝛃\boldsymbol{\beta} when X=1X = 1 be (0.75000.75).\begin{equation} \left( \begin{array}{cc} 0.75 & 0 \\ 0 & 0.75 \\ \end{array} \right) . \end{equation} Let the covariance matrix be and covariance matrix (0.020.01000.010.01500000.010.005000.0050.015).\begin{equation} \left( \begin{array}{cccc} 0.02 & 0.01 & 0 & 0 \\ 0.01 & 0.015 & 0 & 0 \\ 0 & 0 & 0.01 & 0.005 \\ 0 & 0 & 0.005 & 0.015 \\ \end{array} \right) . \end{equation}

The SimAlphaN and SimBetaNCovariate functions from the simStateSpace package generate random intercept vectors and transition matrices from the multivariate normal distribution. Note that the SimBetaNCovariate function generates transition matrices that are weakly stationary with an option to set lower and upper bounds. The person-specific set-point vector 𝛍i\boldsymbol{\mu}_{i} was derived from the generated 𝛂i\boldsymbol{\alpha}_{i} and 𝛃i\boldsymbol{\beta}_{i}.

Let the dynamic process noise 𝚿\boldsymbol{\Psi} be given by 𝚿=(0.2βˆ’0.05βˆ’0.050.18).\begin{equation} \boldsymbol{\Psi} = \left( \begin{array}{cc} 0.2 & -0.05 \\ -0.05 & 0.18 \\ \end{array} \right) . \end{equation}

R Function Arguments

n
#> [1] 1000
time
#> [1] 11000
burnin
#> [1] 10000
# first mu0 in the list of length n
mu0[[1]]
#> [1]  0.7520376 -0.5127468
# first sigma0 in the list of length n
sigma0[[1]]
#>            [,1]       [,2]
#> [1,]  0.2787159 -0.1023574
#> [2,] -0.1023574  0.2538853
# first sigma0_l in the list of length n
sigma0_l[[1]] # sigma0_l <- t(chol(sigma0))
#>            [,1]      [,2]
#> [1,]  0.5279355 0.0000000
#> [2,] -0.1938823 0.4650752
# first alpha in the list of length n
alpha[[1]]
#> [1]  0.3319244 -0.1910529
# first beta in the list of length n
beta[[1]]
#>             [,1]       [,2]
#> [1,]  0.47646139 -0.1205201
#> [2,] -0.08920883  0.4965522
# first psi in the list of length n
psi[[1]]
#>       [,1]  [,2]
#> [1,]  0.20 -0.05
#> [2,] -0.05  0.18
psi_l[[1]] # psi_l <- t(chol(psi))
#>            [,1]      [,2]
#> [1,]  0.4472136 0.0000000
#> [2,] -0.1118034 0.4092676
nu
#> [[1]]
#> [1] 0 0
lambda
#> [[1]]
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
theta
#> [[1]]
#>      [,1] [,2]
#> [1,]  0.5  0.0
#> [2,]  0.0  0.5
theta_l # theta_l <- t(chol(theta))
#> [[1]]
#>           [,1]      [,2]
#> [1,] 0.7071068 0.0000000
#> [2,] 0.0000000 0.7071068
# first mu_eta (set-point) in the list of length n
mu_eta[[1]]
#> [1]  0.7520376 -0.5127468
# distal outcome parameters
kappa_z
#> [1] 10
phi_z
#>      [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,]    5    5    5    5    5    5
omega_z
#> [1] 0.15
psi_z
#> [1] 0.45

Visualizing the Dynamics Without Process Noise and Measurement Error (n = 5 with Different Initial Condition)

X=0X = 0

X=1X = 1

Using the SimSSMIVary Function from the simStateSpace Package to Simulate Data

library(simStateSpace)
sim <- SimSSMIVary(
  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
)
data <- as.data.frame(sim, burnin = burnin)
head(data)
#>   id time         y1         y2
#> 1  1    0 -0.2039857 -0.5271213
#> 2  1    1  2.3635709 -0.8225477
#> 3  1    2  1.0336287 -1.3055546
#> 4  1    3  0.3748494 -0.1758500
#> 5  1    4 -0.6424827 -1.8117723
#> 6  1    5  1.0244405 -0.1976583
plot(sim, burnin = burnin)

Model Fitting

The FitDTVARMxID function fits a DT-VAR model on each individual ii. To set up the estimation, we first provide starting values for each parameter matrix.

Set-Point (mu_eta)

The set-point vector 𝛍\boldsymbol{\mu} is initialized with starting values.

mu_eta_values <- mu_eta

Autoregressive Parameters (beta)

We initialize the autoregressive coefficient matrix 𝛃\boldsymbol{\beta} with the true values used in simulation.

beta_values <- beta

LDL’-parameterized covariance matrices

Covariances such as psi and theta are estimated using the LDL’ decomposition of a positive definite covariance matrix. The decomposition expresses a covariance matrix Ξ£\Sigma as
𝚺=(𝐋+𝐈)diag(Softplus(𝐝uc))(𝐋+𝐈)β€²,\begin{equation} \boldsymbol{\Sigma} = \left( \mathbf{L} + \mathbf{I} \right) \mathrm{diag} \left( \mathrm{Softplus} \left( \mathbf{d}_{uc} \right) \right) \left( \mathbf{L} + \mathbf{I} \right)^{\prime}, \end{equation} where: - 𝐋\mathbf{L} is a strictly lower-triangular matrix of free parameters (l_mat_strict),
- 𝐈\mathbf{I} is the identity matrix,
- 𝐝uc\mathbf{d}_{uc} is an unconstrained vector,
- Softplus(𝐝uc)=log⁑(1+exp(𝐝uc))\mathrm{Softplus} \left(\mathbf{d}_{uc} \right) = \log \left(1 + \exp \left( \mathbf{d}_{uc} \right) \right) ensures strictly positive diagonal entries.

The LDL() function extracts this decomposition from a positive definite covariance matrix. It returns:
- d_uc: unconstrained diagonal parameters, equal to InvSoftplus(d_vec),
- d_vec: diagonal entries, equal to Softplus(d_uc),
- l_mat_strict: the strictly lower-triangular factor.

sigma <- matrix(
  data = c(1.0, 0.5, 0.5, 1.0),
  nrow = 2,
  ncol = 2
)
ldl_sigma <- LDL(sigma)
d_uc <- ldl_sigma$d_uc
l_mat_strict <- ldl_sigma$l_mat_strict
I <- diag(2)
sigma_reconstructed <- (l_mat_strict + I) %*% diag(log1p(exp(d_uc)), 2) %*% t(l_mat_strict + I)
sigma_reconstructed
#>      [,1] [,2]
#> [1,]  1.0  0.5
#> [2,]  0.5  1.0

Process Noise Covariance Matrix (psi)

Starting values for the process noise covariance matrix 𝚿\boldsymbol{\Psi} are given below, with corresponding LDL’ parameters.

psi_values <- psi[[1]]
ldl_psi_values <- LDL(psi_values)
psi_d_values <- ldl_psi_values$d_uc
psi_l_values <- ldl_psi_values$l_mat_strict
psi_d_values
#> [1] -1.507772 -1.701853
psi_l_values
#>       [,1] [,2]
#> [1,]  0.00    0
#> [2,] -0.25    0

Measurement Error Covariance Matrix (theta)

Starting values for the measurement error covariance matrix 𝚯\boldsymbol{\Theta} are given below, with corresponding LDL’ parameters.

theta_values <- theta[[1]]
ldl_theta_values <- LDL(theta_values)
theta_d_values <- ldl_theta_values$d_uc
theta_l_values <- ldl_theta_values$l_mat_strict
theta_d_values
#> [1] -0.4327521 -0.4327521
theta_l_values
#>      [,1] [,2]
#> [1,]    0    0
#> [2,]    0    0

Initial mean vector (mu_0) and covariance matrix (sigma_0)

The initial mean vector π›πŸŽ\boldsymbol{\mu_0} and covariance matrix 𝚺𝟎\boldsymbol{\Sigma_0} are fixed using mu0 and sigma0.

mu0_values <- mu0
sigma0_values <- lapply(
  X = sigma0,
  FUN = LDL
)
sigma0_d_values <- lapply(
  X = sigma0_values,
  FUN = function(i) {
    i$d_uc
  }
)
sigma0_l_values <- lapply(
  X = sigma0_values,
  FUN = function(i) {
    i$l_mat_strict
  }
)

FitDTVARMxID

fit <- FitDTVARMxID(
  data = data,
  observed = c("y1", "y2"),
  id = "id",
  center = TRUE,
  mu_eta_values = mu_eta_values,
  beta_values = beta_values,
  psi_d_values = psi_d_values,
  psi_l_values = psi_l_values,
  theta_d_values = theta_d_values,
  mu0_values = mu0_values,
  sigma0_d_values = sigma0_d_values,
  sigma0_l_values = sigma0_l_values,
  ncores = parallel::detectCores()
)

Parameter estimates

head(summary(fit))
#>                             beta_1_1    beta_2_1     beta_1_2  beta_2_2
#> FitDTVARMxID_DTVAR_ID1.Rds 0.7356647 -0.03709508  0.124911294 0.6075660
#> FitDTVARMxID_DTVAR_ID2.Rds 0.3932550  0.33128856  0.070209848 0.6452306
#> FitDTVARMxID_DTVAR_ID3.Rds 0.3667931  0.17275648  0.005867861 0.6412371
#> FitDTVARMxID_DTVAR_ID4.Rds 0.4814453 -0.20665773 -0.083737394 0.1282792
#> FitDTVARMxID_DTVAR_ID5.Rds 0.3894912 -0.09250685  0.029823476 0.5788790
#> FitDTVARMxID_DTVAR_ID6.Rds 0.1466637 -0.04662990  0.044473537 0.3646829
#>                            mu_eta_1_1    mu_eta_2_1   psi_l_2_1   psi_d_1_1
#> FitDTVARMxID_DTVAR_ID1.Rds  0.7429922 -0.5422434386 -0.64137358 -2.09263860
#> FitDTVARMxID_DTVAR_ID2.Rds  2.1089697 -0.9809131058 -0.37478408 -1.74439266
#> FitDTVARMxID_DTVAR_ID3.Rds  0.9790736 -1.7645485016 -0.26088418 -1.21125563
#> FitDTVARMxID_DTVAR_ID4.Rds  1.5471235 -0.7583743612 -0.05025920 -1.63597326
#> FitDTVARMxID_DTVAR_ID5.Rds  0.8140559 -0.0001548687 -0.11296257 -0.87220954
#> FitDTVARMxID_DTVAR_ID6.Rds  0.6719574 -1.2148346783 -0.09648513  0.02601587
#>                              psi_d_2_1 theta_d_1_1 theta_d_2_1
#> FitDTVARMxID_DTVAR_ID1.Rds -2.44661974  -0.3062973  -0.2501242
#> FitDTVARMxID_DTVAR_ID2.Rds -2.01994760  -0.2184480  -0.3630670
#> FitDTVARMxID_DTVAR_ID3.Rds -1.83009313  -0.7312709  -0.5093707
#> FitDTVARMxID_DTVAR_ID4.Rds  0.08626565  -0.3614859 -14.3344963
#> FitDTVARMxID_DTVAR_ID5.Rds -1.77703664  -0.7189124  -0.6065102
#> FitDTVARMxID_DTVAR_ID6.Rds -0.80564615 -17.1757445  -0.8495140

Proportion of converged cases

converged(
  fit,
  theta_tol = 0.01,
  prop = TRUE
)
#> [1] 0.903

Fixed-Effect Meta-Analysis of Measurement Error

When fitting DT-VAR models per person, separating process noise (𝚿\boldsymbol{\Psi}) from measurement error (𝚯\boldsymbol{\Theta}) can be unstable for some individuals. To stabilize inference, we first pool the person-level 𝚯i\boldsymbol{\Theta}_{i} estimates from only the converged fits using a fixed-effect meta-analysis. This yields a high-precision estimate of the common measurement-error covariance that we will then hold fixed in a second pass of model fitting.

What the code does: - Selects individuals that converged and whose 𝚯i\boldsymbol{\Theta}_i diagonals exceed a small threshold (theta_tol), filtering out near-zero or ill-conditioned solutions. - Extracts each person’s LDL’ diagonal parameters for 𝚯i\boldsymbol{\Theta}_i and their sampling covariance matrices. - Computes the inverse-variance-weighted pooled estimate (fixed effect), returning it on the same LDL’ parameterization used by FitDTVARMxID().

library(metaVAR)
fixed_theta <- MetaVARMx(
  fit,
  random = FALSE, # TRUE by default
  effects = FALSE, # TRUE by default
  cov_meas = TRUE, # FALSE by default
  theta_tol = 0.01,
  ncores = parallel::detectCores()
)

You can read summary(fixed_theta) as providing the pooled (fixed) measurement-error scale that is common across persons. If individual instruments truly share the same reliability structure, fixing 𝚯\boldsymbol{\Theta} to this pooled value improves stability and often reduces bias in the dynamic parameters.

Note: Fixed-effect pooling assumes a common 𝚯\boldsymbol{\Theta} across individuals.

coef(fixed_theta)
#>  alpha_1_1  alpha_2_1 
#> -0.3798856 -0.3848457
summary(fixed_theta)
#> [1] 0
#> Call:
#> MetaVARMx(object = fit, random = FALSE, effects = FALSE, cov_meas = TRUE, 
#>     theta_tol = 0.01, ncores = parallel::detectCores())
#> 
#> CI type = "normal"
#>                est     se        z p    2.5%   97.5%
#> alpha[1,1] -0.3799 0.0045 -84.0518 0 -0.3887 -0.3710
#> alpha[2,1] -0.3848 0.0043 -88.6967 0 -0.3933 -0.3763
theta_d_values <- coef(fixed_theta)

Refit the model with fixed measurement error covariance matrix

We refit the individual models using the pooled 𝚯\boldsymbol{\Theta} as a fixed measurement-error covariance matrix.

fit <- FitDTVARMxID(
  data = data,
  observed = c("y1", "y2"),
  id = "id",
  center = TRUE,
  mu_eta_values = mu_eta_values,
  beta_values = beta_values,
  psi_d_values = psi_d_values,
  psi_l_values = psi_l_values,
  theta_fixed = TRUE,
  theta_d_values = theta_d_values,
  mu0_values = mu0_values,
  sigma0_d_values = sigma0_d_values,
  sigma0_l_values = sigma0_l_values,
  ncores = parallel::detectCores()
)

With 𝚯\boldsymbol{\Theta} fixed, the re-estimation focuses on the dynamic structure (𝛍\boldsymbol{\mu}, 𝛃\boldsymbol{\beta}, 𝚿\boldsymbol{\Psi}). In practice, this often increases the proportion of converged fits and yields more stable cross-lag estimates.

Proportion of converged cases

converged(
  fit,
  prop = TRUE
)
#> [1] 1

Mixed-Effects Meta-Analysis with Distal Outcome of Person-Specific Dynamics and Means

Having stabilized 𝚯\boldsymbol{\Theta}, we synthesize the person-specific estimates to recover population-level effects, between-person variability, and systematic covariate-related differences. We fit a mixed-effects meta-analytic model in which each individual’s estimate is weighted by its within-person sampling uncertainty, random effects capture residual heterogeneity across individuals, and fixed effects quantify the association between covariate XX and the person-specific dynamic parameters as well as effects on a distal outcome.

random <- MetaVARMx(
  fit,
  x = x,
  z = z,
  effects = TRUE,
  set_point = TRUE,
  robust_v = FALSE,
  robust = TRUE,
  ncores = parallel::detectCores()
)
summary(random)
#> [1] 0
#> Call:
#> MetaVARMx(object = fit, x = x, z = z, effects = TRUE, set_point = TRUE, 
#>     robust_v = FALSE, robust = TRUE, ncores = parallel::detectCores())
#> 
#> CI type = "normal"
#>                  est     se           z      p    2.5%   97.5%
#> alpha[1,1]    1.0304 0.1198      8.6023 0.0000  0.7956  1.2652
#> alpha[2,1]   -1.0166 0.1184     -8.5849 0.0000 -1.2488 -0.7845
#> alpha[3,1]    0.5513 0.0061     89.9584 0.0000  0.5393  0.5633
#> alpha[4,1]    0.0204 0.0059      3.4481 0.0006  0.0088  0.0321
#> alpha[5,1]    0.0208 0.0055      3.7563 0.0002  0.0099  0.0316
#> alpha[6,1]    0.5549 0.0058     95.0818 0.0000  0.5435  0.5663
#> gamma[1,1]    2.2504 0.1695     13.2746 0.0000  1.9182  2.5827
#> gamma[2,1]   -2.4506 0.1675    -14.6274 0.0000 -2.7790 -2.1223
#> gamma[3,1]    0.1982 0.0081     24.5285 0.0000  0.1824  0.2140
#> gamma[4,1]   -0.0394 0.0078     -5.0212 0.0000 -0.0547 -0.0240
#> gamma[5,1]   -0.0140 0.0071     -1.9715 0.0487 -0.0278 -0.0001
#> gamma[6,1]    0.2053 0.0075     27.2814 0.0000  0.1906  0.2201
#> kappa[1,1]    9.8546 0.1296     76.0599 0.0000  9.6007 10.1086
#> phi[1,1]      4.9958 0.0095    528.2507 0.0000  4.9773  5.0144
#> phi[1,2]      5.0136 0.0096    524.7809 0.0000  4.9949  5.0324
#> phi[1,3]      5.1450 0.1712     30.0571 0.0000  4.8095  5.4804
#> phi[1,4]      4.8677 0.1712     28.4262 0.0000  4.5321  5.2033
#> phi[1,5]      4.8222 0.1854     26.0061 0.0000  4.4587  5.1856
#> phi[1,6]      5.1816 0.1747     29.6662 0.0000  4.8393  5.5239
#> omega[1,1]    0.1571 0.0713      2.2022 0.0277  0.0173  0.2969
#> psi[1,1]      0.4670 0.0209     22.3721 0.0000  0.4261  0.5079
#> tau_sqr[1,1]  7.2471 0.3253     22.2751 0.0000  6.6094  7.8848
#> tau_sqr[2,1]  2.1395 0.2368      9.0369 0.0000  1.6755  2.6036
#> tau_sqr[3,1]  0.1274 0.0106     11.9785 0.0000  0.1065  0.1482
#> tau_sqr[4,1]  0.0747 0.0098      7.5971 0.0000  0.0554  0.0939
#> tau_sqr[5,1] -0.1148 0.0092    -12.4286 0.0000 -0.1329 -0.0967
#> tau_sqr[6,1] -0.0644 0.0094     -6.8542 0.0000 -0.0829 -0.0460
#> tau_sqr[2,2]  7.0475 0.3162     22.2913 0.0000  6.4278  7.6671
#> tau_sqr[3,2]  0.0632 0.0101      6.2659 0.0000  0.0434  0.0829
#> tau_sqr[4,2]  0.1344 0.0105     12.8154 0.0000  0.1138  0.1549
#> tau_sqr[5,2] -0.0516 0.0083     -6.2249 0.0000 -0.0679 -0.0354
#> tau_sqr[6,2] -0.1101 0.0095    -11.6049 0.0000 -0.1287 -0.0915
#> tau_sqr[3,3]  0.0123 0.0007     16.9708 0.0000  0.0109  0.0137
#> tau_sqr[4,3]  0.0061 0.0005     11.4207 0.0000  0.0051  0.0072
#> tau_sqr[5,3] -0.0016 0.0004     -3.6272 0.0003 -0.0024 -0.0007
#> tau_sqr[6,3] -0.0007 0.0005     -1.5119 0.1306 -0.0016  0.0002
#> tau_sqr[4,4]  0.0116 0.0007     16.8114 0.0000  0.0103  0.0130
#> tau_sqr[5,4] -0.0026 0.0004     -6.3614 0.0000 -0.0034 -0.0018
#> tau_sqr[6,4] -0.0017 0.0004     -3.8666 0.0001 -0.0026 -0.0009
#> tau_sqr[5,5]  0.0083 0.0005     15.6867 0.0000  0.0073  0.0093
#> tau_sqr[6,5]  0.0032 0.0004      7.7199 0.0000  0.0024  0.0040
#> tau_sqr[6,6]  0.0100 0.0006     16.1457 0.0000  0.0087  0.0112
#> i_sqr[1,1]    0.9998 0.0000  97282.0973 0.0000  0.9998  0.9998
#> i_sqr[2,1]    0.9998 0.0000 105466.8039 0.0000  0.9998  0.9998
#> i_sqr[3,1]    0.9130 0.0047    195.2024 0.0000  0.9039  0.9222
#> i_sqr[4,1]    0.9279 0.0038    241.1257 0.0000  0.9203  0.9354
#> i_sqr[5,1]    0.8770 0.0068    129.2987 0.0000  0.8637  0.8903
#> i_sqr[6,1]    0.9092 0.0050    181.1073 0.0000  0.8994  0.9191

Normal Theory Confidence Intervals

confint(random, level = 0.95, lb = FALSE)
#>                     2.5 %        97.5 %
#> alpha[1,1]    0.795645533  1.265190e+00
#> alpha[2,1]   -1.248752370 -7.845448e-01
#> alpha[3,1]    0.539283375  5.633060e-01
#> alpha[4,1]    0.008823754  3.206671e-02
#> alpha[5,1]    0.009927449  3.159086e-02
#> alpha[6,1]    0.543472048  5.663493e-01
#> gamma[1,1]    1.918150801  2.582687e+00
#> gamma[2,1]   -2.779003765 -2.122269e+00
#> gamma[3,1]    0.182373291  2.140498e-01
#> gamma[4,1]   -0.054733290 -2.400063e-02
#> gamma[5,1]   -0.027839741 -8.192102e-05
#> gamma[6,1]    0.190588650  2.200931e-01
#> kappa[1,1]    9.600697946  1.010858e+01
#> phi[1,1]      4.977311073  5.014383e+00
#> phi[1,2]      4.994924338  5.032375e+00
#> phi[1,3]      4.809462198  5.480447e+00
#> phi[1,4]      4.532075425  5.203322e+00
#> phi[1,5]      4.458737933  5.185588e+00
#> phi[1,6]      4.839257154  5.523923e+00
#> omega[1,1]    0.017275605  2.968860e-01
#> psi[1,1]      0.426112003  5.079424e-01
#> tau_sqr[1,1]  6.609445479  7.884779e+00
#> tau_sqr[2,1]  1.675504871  2.603567e+00
#> tau_sqr[3,1]  0.106547713  1.482365e-01
#> tau_sqr[4,1]  0.055407065  9.393597e-02
#> tau_sqr[5,1] -0.132886496 -9.668376e-02
#> tau_sqr[6,1] -0.082853848 -4.600605e-02
#> tau_sqr[2,2]  6.427808452  7.667105e+00
#> tau_sqr[3,2]  0.043421040  8.294972e-02
#> tau_sqr[4,2]  0.113833342  1.549388e-01
#> tau_sqr[5,2] -0.067857538 -3.535899e-02
#> tau_sqr[6,2] -0.128666894 -9.148508e-02
#> tau_sqr[3,3]  0.010893987  1.373884e-02
#> tau_sqr[4,3]  0.005063908  7.162061e-03
#> tau_sqr[5,3] -0.002427073 -7.242415e-04
#> tau_sqr[6,3] -0.001611183  2.079506e-04
#> tau_sqr[4,4]  0.010251436  1.295723e-02
#> tau_sqr[5,4] -0.003408932 -1.803091e-03
#> tau_sqr[6,4] -0.002614903 -8.556802e-04
#> tau_sqr[5,5]  0.007264868  9.339495e-03
#> tau_sqr[6,5]  0.002400744  4.034564e-03
#> tau_sqr[6,6]  0.008744842  1.116129e-02
#> i_sqr[1,1]    0.999750876  9.997912e-01
#> i_sqr[2,1]    0.999770113  9.998073e-01
#> i_sqr[3,1]    0.903850271  9.221849e-01
#> i_sqr[4,1]    0.920338036  9.354224e-01
#> i_sqr[5,1]    0.863710067  8.902981e-01
#> i_sqr[6,1]    0.899379698  9.190591e-01
confint(random, level = 0.99, lb = FALSE)
#>                     0.5 %        99.5 %
#> alpha[1,1]    0.721874800  1.3389604164
#> alpha[2,1]   -1.321684665 -0.7116125062
#> alpha[3,1]    0.535509149  0.5670802140
#> alpha[4,1]    0.005172022  0.0357184373
#> alpha[5,1]    0.006523881  0.0349944315
#> alpha[6,1]    0.539877771  0.5699435743
#> gamma[1,1]    1.813744599  2.6870931839
#> gamma[2,1]   -2.882184327 -2.0190881110
#> gamma[3,1]    0.177396556  0.2190265017
#> gamma[4,1]   -0.059561742 -0.0191721751
#> gamma[5,1]   -0.032200811  0.0042791486
#> gamma[6,1]    0.185953164  0.2247285844
#> kappa[1,1]    9.520903861 10.1883742839
#> phi[1,1]      4.971486624  5.0202076205
#> phi[1,2]      4.989040486  5.0382583833
#> phi[1,3]      4.704042818  5.5858665579
#> phi[1,4]      4.426614902  5.3087827986
#> phi[1,5]      4.344541563  5.2997840361
#> phi[1,6]      4.731688334  5.6314919457
#> omega[1,1]   -0.026654365  0.3408159264
#> psi[1,1]      0.413255523  0.5207988341
#> tau_sqr[1,1]  6.409075987  8.0851489628
#> tau_sqr[2,1]  1.529695796  2.7493757369
#> tau_sqr[3,1]  0.099997931  0.1547862739
#> tau_sqr[4,1]  0.049353736  0.0999892996
#> tau_sqr[5,1] -0.138574358 -0.0909958985
#> tau_sqr[6,1] -0.088643056 -0.0402168392
#> tau_sqr[2,2]  6.233100859  7.8618125532
#> tau_sqr[3,2]  0.037210635  0.0891601234
#> tau_sqr[4,2]  0.107375209  0.1613969120
#> tau_sqr[5,2] -0.072963430 -0.0302530970
#> tau_sqr[6,2] -0.134508581 -0.0856433920
#> tau_sqr[3,3]  0.010447028  0.0141858019
#> tau_sqr[4,3]  0.004734265  0.0074917045
#> tau_sqr[5,3] -0.002694607 -0.0004567073
#> tau_sqr[6,3] -0.001896990  0.0004937573
#> tau_sqr[4,4]  0.009826325  0.0133823408
#> tau_sqr[5,4] -0.003661227 -0.0015507954
#> tau_sqr[6,4] -0.002891297 -0.0005792863
#> tau_sqr[5,5]  0.006938921  0.0096654420
#> tau_sqr[6,5]  0.002144052  0.0042912560
#> tau_sqr[6,6]  0.008365191  0.0115409384
#> i_sqr[1,1]    0.999744546  0.9997974902
#> i_sqr[2,1]    0.999764275  0.9998131111
#> i_sqr[3,1]    0.900969692  0.9250654766
#> i_sqr[4,1]    0.917968114  0.9377923061
#> i_sqr[5,1]    0.859532790  0.8944753407
#> i_sqr[6,1]    0.896287847  0.9221509035

Robust Confidence Intervals

confint(random, level = 0.95, lb = FALSE, robust = TRUE)
#>                     2.5 %        97.5 %
#> alpha[1,1]    0.954009504  1.1068257131
#> alpha[2,1]   -1.093136721 -0.9401604508
#> alpha[3,1]    0.538507678  0.5640816851
#> alpha[4,1]    0.008438036  0.0324524237
#> alpha[5,1]    0.009668783  0.0318495288
#> alpha[6,1]    0.542586245  0.5672350999
#> gamma[1,1]    1.917400079  2.5834377043
#> gamma[2,1]   -2.779454768 -2.1218176695
#> gamma[3,1]    0.182041192  0.2143818651
#> gamma[4,1]   -0.054982266 -0.0237516503
#> gamma[5,1]   -0.028200642  0.0002789799
#> gamma[6,1]    0.190151007  0.2205307423
#> kappa[1,1]    9.611802837 10.0974753076
#> phi[1,1]      4.978269132  5.0134251125
#> phi[1,2]      4.996834018  5.0304648513
#> phi[1,3]      4.815395731  5.4745136445
#> phi[1,4]      4.532305332  5.2030923689
#> phi[1,5]      4.462575857  5.1817497424
#> phi[1,6]      4.851474672  5.5117056073
#> omega[1,1]    0.019541658  0.2946199037
#> psi[1,1]      0.426130719  0.5079236376
#> tau_sqr[1,1]  5.387957749  9.1062672013
#> tau_sqr[2,1]  0.944451816  3.3346197167
#> tau_sqr[3,1]  0.100881257  0.1539029479
#> tau_sqr[4,1]  0.053782350  0.0955606849
#> tau_sqr[5,1] -0.138071603 -0.0914986536
#> tau_sqr[6,1] -0.085039851 -0.0438200451
#> tau_sqr[2,2]  5.455328896  8.6395845168
#> tau_sqr[3,2]  0.036192674  0.0901780843
#> tau_sqr[4,2]  0.104961488  0.1638106334
#> tau_sqr[5,2] -0.070737415 -0.0324791127
#> tau_sqr[6,2] -0.130761588 -0.0893903843
#> tau_sqr[3,3]  0.010883817  0.0137490127
#> tau_sqr[4,3]  0.004984255  0.0072417146
#> tau_sqr[5,3] -0.002447008 -0.0007043060
#> tau_sqr[6,3] -0.001608709  0.0002054764
#> tau_sqr[4,4]  0.010173979  0.0130346868
#> tau_sqr[5,4] -0.003435942 -0.0017760805
#> tau_sqr[6,4] -0.002582638 -0.0008879455
#> tau_sqr[5,5]  0.007326583  0.0092777797
#> tau_sqr[6,5]  0.002324761  0.0041105469
#> tau_sqr[6,6]  0.008594191  0.0113119382
#> i_sqr[1,1]    0.999712291  0.9998297453
#> i_sqr[2,1]    0.999738995  0.9998383910
#> i_sqr[3,1]    0.903782934  0.9222522349
#> i_sqr[4,1]    0.919794805  0.9359656144
#> i_sqr[5,1]    0.864399311  0.8896088201
#> i_sqr[6,1]    0.897941819  0.9204969318
confint(random, level = 0.99, lb = FALSE, robust = TRUE)
#>                     0.5 %        99.5 %
#> alpha[1,1]    0.930000337  1.1308348797
#> alpha[2,1]   -1.117171035 -0.9161261369
#> alpha[3,1]    0.534489710  0.5680996528
#> alpha[4,1]    0.004665102  0.0362253575
#> alpha[5,1]    0.006183936  0.0353343764
#> alpha[6,1]    0.538713630  0.5711077156
#> gamma[1,1]    1.812757984  2.6880797993
#> gamma[2,1]   -2.882777045 -2.0184953929
#> gamma[3,1]    0.176960105  0.2194629531
#> gamma[4,1]   -0.059888952 -0.0188449649
#> gamma[5,1]   -0.032675115  0.0047534528
#> gamma[6,1]    0.185378004  0.2253037447
#> kappa[1,1]    9.535498162 10.1737799829
#> phi[1,1]      4.972745727  5.0189485173
#> phi[1,2]      4.991550231  5.0357486382
#> phi[1,3]      4.711840802  5.5780685739
#> phi[1,4]      4.426917050  5.3084806505
#> phi[1,5]      4.349585451  5.2947401488
#> phi[1,6]      4.747744874  5.6154354051
#> omega[1,1]   -0.023676267  0.3378378283
#> psi[1,1]      0.413280120  0.5207742365
#> tau_sqr[1,1]  4.803768995  9.6904559556
#> tau_sqr[2,1]  0.568929223  3.7101423101
#> tau_sqr[3,1]  0.092550946  0.1622332593
#> tau_sqr[4,1]  0.047218498  0.1021245370
#> tau_sqr[5,1] -0.145388744 -0.0841815129
#> tau_sqr[6,1] -0.091515951 -0.0373439442
#> tau_sqr[2,2]  4.955046080  9.1398673331
#> tau_sqr[3,2]  0.027710951  0.0986598070
#> tau_sqr[4,2]  0.095715617  0.1730565043
#> tau_sqr[5,2] -0.076748229 -0.0264682978
#> tau_sqr[6,2] -0.137261476 -0.0828904970
#> tau_sqr[3,3]  0.010433662  0.0141991677
#> tau_sqr[4,3]  0.004629582  0.0075963872
#> tau_sqr[5,3] -0.002720806 -0.0004305076
#> tau_sqr[6,3] -0.001893738  0.0004905056
#> tau_sqr[4,4]  0.009724529  0.0134841366
#> tau_sqr[5,4] -0.003696725 -0.0015152973
#> tau_sqr[6,4] -0.002848893 -0.0006216901
#> tau_sqr[5,5]  0.007020028  0.0095843349
#> tau_sqr[6,5]  0.002044194  0.0043911141
#> tau_sqr[6,6]  0.008167202  0.0117389273
#> i_sqr[1,1]    0.999693838  0.9998481986
#> i_sqr[2,1]    0.999723379  0.9998540072
#> i_sqr[3,1]    0.900881196  0.9251539724
#> i_sqr[4,1]    0.917254187  0.9385062327
#> i_sqr[5,1]    0.860438610  0.8935695210
#> i_sqr[6,1]    0.894398154  0.9240405968

Profile-Likelihood Confidence Intervals

confint(random, level = 0.95, lb = TRUE)
#> Error in `[.data.frame`:
#> ! undefined columns selected
confint(random, level = 0.99, lb = TRUE)
#> Error in `[.data.frame`:
#> ! undefined columns selected
  • The fixed part of the random-effects model gives pooled means for the person-specific parameters (e.g., 𝔼[vec(𝛃i)]\mathbb{E}[\mathrm{vec}(\boldsymbol{\beta}_i)] and 𝔼[π›Ži]\mathbb{E}[\boldsymbol{\nu}_i]) and fixed effects for how XX shifts these parameters.
  • The random part yields between-person covariances (𝛕2\boldsymbol{\tau}^2) quantifying residual heterogeneity in dynamics and intercepts beyond what is explained by XX.
  • The distal-outcome sub-model yields regression effects linking the the estimated person-specific parameters (via π›Ÿ\boldsymbol{\phi}) to distal outcome ziz_i, a direct effect of XX on ziz_i (via Ο‰\omega), and the residual variance ψ\psi.
means <- extract(random, what = "alpha")
means
#> [1]  1.03041761 -1.01664859  0.55129468  0.02044523  0.02075916  0.55491067
covariances <- extract(random, what = "tau_sqr")
covariances
#>             [,1]        [,2]          [,3]         [,4]         [,5]
#> [1,]  7.24711248  2.13953577  0.1273921026  0.074671518 -0.114785128
#> [2,]  2.13953577  7.04745671  0.0631853790  0.134386061 -0.051608264
#> [3,]  0.12739210  0.06318538  0.0123164147  0.006112985 -0.001575657
#> [4,]  0.07467152  0.13438606  0.0061129847  0.011604333 -0.002606011
#> [5,] -0.11478513 -0.05160826 -0.0015756570 -0.002606011  0.008302181
#> [6,] -0.06442995 -0.11007599 -0.0007016163 -0.001735292  0.003217654
#>               [,6]
#> [1,] -0.0644299479
#> [2,] -0.1100759864
#> [3,] -0.0007016163
#> [4,] -0.0017352916
#> [5,]  0.0032176542
#> [6,]  0.0099530645

Finally, we compare the meta-analytic population estimates to the known generating values.

pop_mean
#> [1]  2.25717566 -2.11275830  0.61362799 -0.00661199 -0.00502123  0.61560881
pop_cov
#>             [,1]        [,2]         [,3]          [,4]          [,5]
#> [1,]  7.87336834  0.88804821  0.273086594  0.0638425889 -0.0915731218
#> [2,]  0.88804821  8.36786378 -0.036344806  0.1331000366 -0.0374675414
#> [3,]  0.27308659 -0.03634481  0.030143625  0.0079252730 -0.0011555838
#> [4,]  0.06384259  0.13310004  0.007925273  0.0139995106 -0.0006635365
#> [5,] -0.09157312 -0.03746754 -0.001155584 -0.0006635365  0.0097715146
#> [6,]  0.09000510 -0.23694437  0.012738301 -0.0012966040  0.0040795653
#>              [,6]
#> [1,]  0.090005095
#> [2,] -0.236944365
#> [3,]  0.012738301
#> [4,] -0.001296604
#> [5,]  0.004079565
#> [6,]  0.027041975

Summary

This vignette demonstrates a two-stage hierarchical estimation approach for dynamic systems: 1. Individual-level DT-VAR estimation with stabilized measurement error. 2. Population-level meta-analysis of person-specific dynamics and means. 3. Estimation and interpretation of covariate effects, where XX predicts systematic between-person differences in dynamics and baseline levels. 4. A distal outcome model linking ziz_i to person-specific dynamic/mean features and to XX.

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. https://doi.org/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. https://doi.org/10.1007/s11336-014-9435-8
R Core Team. (2024). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/