Skip to contents

This function computes the delta method sampling variance-covariance matrix for the elements of the matrix of lagged coefficients \(\boldsymbol{\beta}\) 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

DeltaBeta(phi, vcov_phi_vec, delta_t, ncores = NULL, tol = 0.01)

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\)).

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.

tol

Numeric. Smallest possible time interval to allow.

Value

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

call

Function call.

args

Function arguments.

fun

Function used ("DeltaBeta").

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 elements of the matrix of lagged coefficients.

vcov

Sampling variance-covariance matrix of estimated elements of the matrix of lagged coefficients.

Details

See Total().

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.00843, 0.00040, -0.00151,
    -0.00600, -0.00033, 0.00110,
    0.00324, 0.00020, -0.00061,
    0.00040, 0.00374, 0.00016,
    -0.00022, -0.00273, -0.00016,
    0.00009, 0.00150, 0.00012,
    -0.00151, 0.00016, 0.00389,
    0.00103, -0.00007, -0.00283,
    -0.00050, 0.00000, 0.00156,
    -0.00600, -0.00022, 0.00103,
    0.00644, 0.00031, -0.00119,
    -0.00374, -0.00021, 0.00070,
    -0.00033, -0.00273, -0.00007,
    0.00031, 0.00287, 0.00013,
    -0.00014, -0.00170, -0.00012,
    0.00110, -0.00016, -0.00283,
    -0.00119, 0.00013, 0.00297,
    0.00063, -0.00004, -0.00177,
    0.00324, 0.00009, -0.00050,
    -0.00374, -0.00014, 0.00063,
    0.00495, 0.00024, -0.00093,
    0.00020, 0.00150, 0.00000,
    -0.00021, -0.00170, -0.00004,
    0.00024, 0.00214, 0.00012,
    -0.00061, 0.00012, 0.00156,
    0.00070, -0.00012, -0.00177,
    -0.00093, 0.00012, 0.00223
  ),
  nrow = 9
)

# Specific time interval ----------------------------------------------------
DeltaBeta(
  phi = phi,
  vcov_phi_vec = vcov_phi_vec,
  delta_t = 1
)
#> 
#> Elements of the matrix of lagged coefficients
#> 
#> $`1`
#>             interval     est     se       z      p    2.5%   97.5%
#> from x to x        1  0.6998 0.0471 14.8688 0.0000  0.6075  0.7920
#> from x to m        1  0.5000 0.0352 14.1965 0.0000  0.4310  0.5691
#> from x to y        1 -0.1000 0.0306 -3.2703 0.0011 -0.1600 -0.0401
#> from m to x        1  0.0000 0.0435  0.0000 1.0000 -0.0852  0.0852
#> from m to m        1  0.5999 0.0326 18.3826 0.0000  0.5359  0.6639
#> from m to y        1  0.3998 0.0284 14.0593 0.0000  0.3441  0.4556
#> from y to x        1  0.0000 0.0418  0.0000 1.0000 -0.0820  0.0820
#> from y to m        1  0.0000 0.0311  0.0000 1.0000 -0.0609  0.0609
#> from y to y        1  0.5001 0.0274 18.2776 0.0000  0.4464  0.5537
#> 

# Range of time intervals ---------------------------------------------------
delta <- DeltaBeta(
  phi = phi,
  vcov_phi_vec = vcov_phi_vec,
  delta_t = 1:5
)
plot(delta)










# Methods -------------------------------------------------------------------
# DeltaBeta has a number of methods including
# print, summary, confint, and plot
print(delta)
#> 
#> Elements of the matrix of lagged coefficients
#> 
#> $`1`
#>             interval     est     se       z      p    2.5%   97.5%
#> from x to x        1  0.6998 0.0471 14.8688 0.0000  0.6075  0.7920
#> from x to m        1  0.5000 0.0352 14.1965 0.0000  0.4310  0.5691
#> from x to y        1 -0.1000 0.0306 -3.2703 0.0011 -0.1600 -0.0401
#> from m to x        1  0.0000 0.0435  0.0000 1.0000 -0.0852  0.0852
#> from m to m        1  0.5999 0.0326 18.3826 0.0000  0.5359  0.6639
#> from m to y        1  0.3998 0.0284 14.0593 0.0000  0.3441  0.4556
#> from y to x        1  0.0000 0.0418  0.0000 1.0000 -0.0820  0.0820
#> from y to m        1  0.0000 0.0311  0.0000 1.0000 -0.0609  0.0609
#> from y to y        1  0.5001 0.0274 18.2776 0.0000  0.4464  0.5537
#> 
#> $`2`
#>             interval    est     se       z      p    2.5%  97.5%
#> from x to x        2 0.4897 0.0548  8.9377 0.0000  0.3823 0.5971
#> from x to m        2 0.6499 0.0537 12.1023 0.0000  0.5446 0.7551
#> from x to y        2 0.0799 0.0342  2.3337 0.0196  0.0128 0.1470
#> from m to x        2 0.0000 0.0513  0.0000 1.0000 -0.1006 0.1006
#> from m to m        2 0.3599 0.0504  7.1405 0.0000  0.2611 0.4587
#> from m to y        2 0.4398 0.0324 13.5818 0.0000  0.3763 0.5033
#> from y to x        2 0.0000 0.0502  0.0000 1.0000 -0.0983 0.0983
#> from y to m        2 0.0000 0.0493  0.0000 1.0000 -0.0967 0.0967
#> from y to y        2 0.2501 0.0318  7.8668 0.0000  0.1878 0.3124
#> 
#> $`3`
#>             interval    est     se       z     p    2.5%  97.5%
#> from x to x        3 0.3427 0.0546  6.2779 0e+00  0.2357 0.4496
#> from x to m        3 0.6347 0.0653  9.7126 0e+00  0.5066 0.7628
#> from x to y        3 0.2508 0.0353  7.1106 0e+00  0.1817 0.3199
#> from m to x        3 0.0000 0.0498  0.0000 1e+00 -0.0976 0.0976
#> from m to m        3 0.2159 0.0609  3.5452 4e-04  0.0965 0.3352
#> from m to y        3 0.3638 0.0325 11.1960 0e+00  0.3001 0.4275
#> from y to x        3 0.0000 0.0456  0.0000 1e+00 -0.0893 0.0893
#> from y to m        3 0.0000 0.0587  0.0000 1e+00 -0.1151 0.1151
#> from y to y        3 0.1251 0.0299  4.1799 0e+00  0.0664 0.1837
#> 
#> $`4`
#>             interval    est     se      z      p    2.5%  97.5%
#> from x to x        4 0.2398 0.0536 4.4747 0.0000  0.1348 0.3448
#> from x to m        4 0.5521 0.0717 7.7014 0.0000  0.4116 0.6926
#> from x to y        4 0.3449 0.0394 8.7512 0.0000  0.2677 0.4222
#> from m to x        4 0.0000 0.0456 0.0000 1.0000 -0.0894 0.0894
#> from m to m        4 0.1295 0.0650 1.9937 0.0462  0.0022 0.2568
#> from m to y        4 0.2683 0.0350 7.6627 0.0000  0.1996 0.3369
#> from y to x        4 0.0000 0.0371 0.0000 1.0000 -0.0727 0.0727
#> from y to m        4 0.0000 0.0599 0.0000 1.0000 -0.1174 0.1174
#> from y to y        4 0.0625 0.0310 2.0161 0.0438  0.0017 0.1233
#> 
#> $`5`
#>             interval    est     se      z      p    2.5%  97.5%
#> from x to x        5 0.1678 0.0527 3.1821 0.0015  0.0644 0.2712
#> from x to m        5 0.4511 0.0749 6.0254 0.0000  0.3044 0.5978
#> from x to y        5 0.3693 0.0441 8.3649 0.0000  0.2827 0.4558
#> from m to x        5 0.0000 0.0401 0.0000 1.0000 -0.0786 0.0786
#> from m to m        5 0.0777 0.0642 1.2092 0.2266 -0.0482 0.2036
#> from m to y        5 0.1859 0.0381 4.8780 0.0000  0.1112 0.2606
#> from y to x        5 0.0000 0.0286 0.0000 1.0000 -0.0560 0.0560
#> from y to m        5 0.0000 0.0554 0.0000 1.0000 -0.1086 0.1086
#> from y to y        5 0.0313 0.0341 0.9180 0.3586 -0.0355 0.0980
#> 
summary(delta)
#>         effect interval         est         se         z            p
#> 1  from x to x        1  0.69977250 0.04706304 14.868833 5.252120e-50
#> 2  from x to m        1  0.50003412 0.03522246 14.196456 9.636357e-46
#> 3  from x to y        1 -0.10003837 0.03059043 -3.270250 1.074523e-03
#> 4  from m to x        1  0.00000000 0.04346035  0.000000 1.000000e+00
#> 5  from m to m        1  0.59989538 0.03263394 18.382559 1.812145e-75
#> 6  from m to y        1  0.39983562 0.02843922 14.059305 6.754616e-45
#> 7  from y to x        1  0.00000000 0.04181566  0.000000 1.000000e+00
#> 8  from y to m        1  0.00000000 0.03106890  0.000000 1.000000e+00
#> 9  from y to y        1  0.50007360 0.02735991 18.277603 1.247910e-74
#> 10 from x to x        2  0.48968155 0.05478810  8.937735 3.972267e-19
#> 11 from x to m        2  0.64987829 0.05369863 12.102325 1.026621e-33
#> 12 from x to y        2  0.07990080 0.03423772  2.333707 1.961107e-02
#> 13 from m to x        2  0.00000000 0.05133834  0.000000 1.000000e+00
#> 14 from m to m        2  0.35987447 0.05039929  7.140467 9.301408e-13
#> 15 from m to y        2  0.43980678 0.03238198 13.581835 5.132412e-42
#> 16 from y to x        2  0.00000000 0.05017236  0.000000 1.000000e+00
#> 17 from y to m        2  0.00000000 0.04933966  0.000000 1.000000e+00
#> 18 from y to y        2  0.25007360 0.03178830  7.866843 3.637020e-15
#> 19 from x to x        3  0.34266568 0.05458246  6.277945 3.430781e-10
#> 20 from x to m        3  0.63471647 0.06534988  9.712588 2.664838e-22
#> 21 from x to y        3  0.25081383 0.03527306  7.110634 1.155108e-12
#> 22 from m to x        3  0.00000000 0.04982130  0.000000 1.000000e+00
#> 23 from m to m        3  0.21588703 0.06089478  3.545247 3.922457e-04
#> 24 from m to y        3  0.36382639 0.03249624 11.195955 4.267787e-29
#> 25 from y to x        3  0.00000000 0.04556623  0.000000 1.000000e+00
#> 26 from y to m        3  0.00000000 0.05873679  0.000000 1.000000e+00
#> 27 from y to y        3  0.12505520 0.02991799  4.179933 2.915945e-05
#> 28 from x to x        4  0.23978802 0.05358737  4.474711 7.651461e-06
#> 29 from x to m        4  0.55210801 0.07168886  7.701448 1.345328e-14
#> 30 from x to y        4  0.34492791 0.03941513  8.751155 2.111808e-18
#> 31 from m to x        4  0.00000000 0.04561260  0.000000 1.000000e+00
#> 32 from m to m        4  0.12950963 0.06495896  1.993715 4.618325e-02
#> 33 from m to y        4  0.26825930 0.03500840  7.662712 1.820476e-14
#> 34 from y to x        4  0.00000000 0.03711526  0.000000 1.000000e+00
#> 35 from y to m        4  0.00000000 0.05991073  0.000000 1.000000e+00
#> 36 from y to y        4  0.06253681 0.03101888  2.016088 4.379072e-02
#> 37 from x to x        5  0.16779706 0.05273210  3.182067 1.462281e-03
#> 38 from x to m        5  0.45110924 0.07486738  6.025445 1.686454e-09
#> 39 from x to y        5  0.36925379 0.04414319  8.364909 6.016140e-17
#> 40 from m to x        5  0.00000000 0.04011151  0.000000 1.000000e+00
#> 41 from m to m        5  0.07769223 0.06424869  1.209242 2.265698e-01
#> 42 from m to y        5  0.18593196 0.03811640  4.878004 1.071646e-06
#> 43 from y to x        5  0.00000000 0.02858726  0.000000 1.000000e+00
#> 44 from y to m        5  0.00000000 0.05541699  0.000000 1.000000e+00
#> 45 from y to y        5  0.03127301 0.03406623  0.918006 3.586157e-01
#>            2.5%       97.5%
#> 1   0.607530630  0.79201437
#> 2   0.430999370  0.56906888
#> 3  -0.159994521 -0.04008223
#> 4  -0.085180722  0.08518072
#> 5   0.535934031  0.66385674
#> 6   0.344095782  0.45557546
#> 7  -0.081957196  0.08195720
#> 8  -0.060893928  0.06089393
#> 9   0.446449155  0.55369804
#> 10  0.382298845  0.59706425
#> 11  0.544630905  0.75512568
#> 12  0.012796105  0.14700550
#> 13 -0.100621301  0.10062130
#> 14  0.261093683  0.45865526
#> 15  0.376339257  0.50327430
#> 16 -0.098336021  0.09833602
#> 17 -0.096703960  0.09670396
#> 18  0.187769671  0.31237753
#> 19  0.235686018  0.44964534
#> 20  0.506633055  0.76279989
#> 21  0.181679901  0.31994775
#> 22 -0.097647963  0.09764796
#> 23  0.096535451  0.33523862
#> 24  0.300134940  0.42751784
#> 25 -0.089308174  0.08930817
#> 26 -0.115121991  0.11512199
#> 27  0.066417023  0.18369339
#> 28  0.134758701  0.34481734
#> 29  0.411600436  0.69261559
#> 30  0.267675671  0.42218015
#> 31 -0.089399053  0.08939905
#> 32  0.002192406  0.25682686
#> 33  0.199644090  0.33687451
#> 34 -0.072744578  0.07274458
#> 35 -0.117422876  0.11742288
#> 36  0.001740919  0.12333269
#> 37  0.064444048  0.27115007
#> 38  0.304371874  0.59784661
#> 39  0.282734719  0.45577286
#> 40 -0.078617114  0.07861711
#> 41 -0.048232879  0.20361734
#> 42  0.111225188  0.26063873
#> 43 -0.056029996  0.05603000
#> 44 -0.108615295  0.10861530
#> 45 -0.035495583  0.09804159
confint(delta, level = 0.95)
#>         effect interval        2.5 %      97.5 %
#> 1  from x to x        1  0.607530630  0.79201437
#> 2  from x to m        1  0.430999370  0.56906888
#> 3  from x to y        1 -0.159994521 -0.04008223
#> 4  from m to x        1 -0.085180722  0.08518072
#> 5  from m to m        1  0.535934031  0.66385674
#> 6  from m to y        1  0.344095782  0.45557546
#> 7  from y to x        1 -0.081957196  0.08195720
#> 8  from y to m        1 -0.060893928  0.06089393
#> 9  from y to y        1  0.446449155  0.55369804
#> 10 from x to x        2  0.382298845  0.59706425
#> 11 from x to m        2  0.544630905  0.75512568
#> 12 from x to y        2  0.012796105  0.14700550
#> 13 from m to x        2 -0.100621301  0.10062130
#> 14 from m to m        2  0.261093683  0.45865526
#> 15 from m to y        2  0.376339257  0.50327430
#> 16 from y to x        2 -0.098336021  0.09833602
#> 17 from y to m        2 -0.096703960  0.09670396
#> 18 from y to y        2  0.187769671  0.31237753
#> 19 from x to x        3  0.235686018  0.44964534
#> 20 from x to m        3  0.506633055  0.76279989
#> 21 from x to y        3  0.181679901  0.31994775
#> 22 from m to x        3 -0.097647963  0.09764796
#> 23 from m to m        3  0.096535451  0.33523862
#> 24 from m to y        3  0.300134940  0.42751784
#> 25 from y to x        3 -0.089308174  0.08930817
#> 26 from y to m        3 -0.115121991  0.11512199
#> 27 from y to y        3  0.066417023  0.18369339
#> 28 from x to x        4  0.134758701  0.34481734
#> 29 from x to m        4  0.411600436  0.69261559
#> 30 from x to y        4  0.267675671  0.42218015
#> 31 from m to x        4 -0.089399053  0.08939905
#> 32 from m to m        4  0.002192406  0.25682686
#> 33 from m to y        4  0.199644090  0.33687451
#> 34 from y to x        4 -0.072744578  0.07274458
#> 35 from y to m        4 -0.117422876  0.11742288
#> 36 from y to y        4  0.001740919  0.12333269
#> 37 from x to x        5  0.064444048  0.27115007
#> 38 from x to m        5  0.304371874  0.59784661
#> 39 from x to y        5  0.282734719  0.45577286
#> 40 from m to x        5 -0.078617114  0.07861711
#> 41 from m to m        5 -0.048232879  0.20361734
#> 42 from m to y        5  0.111225188  0.26063873
#> 43 from y to x        5 -0.056029996  0.05603000
#> 44 from y to m        5 -0.108615295  0.10861530
#> 45 from y to y        5 -0.035495583  0.09804159
plot(delta)