Empirical Illustration: Meta-Analysis of Affect Dynamics
Anonymous
Source:vignettes/empirical.Rmd
empirical.RmdData Pre-Processing
This illustration uses ecological momentary assessment (EMA) data from the Affective Dynamics and Individual Differences (ADID) study. To align the data with the discrete-time VAR framework used in this vignette, we first rounded each response timestamp to the nearest hour and then constructed an hourly, regularly spaced time series for each participant. Hours with no observed response were retained as missing so that the lagged effects could be interpreted on an approximately hourly timescale.
We then created per-occasion negative affect (NA) and positive affect (PA) composites by averaging the available negative-affect and positive-affect item responses, respectively. Because the raw EMA series also contain slower month-long drift, we applied within-person linear detrending before model fitting. Under this preprocessing scheme, the resulting VAR model targets a short-term, detrended, approximately hourly affective process rather than the full raw trajectory.
The full preprocessing script used to generate the analysis dataset is available here:
Stage 1: Person-Specific VAR
library(OpenMx)
library(fitVARMxID)
stage1 <- FitVARMxID(
data = data,
observed = c("na", "pa"),
id = "id",
center = TRUE,
ncores = parallel::detectCores()
)
summary(stage1, means = TRUE)
#> Call:
#> FitVARMxID(data = data, observed = c("na", "pa"), id = "id",
#> center = TRUE, ncores = parallel::detectCores())
#>
#> Convergence:
#> 100.0%
#>
#> Means of the estimated paramaters per individual.
#> mu[1,1] mu[2,1] beta[1,1] beta[2,1] beta[1,2] beta[2,2] psi[1,1] psi[2,1]
#> 1.4411 2.5824 0.3246 -0.0888 -0.0592 0.2782 0.0403 -0.0112
#> psi[2,2]
#> 0.0701Stage 2: Multivariate Random-Effects Meta-Analysis of the Dynamic Parameter System
library(metaDyn)
stage2 <- MetaVARMx(
object = stage1,
random = TRUE,
ncores = parallel::detectCores()
)
summary(stage2)
#> Call:
#> MetaVARMx(object = stage1, random = TRUE, ncores = parallel::detectCores())
#>
#> Status code:
#> 0
#>
#> CI type:
#> "normal"
#>
#> est se z p 2.5% 97.5%
#> alpha[1,1] 1.4402 0.0253 56.9727 0.0000 1.3907 1.4898
#> alpha[2,1] 2.5817 0.0322 80.2380 0.0000 2.5187 2.6448
#> alpha[3,1] 0.3617 0.0309 11.6903 0.0000 0.3011 0.4224
#> alpha[4,1] -0.0761 0.0364 -2.0899 0.0366 -0.1474 -0.0047
#> alpha[5,1] -0.0598 0.0186 -3.2091 0.0013 -0.0963 -0.0233
#> alpha[6,1] 0.3170 0.0314 10.1063 0.0000 0.2555 0.3784
#> alpha[7,1] 0.0333 0.0019 17.4914 0.0000 0.0296 0.0370
#> alpha[8,1] -0.0073 0.0010 -7.4156 0.0000 -0.0093 -0.0054
#> alpha[9,1] 0.0609 0.0029 20.8052 0.0000 0.0552 0.0666
#> tau_sqr[1,1] 0.1373 0.0133 10.2958 0.0000 0.1112 0.1634
#> tau_sqr[2,1] 0.0030 0.0120 0.2481 0.8041 -0.0205 0.0264
#> tau_sqr[3,1] 0.0262 0.0117 2.2274 0.0259 0.0031 0.0492
#> tau_sqr[4,1] -0.0025 0.0133 -0.1865 0.8521 -0.0284 0.0235
#> tau_sqr[5,1] 0.0003 0.0071 0.0455 0.9637 -0.0136 0.0143
#> tau_sqr[6,1] -0.0028 0.0116 -0.2444 0.8069 -0.0257 0.0200
#> tau_sqr[7,1] 0.0040 0.0008 5.2301 0.0000 0.0025 0.0054
#> tau_sqr[8,1] 0.0000 0.0003 0.0982 0.9218 -0.0006 0.0007
#> tau_sqr[9,1] -0.0022 0.0011 -2.0799 0.0375 -0.0043 -0.0001
#> tau_sqr[2,2] 0.2227 0.0215 10.3522 0.0000 0.1806 0.2649
#> tau_sqr[3,2] 0.0033 0.0148 0.2230 0.8235 -0.0257 0.0322
#> tau_sqr[4,2] -0.0057 0.0171 -0.3336 0.7387 -0.0391 0.0278
#> tau_sqr[5,2] -0.0049 0.0090 -0.5463 0.5849 -0.0225 0.0127
#> tau_sqr[6,2] 0.0045 0.0148 0.3013 0.7632 -0.0246 0.0335
#> tau_sqr[7,2] -0.0022 0.0009 -2.4979 0.0125 -0.0039 -0.0005
#> tau_sqr[8,2] 0.0008 0.0004 1.7833 0.0745 -0.0001 0.0016
#> tau_sqr[9,2] -0.0055 0.0014 -3.9687 0.0001 -0.0082 -0.0028
#> tau_sqr[3,3] 0.1841 0.0195 9.4600 0.0000 0.1460 0.2223
#> tau_sqr[4,3] -0.0655 0.0174 -3.7713 0.0002 -0.0996 -0.0315
#> tau_sqr[5,3] 0.0237 0.0089 2.6658 0.0077 0.0063 0.0411
#> tau_sqr[6,3] 0.0040 0.0145 0.2774 0.7815 -0.0243 0.0324
#> tau_sqr[7,3] -0.0011 0.0009 -1.2615 0.2071 -0.0027 0.0006
#> tau_sqr[8,3] 0.0007 0.0004 1.7231 0.0849 -0.0001 0.0016
#> tau_sqr[9,3] -0.0003 0.0013 -0.2630 0.7926 -0.0029 0.0022
#> tau_sqr[4,4] 0.2257 0.0303 7.4481 0.0000 0.1663 0.2851
#> tau_sqr[5,4] 0.0022 0.0091 0.2359 0.8135 -0.0158 0.0201
#> tau_sqr[6,4] 0.0375 0.0170 2.2070 0.0273 0.0042 0.0709
#> tau_sqr[7,4] 0.0012 0.0010 1.2419 0.2143 -0.0007 0.0031
#> tau_sqr[8,4] -0.0009 0.0005 -1.8605 0.0628 -0.0018 0.0000
#> tau_sqr[9,4] -0.0017 0.0016 -1.0609 0.2888 -0.0048 0.0014
#> tau_sqr[5,5] 0.0596 0.0080 7.4151 0.0000 0.0439 0.0754
#> tau_sqr[6,5] -0.0227 0.0090 -2.5166 0.0119 -0.0404 -0.0050
#> tau_sqr[7,5] -0.0008 0.0005 -1.4432 0.1490 -0.0018 0.0003
#> tau_sqr[8,5] -0.0001 0.0002 -0.4722 0.6368 -0.0006 0.0004
#> tau_sqr[9,5] 0.0001 0.0008 0.1497 0.8810 -0.0014 0.0016
#> tau_sqr[6,6] 0.1904 0.0201 9.4779 0.0000 0.1510 0.2298
#> tau_sqr[7,6] 0.0010 0.0009 1.1637 0.2445 -0.0007 0.0027
#> tau_sqr[8,6] -0.0009 0.0004 -2.0560 0.0398 -0.0017 0.0000
#> tau_sqr[9,6] -0.0011 0.0013 -0.8280 0.4077 -0.0036 0.0015
#> tau_sqr[7,7] 0.0007 0.0001 7.8848 0.0000 0.0005 0.0008
#> tau_sqr[8,7] -0.0002 0.0000 -4.5148 0.0000 -0.0002 -0.0001
#> tau_sqr[9,7] 0.0004 0.0001 4.0520 0.0001 0.0002 0.0005
#> tau_sqr[8,8] 0.0001 0.0000 5.8769 0.0000 0.0001 0.0002
#> tau_sqr[9,8] -0.0002 0.0000 -4.6322 0.0000 -0.0003 -0.0001
#> tau_sqr[9,9] 0.0016 0.0002 8.0357 0.0000 0.0012 0.0019
#> i_sqr[1,1] 1.0000 0.0000 817675.4847 0.0000 1.0000 1.0000
#> i_sqr[2,1] 0.9997 0.0000 36062.4306 0.0000 0.9997 0.9998
#> i_sqr[3,1] 0.9906 0.0010 1004.2120 0.0000 0.9886 0.9925
#> i_sqr[4,1] 0.9790 0.0027 356.6691 0.0000 0.9736 0.9844
#> i_sqr[5,1] 0.9929 0.0008 1211.9282 0.0000 0.9913 0.9945
#> i_sqr[6,1] 0.9880 0.0012 792.0031 0.0000 0.9856 0.9905
#> i_sqr[7,1] 0.9999 0.0000 106580.6511 0.0000 0.9999 0.9999
#> i_sqr[8,1] 0.9997 0.0000 21146.1001 0.0000 0.9996 0.9998
#> i_sqr[9,1] 0.9999 0.0000 103442.4555 0.0000 0.9999 0.9999