Multivariate Meta-Analysis of Discrete-Time VAR Estimates (Fixed-Effect Model)
Ivan Jacob Agaloos Pesigan
2025-05-08
Source:vignettes/fit-dt-var-id-fixed.Rmd
fit-dt-var-id-fixed.Rmd
Model
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 matrix of factor loadings, and the covariance matrix of . In this model, is an identity matrix and is a diagonal matrix.
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 . In this model, is a symmetric matrix.
Data Generation
The parameters used in this example were based on Bringmann et al. (2013).
Notation
Let be the number of time points and be the number of individuals.
Let the measurement model intecept vector be given by
Let the factor loadings matrix be given by
Let the measurement error covariance matrix be given by
Let the initial condition be given by
Let the transition matrix be given by
Let the dynamic process noise be given by
R Function Arguments
n
#> [1] 1000
time
#> [1] 1000
mu0
#> [1] 3.814355 2.576348
sigma0
#> [,1] [,2]
#> [1,] 1.3978842 0.5782369
#> [2,] 0.5782369 1.6636513
sigma0_l # sigma0_l <- t(chol(sigma0))
#> [,1] [,2]
#> [1,] 1.1823215 0.000000
#> [2,] 0.4890691 1.193509
alpha
#> [1] 2.87 2.04
beta
#> [,1] [,2]
#> [1,] 0.280 -0.048
#> [2,] -0.035 0.260
psi
#> [,1] [,2]
#> [1,] 1.3000000 0.5696315
#> [2,] 0.5696315 1.5600000
psi_l # psi_l <- t(chol(psi))
#> [,1] [,2]
#> [1,] 1.1401754 0.000000
#> [2,] 0.4995998 1.144727
nu
#> [1] 0 0
lambda
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 0 1
theta
#> [,1] [,2]
#> [1,] 0.2 0.0
#> [2,] 0.0 0.2
theta_l # theta_l <- t(chol(theta))
#> [,1] [,2]
#> [1,] 0.4472136 0.0000000
#> [2,] 0.0000000 0.4472136
Using the SimSSMFixed
Function from the
simStateSpace
Package to Simulate Data
library(simStateSpace)
sim <- 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
)
data <- as.data.frame(sim)
head(data)
#> id time y1 y2
#> 1 1 0 3.455114 1.9223092
#> 2 1 1 5.696312 0.6452660
#> 3 1 2 4.364664 1.4954592
#> 4 1 3 4.900281 2.6730811
#> 5 1 4 2.325515 0.2139305
#> 6 1 5 3.340405 1.9930331
plot(sim)
Model Fitting
The FitDTVARIDMx
function fits a DT-VAR model on each
individual
.
library(fitDTVARMx)
fit <- FitDTVARIDMx(
data = data,
observed = paste0("y", seq_len(k)),
id = "id",
mu0_values = mu0,
sigma0_values = sigma0,
ncores = parallel::detectCores()
)
Multivariate Meta-Analysis
The MetaVARMx
function performs multivariate
meta-analysis using the estimated parameters and the corresponding
sampling variance-covariance matrix for each individual
.
Estimates with the prefix b0
correspond to the estimates of
beta
and alpha
.
library(metaVAR)
meta <- MetaVARMx(
object = fit,
random = FALSE,
intercept = TRUE,
ncores = parallel::detectCores()
)
#> Running Model with 6 parameters
#>
#> Beginning initial fit attempt
#> Running Model with 6 parameters
#>
#> Lowest minimum so far: 14630.5433348837
#>
#> Solution found
#>
#> Solution found! Final fit=14630.543 (started at 25387129) (1 attempt(s): 1 valid, 0 errors)
#> Start values from best fit:
#> 0.185482523593782,0.0121788228619116,0.0115184897567764,0.184817876404306,3.10216459456662,2.02115148863649
summary(meta)
#> est se z p 2.5% 97.5%
#> b0_1 0.1855 0.0017 109.4794 0 0.1822 0.1888
#> b0_2 0.0122 0.0014 8.9432 0 0.0095 0.0148
#> b0_3 0.0115 0.0013 8.9464 0 0.0090 0.0140
#> b0_4 0.1848 0.0017 108.4805 0 0.1815 0.1882
#> b0_5 3.1022 0.0064 483.2179 0 3.0896 3.1147
#> b0_6 2.0212 0.0060 334.1024 0 2.0093 2.0330