Skip to contents

This function generates a Monte Carlo method sampling distribution of the total effect centrality at a particular time interval \(\Delta t\) using the first-order stochastic differential equation model drift matrix \(\boldsymbol{\Phi}\).

Usage

MCTotalCentral(
  phi,
  vcov_phi_vec,
  delta_t,
  R,
  test_phi = TRUE,
  ncores = NULL,
  seed = 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

Numeric. Time interval (\(\Delta t\)).

R

Positive integer. Number of replications.

test_phi

Logical. If test_phi = TRUE, the function tests the stability of the generated drift matrix \(\boldsymbol{\Phi}\). If the test returns FALSE, the function generates a new drift matrix \(\boldsymbol{\Phi}\) and runs the test recursively until the test returns TRUE.

ncores

Positive integer. Number of cores to use. If ncores = NULL, use a single core. Consider using multiple cores when number of replications R is a large value.

seed

Random seed.

Value

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

call

Function call.

args

Function arguments.

fun

Function used ("MCTotalCentral").

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:

est

A vector of total effect centrality.

thetahatstar

A matrix of Monte Carlo total effect centrality.

Details

See TotalCentral() for more details.

Monte Carlo 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)\). Based on the asymptotic properties of maximum likelihood estimators, we can assume that estimators are normally distributed around the population parameters. $$ \hat{\boldsymbol{\theta}} \sim \mathcal{N} \left( \boldsymbol{\theta}, \mathbb{V} \left( \hat{\boldsymbol{\theta}} \right) \right) $$ Using this distributional assumption, a sampling distribution of \(\hat{\boldsymbol{\theta}}\) which we refer to as \(\hat{\boldsymbol{\theta}}^{\ast}\) can be generated by replacing the population parameters with sample estimates, that is, $$ \hat{\boldsymbol{\theta}}^{\ast} \sim \mathcal{N} \left( \hat{\boldsymbol{\theta}}, \hat{\mathbb{V}} \left( \hat{\boldsymbol{\theta}} \right) \right) . $$ Let \(\mathbf{g} \left( \hat{\boldsymbol{\theta}} \right)\) be a parameter that is a function of the estimated parameters. A sampling distribution of \(\mathbf{g} \left( \hat{\boldsymbol{\theta}} \right)\) , which we refer to as \(\mathbf{g} \left( \hat{\boldsymbol{\theta}}^{\ast} \right)\) , can be generated by using the simulated estimates to calculate \(\mathbf{g}\). The standard deviations of the simulated estimates are the standard errors. Percentiles corresponding to \(100 \left( 1 - \alpha \right) \%\) are the confidence intervals.

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

set.seed(42)
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 ----------------------------------------------------
MCTotalCentral(
  phi = phi,
  vcov_phi_vec = vcov_phi_vec,
  delta_t = 1,
  R = 100L # use a large value for R in actual research
)
#> 
#> Total Effect Centrality
#> 
#> $`1`
#>   interval    est     se   R    2.5%  97.5%
#> x        1 0.4000 0.0460 100  0.3107 0.4886
#> m        1 0.3998 0.0336 100  0.3295 0.4655
#> y        1 0.0000 0.0368 100 -0.0705 0.0692
#> 

# Range of time intervals ---------------------------------------------------
mc <- MCTotalCentral(
  phi = phi,
  vcov_phi_vec = vcov_phi_vec,
  delta_t = 1:5,
  R = 100L # use a large value for R in actual research
)
plot(mc)




# Methods -------------------------------------------------------------------
# MCTotalCentral has a number of methods including
# print, summary, confint, and plot
print(mc)
#> 
#> Total Effect Centrality
#> 
#> $`1`
#>   interval    est     se   R    2.5%  97.5%
#> x        1 0.4000 0.0394 100  0.3279 0.4814
#> m        1 0.3998 0.0334 100  0.3173 0.4534
#> y        1 0.0000 0.0378 100 -0.0646 0.0758
#> 
#> $`2`
#>   interval    est     se   R    2.5%  97.5%
#> x        2 0.7298 0.0536 100  0.6181 0.8266
#> m        2 0.4398 0.0319 100  0.3671 0.4868
#> y        2 0.0000 0.0516 100 -0.0912 0.0938
#> 
#> $`3`
#>   interval    est     se   R    2.5%  97.5%
#> x        3 0.8855 0.0622 100  0.7756 0.9970
#> m        3 0.3638 0.0318 100  0.2994 0.4177
#> y        3 0.0000 0.0541 100 -0.1010 0.0949
#> 
#> $`4`
#>   interval    est     se   R    2.5%  97.5%
#> x        4 0.8970 0.0687 100  0.7762 1.0521
#> m        4 0.2683 0.0336 100  0.2003 0.3305
#> y        4 0.0000 0.0507 100 -0.0947 0.0917
#> 
#> $`5`
#>   interval    est     se   R    2.5%  97.5%
#> x        5 0.8204 0.0735 100  0.7120 1.0093
#> m        5 0.1859 0.0347 100  0.1227 0.2550
#> y        5 0.0000 0.0444 100 -0.0835 0.0812
#> 
summary(mc)
#>    variable interval       est         se   R        2.5%      97.5%
#> 1         x        1 0.3999957 0.03939299 100  0.32793232 0.48139051
#> 2         m        1 0.3998356 0.03335379 100  0.31725441 0.45344808
#> 3         y        1 0.0000000 0.03776644 100 -0.06459924 0.07584911
#> 4         x        2 0.7297791 0.05361468 100  0.61810182 0.82661873
#> 5         m        2 0.4398068 0.03193405 100  0.36713308 0.48684851
#> 6         y        2 0.0000000 0.05155762 100 -0.09115130 0.09378980
#> 7         x        3 0.8855303 0.06216891 100  0.77557823 0.99704825
#> 8         m        3 0.3638264 0.03179050 100  0.29936757 0.41767664
#> 9         y        3 0.0000000 0.05408646 100 -0.10095209 0.09492716
#> 10        x        4 0.8970359 0.06872467 100  0.77620081 1.05207254
#> 11        m        4 0.2682593 0.03355110 100  0.20030793 0.33054800
#> 12        y        4 0.0000000 0.05068041 100 -0.09470587 0.09169483
#> 13        x        5 0.8203630 0.07351557 100  0.71195683 1.00933616
#> 14        m        5 0.1859320 0.03474112 100  0.12268216 0.25501048
#> 15        y        5 0.0000000 0.04442033 100 -0.08351493 0.08115569
confint(mc, level = 0.95)
#>    variable interval       2.5 %     97.5 %
#> 1         x        1  0.32793232 0.48139051
#> 2         m        1  0.31725441 0.45344808
#> 3         y        1 -0.06459924 0.07584911
#> 4         x        2  0.61810182 0.82661873
#> 5         m        2  0.36713308 0.48684851
#> 6         y        2 -0.09115130 0.09378980
#> 7         x        3  0.77557823 0.99704825
#> 8         m        3  0.29936757 0.41767664
#> 9         y        3 -0.10095209 0.09492716
#> 10        x        4  0.77620081 1.05207254
#> 11        m        4  0.20030793 0.33054800
#> 12        y        4 -0.09470587 0.09169483
#> 13        x        5  0.71195683 1.00933616
#> 14        m        5  0.12268216 0.25501048
#> 15        y        5 -0.08351493 0.08115569
plot(mc)