Bootstrap Sampling Distribution for the Total Effect Centrality Over a Specific Time Interval or a Range of Time Intervals
Source:R/cTMed-boot-total-central.R
BootTotalCentral.Rd
This function generates a bootstrap method sampling distribution for the total effect centrality over a specific time interval \(\Delta t\) or a range of time intervals using the first-order stochastic differential equation model drift matrix \(\boldsymbol{\Phi}\).
Arguments
- phi
List of numeric matrices. Each element of the list is a bootstrap estimate of the drift matrix (\(\boldsymbol{\Phi}\)).
- phi_hat
Numeric matrix. The estimated drift matrix (\(\hat{\boldsymbol{\Phi}}\)) from the original data set.
phi_hat
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 replicationsR
is a large value.- tol
Numeric. Smallest possible time interval to allow.
Value
Returns an object
of class ctmedboot
which is a list with the following elements:
- call
Function call.
- args
Function arguments.
- fun
Function used ("BootTotalCentral").
- output
A list with length of
length(delta_t)
.
Each element in the output
list has the following elements:
- est
A vector of total effect centrality.
- thetahatstar
A matrix of bootstrap total effect centrality.
Details
See TotalCentral()
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
See also
Other Continuous Time Mediation Functions:
BootBeta()
,
BootBetaStd()
,
BootIndirectCentral()
,
BootMed()
,
BootMedStd()
,
DeltaBeta()
,
DeltaBetaStd()
,
DeltaIndirectCentral()
,
DeltaMed()
,
DeltaMedStd()
,
DeltaTotalCentral()
,
Direct()
,
DirectStd()
,
Indirect()
,
IndirectCentral()
,
IndirectStd()
,
MCBeta()
,
MCBetaStd()
,
MCIndirectCentral()
,
MCMed()
,
MCMedStd()
,
MCPhi()
,
MCPhiSigma()
,
MCTotalCentral()
,
Med()
,
MedStd()
,
PosteriorBeta()
,
PosteriorIndirectCentral()
,
PosteriorMed()
,
PosteriorTotalCentral()
,
Total()
,
TotalCentral()
,
TotalStd()
,
Trajectory()
Examples
# \donttest{
library(bootStateSpace)
# prepare parameters
## number of individuals
n <- 50
## time points
time <- 100
delta_t <- 0.10
## dynamic structure
p <- 3
mu0 <- rep(x = 0, times = p)
sigma0 <- matrix(
data = c(
1.0,
0.2,
0.2,
0.2,
1.0,
0.2,
0.2,
0.2,
1.0
),
nrow = p
)
sigma0_l <- t(chol(sigma0))
mu <- rep(x = 0, times = p)
phi <- matrix(
data = c(
-0.357,
0.771,
-0.450,
0.0,
-0.511,
0.729,
0,
0,
-0.693
),
nrow = p
)
sigma <- matrix(
data = c(
0.24455556,
0.02201587,
-0.05004762,
0.02201587,
0.07067800,
0.01539456,
-0.05004762,
0.01539456,
0.07553061
),
nrow = p
)
sigma_l <- t(chol(sigma))
## measurement model
k <- 3
nu <- rep(x = 0, times = k)
lambda <- diag(k)
theta <- 0.2 * diag(k)
theta_l <- t(chol(theta))
boot <- PBSSMOUFixed(
R = 10L, # use at least 1000 in actual research
path = getwd(),
prefix = "ou",
n = n,
time = time,
delta_t = delta_t,
mu0 = mu0,
sigma0_l = sigma0_l,
mu = mu,
phi = phi,
sigma_l = sigma_l,
nu = nu,
lambda = lambda,
theta_l = theta_l,
ncores = NULL, # consider using multiple cores
seed = 42
)
phi_hat <- phi
colnames(phi_hat) <- rownames(phi_hat) <- c("x", "m", "y")
phi <- extract(object = boot, what = "phi")
# Specific time interval ----------------------------------------------------
BootTotalCentral(
phi = phi,
phi_hat = phi_hat,
delta_t = 1
)
#>
#> Total Effect Centrality
#> type = pc
#> $`1`
#> interval est se R 2.5% 97.5%
#> x 1 0.4000 0.0230 10 0.3655 0.4264
#> m 1 0.3998 0.0477 10 0.3466 0.4918
#> y 1 0.0000 0.0589 10 -0.1013 0.0613
#>
# Range of time intervals ---------------------------------------------------
boot <- BootTotalCentral(
phi = phi,
phi_hat = phi_hat,
delta_t = 1:5
)
plot(boot)
plot(boot, type = "bc") # bias-corrected
# Methods -------------------------------------------------------------------
# BootTotalCentral has a number of methods including
# print, summary, confint, and plot
print(boot)
#>
#> Total Effect Centrality
#> type = pc
#> $`1`
#> interval est se R 2.5% 97.5%
#> x 1 0.4000 0.0230 10 0.3655 0.4264
#> m 1 0.3998 0.0477 10 0.3466 0.4918
#> y 1 0.0000 0.0589 10 -0.1013 0.0613
#>
#> $`2`
#> interval est se R 2.5% 97.5%
#> x 2 0.7298 0.0394 10 0.6503 0.7728
#> m 2 0.4398 0.0540 10 0.3823 0.5412
#> y 2 0.0000 0.0874 10 -0.1553 0.0890
#>
#> $`3`
#> interval est se R 2.5% 97.5%
#> x 3 0.8855 0.0584 10 0.7695 0.9410
#> m 3 0.3638 0.0556 10 0.3091 0.4702
#> y 3 0.0000 0.0963 10 -0.1756 0.1031
#>
#> $`4`
#> interval est se R 2.5% 97.5%
#> x 4 0.8970 0.0772 10 0.7551 0.9984
#> m 4 0.2683 0.0552 10 0.2212 0.3732
#> y 4 0.0000 0.0933 10 -0.1740 0.1013
#>
#> $`5`
#> interval est se R 2.5% 97.5%
#> x 5 0.8204 0.0922 10 0.6677 0.9650
#> m 5 0.1859 0.0522 10 0.1407 0.2809
#> y 5 0.0000 0.0837 10 -0.1596 0.0905
#>
summary(boot)
#> variable interval est se R 2.5% 97.5%
#> 1 x 1 0.3999957 0.02296759 10 0.3654829 0.42636204
#> 2 m 1 0.3998356 0.04772231 10 0.3465982 0.49180449
#> 3 y 1 0.0000000 0.05893594 10 -0.1013119 0.06128272
#> 4 x 2 0.7297791 0.03935772 10 0.6503308 0.77278373
#> 5 m 2 0.4398068 0.05403270 10 0.3823457 0.54118215
#> 6 y 2 0.0000000 0.08740366 10 -0.1553369 0.08899969
#> 7 x 3 0.8855303 0.05837274 10 0.7695357 0.94098257
#> 8 m 3 0.3638264 0.05562599 10 0.3091364 0.47021113
#> 9 y 3 0.0000000 0.09632624 10 -0.1755898 0.10308311
#> 10 x 4 0.8970359 0.07715246 10 0.7551021 0.99841198
#> 11 m 4 0.2682593 0.05517596 10 0.2211691 0.37320330
#> 12 y 4 0.0000000 0.09327282 10 -0.1739915 0.10128918
#> 13 x 5 0.8203630 0.09219479 10 0.6677285 0.96497207
#> 14 m 5 0.1859320 0.05222735 10 0.1407348 0.28089102
#> 15 y 5 0.0000000 0.08374104 10 -0.1596274 0.09052208
confint(boot, level = 0.95)
#> variable interval 2.5 % 97.5 %
#> 1 x 1 0.3654829 0.42636204
#> 2 m 1 0.3465982 0.49180449
#> 3 y 1 -0.1013119 0.06128272
#> 4 x 2 0.6503308 0.77278373
#> 5 m 2 0.3823457 0.54118215
#> 6 y 2 -0.1553369 0.08899969
#> 7 x 3 0.7695357 0.94098257
#> 8 m 3 0.3091364 0.47021113
#> 9 y 3 -0.1755898 0.10308311
#> 10 x 4 0.7551021 0.99841198
#> 11 m 4 0.2211691 0.37320330
#> 12 y 4 -0.1739915 0.10128918
#> 13 x 5 0.6677285 0.96497207
#> 14 m 5 0.1407348 0.28089102
#> 15 y 5 -0.1596274 0.09052208
print(boot, type = "bc") # bias-corrected
#>
#> Total Effect Centrality
#> type = bc
#> $`1`
#> interval est se R 2.5% 97.5%
#> x 1 0.4000 0.0230 10 0.3713 0.4282
#> m 1 0.3998 0.0477 10 0.3466 0.4918
#> y 1 0.0000 0.0589 10 -0.1013 0.0613
#>
#> $`2`
#> interval est se R 2.5% 97.5%
#> x 2 0.7298 0.0394 10 0.6881 0.7794
#> m 2 0.4398 0.0540 10 0.3768 0.5391
#> y 2 0.0000 0.0874 10 -0.1553 0.0890
#>
#> $`3`
#> interval est se R 2.5% 97.5%
#> x 3 0.8855 0.0584 10 0.7534 0.9384
#> m 3 0.3638 0.0556 10 0.3056 0.4642
#> y 3 0.0000 0.0963 10 -0.1756 0.1031
#>
#> $`4`
#> interval est se R 2.5% 97.5%
#> x 4 0.8970 0.0772 10 0.7251 0.9572
#> m 4 0.2683 0.0552 10 0.2191 0.3633
#> y 4 0.0000 0.0933 10 -0.1740 0.1013
#>
#> $`5`
#> interval est se R 2.5% 97.5%
#> x 5 0.8204 0.0922 10 0.6313 0.8943
#> m 5 0.1859 0.0522 10 0.1407 0.2809
#> y 5 0.0000 0.0837 10 -0.1596 0.0905
#>
summary(boot, type = "bc")
#> variable interval est se R 2.5% 97.5%
#> 1 x 1 0.3999957 0.02296759 10 0.3712508 0.42824588
#> 2 m 1 0.3998356 0.04772231 10 0.3465982 0.49180449
#> 3 y 1 0.0000000 0.05893594 10 -0.1013119 0.06128272
#> 4 x 2 0.7297791 0.03935772 10 0.6881137 0.77938396
#> 5 m 2 0.4398068 0.05403270 10 0.3768249 0.53905183
#> 6 y 2 0.0000000 0.08740366 10 -0.1553369 0.08899969
#> 7 x 3 0.8855303 0.05837274 10 0.7534480 0.93837943
#> 8 m 3 0.3638264 0.05562599 10 0.3055505 0.46424140
#> 9 y 3 0.0000000 0.09632624 10 -0.1755898 0.10308311
#> 10 x 4 0.8970359 0.07715246 10 0.7250552 0.95717611
#> 11 m 4 0.2682593 0.05517596 10 0.2191289 0.36332567
#> 12 y 4 0.0000000 0.09327282 10 -0.1739915 0.10128918
#> 13 x 5 0.8203630 0.09219479 10 0.6312856 0.89432498
#> 14 m 5 0.1859320 0.05222735 10 0.1407348 0.28089102
#> 15 y 5 0.0000000 0.08374104 10 -0.1596274 0.09052208
confint(boot, level = 0.95, type = "bc")
#> variable interval 2.5 % 97.5 %
#> 1 x 1 0.3712508 0.42824588
#> 2 m 1 0.3465982 0.49180449
#> 3 y 1 -0.1013119 0.06128272
#> 4 x 2 0.6881137 0.77938396
#> 5 m 2 0.3768249 0.53905183
#> 6 y 2 -0.1553369 0.08899969
#> 7 x 3 0.7534480 0.93837943
#> 8 m 3 0.3055505 0.46424140
#> 9 y 3 -0.1755898 0.10308311
#> 10 x 4 0.7250552 0.95717611
#> 11 m 4 0.2191289 0.36332567
#> 12 y 4 -0.1739915 0.10128918
#> 13 x 5 0.6312856 0.89432498
#> 14 m 5 0.1407348 0.28089102
#> 15 y 5 -0.1596274 0.09052208
# }