Skip to contents

This function generates a posterior distribution of the total effect centrality over a specific time interval \(\Delta t\) or a range of time intervals using the posterior distribution of the first-order stochastic differential equation model drift matrix \(\boldsymbol{\Phi}\).

Usage

PosteriorTotalCentral(phi, delta_t, ncores = NULL)

Arguments

phi

List of numeric matrices. Each element of the list is a sample from the posterior distribution of the drift matrix (\(\boldsymbol{\Phi}\)). Each matrix should have row and column names pertaining to the variables in the system.

delta_t

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

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.

Value

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

call

Function call.

args

Function arguments.

fun

Function used ("PosteriorTotalCentral").

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

Mean of the posterior distribution of the total, direct, and indirect effects.

thetahatstar

Posterior distribution of the total, direct, and indirect effects.

Details

See TotalCentral() for more details.

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
)

phi <- MCPhi(
  phi = phi,
  vcov_phi_vec = vcov_phi_vec,
  R = 1000L
)$output

# Specific time interval ----------------------------------------------------
PosteriorTotalCentral(
  phi = phi,
  delta_t = 1
)
#> 
#> Total Effect Centrality
#> 
#> $`1`
#>   interval     est     se    R    2.5%  97.5%
#> x        1  0.4015 0.0405 1000  0.3245 0.4792
#> m        1  0.4012 0.0344 1000  0.3337 0.4671
#> y        1 -0.0008 0.0377 1000 -0.0769 0.0709
#> 

# Range of time intervals ---------------------------------------------------
posterior <- PosteriorTotalCentral(
  phi = phi,
  delta_t = 1:5
)

# Methods -------------------------------------------------------------------
# PosteriorTotalCentral has a number of methods including
# print, summary, confint, and plot
print(posterior)
#> 
#> Total Effect Centrality
#> 
#> $`1`
#>   interval     est     se    R    2.5%  97.5%
#> x        1  0.4015 0.0405 1000  0.3245 0.4792
#> m        1  0.4012 0.0344 1000  0.3337 0.4671
#> y        1 -0.0008 0.0377 1000 -0.0769 0.0709
#> 
#> $`2`
#>   interval     est     se    R    2.5%  97.5%
#> x        2  0.7324 0.0551 1000  0.6262 0.8409
#> m        2  0.4407 0.0354 1000  0.3704 0.5103
#> y        2 -0.0013 0.0530 1000 -0.1125 0.0991
#> 
#> $`3`
#>   interval     est     se    R    2.5%  97.5%
#> x        3  0.8893 0.0631 1000  0.7726 1.0196
#> m        3  0.3649 0.0363 1000  0.2950 0.4353
#> y        3 -0.0013 0.0569 1000 -0.1200 0.1088
#> 
#> $`4`
#>   interval     est     se    R    2.5%  97.5%
#> x        4  0.9022 0.0685 1000  0.7800 1.0496
#> m        4  0.2698 0.0369 1000  0.1995 0.3464
#> y        4 -0.0010 0.0541 1000 -0.1158 0.1052
#> 
#> $`5`
#>   interval     est     se    R    2.5%  97.5%
#> x        5  0.8270 0.0717 1000  0.7048 0.9929
#> m        5  0.1877 0.0366 1000  0.1184 0.2615
#> y        5 -0.0007 0.0478 1000 -0.0988 0.0918
#> 
summary(posterior)
#>    variable interval           est         se    R        2.5%      97.5%
#> 1         x        1  0.4014562037 0.04052495 1000  0.32445284 0.47922103
#> 2         m        1  0.4012244046 0.03443133 1000  0.33370383 0.46712540
#> 3         y        1 -0.0008203336 0.03765242 1000 -0.07688940 0.07089804
#> 4         x        2  0.7324245835 0.05505442 1000  0.62624950 0.84093970
#> 5         m        2  0.4406701830 0.03540174 1000  0.37040218 0.51033223
#> 6         y        2 -0.0013019510 0.05298059 1000 -0.11254750 0.09907918
#> 7         x        3  0.8893415961 0.06313169 1000  0.77255766 1.01961211
#> 8         m        3  0.3649210827 0.03627488 1000  0.29499602 0.43533267
#> 9         y        3 -0.0012750227 0.05685432 1000 -0.12004014 0.10877113
#> 10        x        4  0.9022245384 0.06851288 1000  0.78002861 1.04956920
#> 11        m        4  0.2697789697 0.03692757 1000  0.19946317 0.34639856
#> 12        y        4 -0.0010186825 0.05408487 1000 -0.11577926 0.10520064
#> 13        x        5  0.8269720110 0.07165792 1000  0.70477096 0.99288511
#> 14        m        5  0.1877401459 0.03657884 1000  0.11840317 0.26153242
#> 15        y        5 -0.0006808998 0.04782257 1000 -0.09879213 0.09180511
confint(posterior, level = 0.95)
#>    variable interval       2.5 %     97.5 %
#> 1         x        1  0.32445284 0.47922103
#> 2         m        1  0.33370383 0.46712540
#> 3         y        1 -0.07688940 0.07089804
#> 4         x        2  0.62624950 0.84093970
#> 5         m        2  0.37040218 0.51033223
#> 6         y        2 -0.11254750 0.09907918
#> 7         x        3  0.77255766 1.01961211
#> 8         m        3  0.29499602 0.43533267
#> 9         y        3 -0.12004014 0.10877113
#> 10        x        4  0.78002861 1.04956920
#> 11        m        4  0.19946317 0.34639856
#> 12        y        4 -0.11577926 0.10520064
#> 13        x        5  0.70477096 0.99288511
#> 14        m        5  0.11840317 0.26153242
#> 15        y        5 -0.09879213 0.09180511
plot(posterior)