Skip to contents

This function computes the delta method sampling variance-covariance matrix for the total, direct, and indirect effects of the independent variable \(X\) on the dependent variable \(Y\) through mediator variables \(\mathbf{m}\) over a specific time interval \(\Delta t\) or a range of time intervals using the first-order stochastic differential equation model's drift matrix \(\boldsymbol{\Phi}\).

Usage

DeltaMed(phi, vcov_phi_vec, delta_t, from, to, med, ncores = NULL)

Arguments

phi

Numeric matrix. The drift matrix (\(\boldsymbol{\Phi}\)). phi should have row and column names pertaining to the variables in the system.

vcov_phi_vec

Numeric matrix. The sampling variance-covariance matrix of \(\mathrm{vec} \left( \boldsymbol{\Phi} \right)\).

delta_t

Vector of positive numbers. Time interval (\(\Delta t\)).

from

Character string. Name of the independent variable \(X\) in phi.

to

Character string. Name of the dependent variable \(Y\) in phi.

med

Character vector. Name/s of the mediator variable/s in phi.

ncores

Positive integer. Number of cores to use. If ncores = NULL, use a single core. Consider using multiple cores when the length of delta_t is long.

Value

Returns an object of class ctmeddelta which is a list with the following elements:

call

Function call.

args

Function arguments.

fun

Function used ("DeltaMed").

output

A list the length of which is equal to the length of delta_t.

Each element in the output list has the following elements:

delta_t

Time interval.

jacobian

Jacobian matrix.

est

Estimated total, direct, and indirect effects.

vcov

Sampling variance-covariance matrix of the estimated total, direct, and indirect effects.

Details

See Total(), Direct(), and Indirect() for more details.

Delta Method

Let \(\boldsymbol{\theta}\) be \(\mathrm{vec} \left( \boldsymbol{\Phi} \right)\), that is, the elements of the \(\boldsymbol{\Phi}\) matrix in vector form sorted column-wise. Let \(\hat{\boldsymbol{\theta}}\) be \(\mathrm{vec} \left( \hat{\boldsymbol{\Phi}} \right)\). By the multivariate central limit theory, the function \(\mathbf{g}\) using \(\hat{\boldsymbol{\theta}}\) as input can be expressed as:

$$ \sqrt{n} \left( \mathbf{g} \left( \hat{\boldsymbol{\theta}} \right) - \mathbf{g} \left( \boldsymbol{\theta} \right) \right) \xrightarrow[]{ \mathrm{D} } \mathcal{N} \left( 0, \mathbf{J} \boldsymbol{\Gamma} \mathbf{J}^{\prime} \right) $$

where \(\mathbf{J}\) is the matrix of first-order derivatives of the function \(\mathbf{g}\) with respect to the elements of \(\boldsymbol{\theta}\) and \(\boldsymbol{\Gamma}\) is the asymptotic variance-covariance matrix of \(\hat{\boldsymbol{\theta}}\).

From the former, we can derive the distribution of \(\mathbf{g} \left( \hat{\boldsymbol{\theta}} \right)\) as follows:

$$ \mathbf{g} \left( \hat{\boldsymbol{\theta}} \right) \approx \mathcal{N} \left( \mathbf{g} \left( \boldsymbol{\theta} \right) , n^{-1} \mathbf{J} \boldsymbol{\Gamma} \mathbf{J}^{\prime} \right) $$

The uncertainty associated with the estimator \(\mathbf{g} \left( \hat{\boldsymbol{\theta}} \right)\) is, therefore, given by \(n^{-1} \mathbf{J} \boldsymbol{\Gamma} \mathbf{J}^{\prime}\) . When \(\boldsymbol{\Gamma}\) is unknown, by substitution, we can use the estimated sampling variance-covariance matrix of \(\hat{\boldsymbol{\theta}}\), that is, \(\hat{\mathbb{V}} \left( \hat{\boldsymbol{\theta}} \right)\) for \(n^{-1} \boldsymbol{\Gamma}\). Therefore, the sampling variance-covariance matrix of \(\mathbf{g} \left( \hat{\boldsymbol{\theta}} \right)\) is given by

$$ \mathbf{g} \left( \hat{\boldsymbol{\theta}} \right) \approx \mathcal{N} \left( \mathbf{g} \left( \boldsymbol{\theta} \right) , \mathbf{J} \hat{\mathbb{V}} \left( \hat{\boldsymbol{\theta}} \right) \mathbf{J}^{\prime} \right) . $$

References

Bollen, K. A. (1987). Total, direct, and indirect effects in structural equation models. Sociological Methodology, 17, 37. doi:10.2307/271028

Deboeck, P. R., & Preacher, K. J. (2015). No need to be discrete: A method for continuous time mediation analysis. Structural Equation Modeling: A Multidisciplinary Journal, 23 (1), 61–75. doi:10.1080/10705511.2014.973960

Ryan, O., & Hamaker, E. L. (2021). Time to intervene: A continuous-time approach to network analysis and centrality. Psychometrika, 87 (1), 214–252. doi:10.1007/s11336-021-09767-0

Author

Ivan Jacob Agaloos Pesigan

Examples

phi <- matrix(
  data = c(
    -0.357, 0.771, -0.450,
    0.0, -0.511, 0.729,
    0, 0, -0.693
  ),
  nrow = 3
)
colnames(phi) <- rownames(phi) <- c("x", "m", "y")
vcov_phi_vec <- matrix(
  data = c(
    0.002704274, -0.001475275, 0.000949122,
    -0.001619422, 0.000885122, -0.000569404,
    0.00085493, -0.000465824, 0.000297815,
    -0.001475275, 0.004428442, -0.002642303,
    0.000980573, -0.00271817, 0.001618805,
    -0.000586921, 0.001478421, -0.000871547,
    0.000949122, -0.002642303, 0.006402668,
    -0.000697798, 0.001813471, -0.004043138,
    0.000463086, -0.001120949, 0.002271711,
    -0.001619422, 0.000980573, -0.000697798,
    0.002079286, -0.001152501, 0.000753,
    -0.001528701, 0.000820587, -0.000517524,
    0.000885122, -0.00271817, 0.001813471,
    -0.001152501, 0.00342605, -0.002075005,
    0.000899165, -0.002532849, 0.001475579,
    -0.000569404, 0.001618805, -0.004043138,
    0.000753, -0.002075005, 0.004984032,
    -0.000622255, 0.001634917, -0.003705661,
    0.00085493, -0.000586921, 0.000463086,
    -0.001528701, 0.000899165, -0.000622255,
    0.002060076, -0.001096684, 0.000686386,
    -0.000465824, 0.001478421, -0.001120949,
    0.000820587, -0.002532849, 0.001634917,
    -0.001096684, 0.003328692, -0.001926088,
    0.000297815, -0.000871547, 0.002271711,
    -0.000517524, 0.001475579, -0.003705661,
    0.000686386, -0.001926088, 0.004726235
  ),
  nrow = 9
)

# Specific time interval ----------------------------------------------------
DeltaMed(
  phi = phi,
  vcov_phi_vec = vcov_phi_vec,
  delta_t = 1,
  from = "x",
  to = "y",
  med = "m"
)
#> 
#> Total, Direct, and Indirect Effects
#> 
#> $`1`
#>          interval     est     se       z      p    2.5%   97.5%
#> total           1 -0.1000 0.0329 -3.0424 0.0023 -0.1645 -0.0356
#> direct          1 -0.2675 0.0436 -6.1280 0.0000 -0.3530 -0.1819
#> indirect        1  0.1674 0.0194  8.6167 0.0000  0.1293  0.2055
#> 

# Range of time intervals ---------------------------------------------------
delta <- DeltaMed(
  phi = phi,
  vcov_phi_vec = vcov_phi_vec,
  delta_t = 1:5,
  from = "x",
  to = "y",
  med = "m"
)
plot(delta)




# Methods -------------------------------------------------------------------
# DeltaMed has a number of methods including
# print, summary, confint, and plot
print(delta)
#> 
#> Total, Direct, and Indirect Effects
#> 
#> $`1`
#>          interval     est     se       z      p    2.5%   97.5%
#> total           1 -0.1000 0.0329 -3.0424 0.0023 -0.1645 -0.0356
#> direct          1 -0.2675 0.0436 -6.1280 0.0000 -0.3530 -0.1819
#> indirect        1  0.1674 0.0194  8.6167 0.0000  0.1293  0.2055
#> 
#> $`2`
#>          interval     est     se       z      p    2.5%   97.5%
#> total           2  0.0799 0.0370  2.1603 0.0307  0.0074  0.1524
#> direct          2 -0.3209 0.0512 -6.2642 0.0000 -0.4213 -0.2205
#> indirect        2  0.4008 0.0389 10.3027 0.0000  0.3246  0.4771
#> 
#> $`3`
#>          interval     est     se       z p    2.5%   97.5%
#> total           3  0.2508 0.0366  6.8606 0  0.1792  0.3225
#> direct          3 -0.2914 0.0485 -6.0055 0 -0.3866 -0.1963
#> indirect        3  0.5423 0.0493 11.0007 0  0.4456  0.6389
#> 
#> $`4`
#>          interval     est     se       z p    2.5%   97.5%
#> total           4  0.3449 0.0350  9.8570 0  0.2763  0.4135
#> direct          4 -0.2374 0.0433 -5.4828 0 -0.3223 -0.1525
#> indirect        4  0.5823 0.0548 10.6249 0  0.4749  0.6897
#> 
#> $`5`
#>          interval     est     se       z p    2.5%   97.5%
#> total           5  0.3693 0.0342 10.8008 0  0.3022  0.4363
#> direct          5 -0.1828 0.0376 -4.8614 0 -0.2566 -0.1091
#> indirect        5  0.5521 0.0571  9.6771 0  0.4403  0.6639
#> 
summary(delta)
#>      effect interval        est         se         z            p         2.5%
#> 1     total        1 -0.1000384 0.03288098 -3.042439 2.346691e-03 -0.164483903
#> 2    direct        1 -0.2674539 0.04364490 -6.127952 8.901719e-10 -0.352996324
#> 3  indirect        1  0.1674155 0.01942918  8.616704 6.890881e-18  0.129335016
#> 4     total        2  0.0799008 0.03698524  2.160343 3.074615e-02  0.007411056
#> 5    direct        2 -0.3209035 0.05122836 -6.264177 3.747993e-10 -0.421309236
#> 6  indirect        2  0.4008043 0.03890291 10.302682 6.852356e-25  0.324556004
#> 7     total        3  0.2508138 0.03655859  6.860599 6.857257e-12  0.179160303
#> 8    direct        3 -0.2914426 0.04852944 -6.005480 1.907663e-09 -0.386558557
#> 9  indirect        3  0.5422564 0.04929290 11.000699 3.791795e-28  0.445644109
#> 10    total        4  0.3449279 0.03499303  9.857046 6.390162e-23  0.276342831
#> 11   direct        4 -0.2373900 0.04329747 -5.482768 4.187214e-08 -0.322251508
#> 12 indirect        4  0.5823179 0.05480696 10.624891 2.282791e-26  0.474898266
#> 13    total        5  0.3692538 0.03418778 10.800755 3.413856e-27  0.302246977
#> 14   direct        5 -0.1828447 0.03761138 -4.861420 1.165464e-06 -0.256561662
#> 15 indirect        5  0.5520985 0.05705207  9.677098 3.772724e-22  0.440278497
#>          97.5%
#> 1  -0.03559285
#> 2  -0.18191145
#> 3   0.20549601
#> 4   0.15239055
#> 5  -0.22049777
#> 6   0.47705260
#> 7   0.32246735
#> 8  -0.19632665
#> 9   0.63886875
#> 10  0.41351299
#> 11 -0.15252853
#> 12  0.68973759
#> 13  0.43626060
#> 14 -0.10912777
#> 15  0.66391851
confint(delta, level = 0.95)
#>      effect interval        2.5 %      97.5 %
#> 1     total        1 -0.164483903 -0.03559285
#> 2    direct        1 -0.352996324 -0.18191145
#> 3  indirect        1  0.129335016  0.20549601
#> 4     total        2  0.007411056  0.15239055
#> 5    direct        2 -0.421309236 -0.22049777
#> 6  indirect        2  0.324556004  0.47705260
#> 7     total        3  0.179160303  0.32246735
#> 8    direct        3 -0.386558557 -0.19632665
#> 9  indirect        3  0.445644109  0.63886875
#> 10    total        4  0.276342831  0.41351299
#> 11   direct        4 -0.322251508 -0.15252853
#> 12 indirect        4  0.474898266  0.68973759
#> 13    total        5  0.302246977  0.43626060
#> 14   direct        5 -0.256561662 -0.10912777
#> 15 indirect        5  0.440278497  0.66391851
plot(delta)