Bootstrap Sampling Distribution for the Elements of the Standardized Matrix of Lagged Coefficients Over a Specific Time Interval or a Range of Time Intervals
Source:R/cTMed-boot-beta-std.R
BootBetaStd.Rd
This function generates a bootstrap method sampling distribution for the elements of the standardized 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 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}\)).
- sigma
List of numeric matrices. Each element of the list is a bootstrap estimate of the process noise covariance matrix (\(\boldsymbol{\Sigma}\)).
- 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.- sigma_hat
Numeric matrix. The estimated process noise covariance matrix (\(\hat{\boldsymbol{\Sigma}}\)) from the original data set.
- 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 ("BootBetaStd").
- output
A list with length of
length(delta_t)
.
Each element in the output
list has the following elements:
- est
Estimated elements of the standardized matrix of lagged coefficients.
- thetahatstar
A matrix of bootstrap elements of the standardized matrix of lagged coefficients.
Details
See TotalStd()
.
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()
,
BootIndirectCentral()
,
BootMed()
,
BootMedStd()
,
BootTotalCentral()
,
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")
sigma_hat <- sigma
phi <- extract(object = boot, what = "phi")
sigma <- extract(object = boot, what = "sigma")
# Specific time interval ----------------------------------------------------
BootBetaStd(
phi = phi,
sigma = sigma,
phi_hat = phi_hat,
sigma_hat = sigma_hat,
delta_t = 1
)
#>
#> Total, Direct, and Indirect Effects
#> type = pc
#> $`1`
#> interval est se R 2.5% 97.5%
#> from x to x 1 0.6998 0.0462 10 0.6266 0.7449
#> from x to m 1 0.3888 0.0195 10 0.3519 0.4120
#> from x to y 1 -0.1069 0.0146 10 -0.1388 -0.0966
#> from m to x 1 0.0000 0.0607 10 -0.0633 0.1097
#> from m to m 1 0.5999 0.0277 10 0.5667 0.6537
#> from m to y 1 0.5494 0.0196 10 0.5280 0.5823
#> from y to x 1 0.0000 0.0379 10 -0.0687 0.0476
#> from y to m 1 0.0000 0.0200 10 -0.0264 0.0323
#> from y to y 1 0.5001 0.0157 10 0.4886 0.5323
#>
# Range of time intervals ---------------------------------------------------
boot <- BootBetaStd(
phi = phi,
sigma = sigma,
phi_hat = phi_hat,
sigma_hat = sigma_hat,
delta_t = 1:5
)
plot(boot)
plot(boot, type = "bc") # bias-corrected
# Methods -------------------------------------------------------------------
# BootBetaStd has a number of methods including
# print, summary, confint, and plot
print(boot)
#>
#> Total, Direct, and Indirect Effects
#> type = pc
#> $`1`
#> interval est se R 2.5% 97.5%
#> from x to x 1 0.6998 0.0462 10 0.6266 0.7449
#> from x to m 1 0.3888 0.0195 10 0.3519 0.4120
#> from x to y 1 -0.1069 0.0146 10 -0.1388 -0.0966
#> from m to x 1 0.0000 0.0607 10 -0.0633 0.1097
#> from m to m 1 0.5999 0.0277 10 0.5667 0.6537
#> from m to y 1 0.5494 0.0196 10 0.5280 0.5823
#> from y to x 1 0.0000 0.0379 10 -0.0687 0.0476
#> from y to m 1 0.0000 0.0200 10 -0.0264 0.0323
#> from y to y 1 0.5001 0.0157 10 0.4886 0.5323
#>
#> $`2`
#> interval est se R 2.5% 97.5%
#> from x to x 2 0.4897 0.0483 10 0.4098 0.5591
#> from x to m 2 0.5053 0.0258 10 0.4619 0.5289
#> from x to y 2 0.0854 0.0170 10 0.0435 0.0934
#> from m to x 2 0.0000 0.0632 10 -0.0603 0.1075
#> from m to m 2 0.3599 0.0460 10 0.3184 0.4541
#> from m to y 2 0.6044 0.0217 10 0.5844 0.6503
#> from y to x 2 0.0000 0.0465 10 -0.0841 0.0600
#> from y to m 2 0.0000 0.0322 10 -0.0508 0.0405
#> from y to y 2 0.2501 0.0190 10 0.2345 0.2841
#>
#> $`3`
#> interval est se R 2.5% 97.5%
#> from x to x 3 0.3427 0.0463 10 0.2751 0.4257
#> from x to m 3 0.4936 0.0310 10 0.4390 0.5293
#> from x to y 3 0.2680 0.0175 10 0.2321 0.2816
#> from m to x 3 0.0000 0.0518 10 -0.0592 0.0783
#> from m to m 3 0.2159 0.0528 10 0.1761 0.3210
#> from m to y 3 0.4999 0.0314 10 0.4755 0.5617
#> from y to x 3 0.0000 0.0435 10 -0.0800 0.0559
#> from y to m 3 0.0000 0.0395 10 -0.0690 0.0401
#> from y to y 3 0.1251 0.0217 10 0.0991 0.1646
#>
#> $`4`
#> interval est se R 2.5% 97.5%
#> from x to x 4 0.2398 0.0451 10 0.1818 0.3288
#> from x to m 4 0.4293 0.0370 10 0.3675 0.4865
#> from x to y 4 0.3686 0.0193 10 0.3339 0.3881
#> from m to x 4 0.0000 0.0407 10 -0.0597 0.0535
#> from m to m 4 0.1295 0.0508 10 0.0907 0.2251
#> from m to y 4 0.3686 0.0420 10 0.3379 0.4582
#> from y to x 4 0.0000 0.0366 10 -0.0691 0.0460
#> from y to m 4 0.0000 0.0417 10 -0.0760 0.0425
#> from y to y 4 0.0625 0.0266 10 0.0262 0.1026
#>
#> $`5`
#> interval est se R 2.5% 97.5%
#> from x to x 5 0.1678 0.0436 10 0.1193 0.2574
#> from x to m 5 0.3508 0.0418 10 0.2884 0.4258
#> from x to y 5 0.3946 0.0256 10 0.3507 0.4268
#> from m to x 5 0.0000 0.0327 10 -0.0543 0.0472
#> from m to m 5 0.0777 0.0448 10 0.0312 0.1541
#> from m to y 5 0.2555 0.0473 10 0.2231 0.3556
#> from y to x 5 0.0000 0.0292 10 -0.0566 0.0356
#> from y to m 5 0.0000 0.0400 10 -0.0749 0.0424
#> from y to y 5 0.0313 0.0316 10 -0.0151 0.0702
#>
summary(boot)
#> effect interval est se R 2.5% 97.5%
#> 1 from x to x 1 0.69977250 0.04619116 10 0.62664729 0.74488459
#> 2 from x to m 1 0.38882458 0.01953203 10 0.35192261 0.41196870
#> 3 from x to y 1 -0.10689374 0.01457135 10 -0.13880836 -0.09659594
#> 4 from m to x 1 0.00000000 0.06073486 10 -0.06326864 0.10973836
#> 5 from m to m 1 0.59989538 0.02765975 10 0.56673563 0.65366698
#> 6 from m to y 1 0.54943087 0.01959635 10 0.52803581 0.58233075
#> 7 from y to x 1 0.00000000 0.03787369 10 -0.06873167 0.04761120
#> 8 from y to m 1 0.00000000 0.02001760 10 -0.02637969 0.03232691
#> 9 from y to y 1 0.50007360 0.01565101 10 0.48863283 0.53227520
#> 10 from x to x 2 0.48968155 0.04829661 10 0.40983641 0.55913746
#> 11 from x to m 2 0.50534282 0.02575876 10 0.46193377 0.52888561
#> 12 from x to y 2 0.08537619 0.01700777 10 0.04354753 0.09341638
#> 13 from m to x 2 0.00000000 0.06319917 10 -0.06032332 0.10754010
#> 14 from m to m 2 0.35987447 0.04599035 10 0.31838727 0.45406311
#> 15 from m to y 2 0.60435691 0.02171160 10 0.58439277 0.65028161
#> 16 from y to x 2 0.00000000 0.04647067 10 -0.08413191 0.05999321
#> 17 from y to m 2 0.00000000 0.03217802 10 -0.05083872 0.04051302
#> 18 from y to y 2 0.25007360 0.01902263 10 0.23452458 0.28407526
#> 19 from x to x 3 0.34266568 0.04625981 10 0.27505399 0.42572708
#> 20 from x to m 3 0.49355305 0.03103092 10 0.43895163 0.52930052
#> 21 from x to y 3 0.26800143 0.01745794 10 0.23207899 0.28160738
#> 22 from m to x 3 0.00000000 0.05182092 10 -0.05918335 0.07830911
#> 23 from m to m 3 0.21588703 0.05277385 10 0.17613806 0.32096736
#> 24 from m to y 3 0.49994907 0.03139222 10 0.47550794 0.56172186
#> 25 from y to x 3 0.00000000 0.04348230 10 -0.07996316 0.05587709
#> 26 from y to m 3 0.00000000 0.03946202 10 -0.06895053 0.04010735
#> 27 from y to y 3 0.12505520 0.02167083 10 0.09906528 0.16456126
#> 28 from x to x 4 0.23978802 0.04513964 10 0.18178975 0.32883844
#> 29 from x to m 4 0.42931704 0.03695913 10 0.36749533 0.48650604
#> 30 from x to y 4 0.36856490 0.01930720 10 0.33393489 0.38807815
#> 31 from m to x 4 0.00000000 0.04073717 10 -0.05974970 0.05349997
#> 32 from m to m 4 0.12950963 0.05084726 10 0.09070625 0.22505825
#> 33 from m to y 4 0.36862633 0.04200137 10 0.33793532 0.45816980
#> 34 from y to x 4 0.00000000 0.03662452 10 -0.06907513 0.04599297
#> 35 from y to m 4 0.00000000 0.04169749 10 -0.07602734 0.04248806
#> 36 from y to y 4 0.06253681 0.02659055 10 0.02623799 0.10262406
#> 37 from x to x 5 0.16779706 0.04357747 10 0.11929313 0.25743403
#> 38 from x to m 5 0.35078078 0.04177677 10 0.28840681 0.42580094
#> 39 from x to y 5 0.39455777 0.02561383 10 0.35066698 0.42679774
#> 40 from m to x 5 0.00000000 0.03265509 10 -0.05429136 0.04717457
#> 41 from m to m 5 0.07769223 0.04484573 10 0.03122991 0.15411817
#> 42 from m to y 5 0.25549689 0.04730229 10 0.22314814 0.35557279
#> 43 from y to x 5 0.00000000 0.02922052 10 -0.05661104 0.03561862
#> 44 from y to m 5 0.00000000 0.03997550 10 -0.07487555 0.04241948
#> 45 from y to y 5 0.03127301 0.03156738 10 -0.01509265 0.07019346
confint(boot, level = 0.95)
#> effect interval 2.5 % 97.5 %
#> 1 from x to x 1 0.62664729 0.74488459
#> 2 from x to m 1 0.35192261 0.41196870
#> 3 from x to y 1 -0.13880836 -0.09659594
#> 4 from x to x 2 0.40983641 0.55913746
#> 5 from x to m 2 0.46193377 0.52888561
#> 6 from x to y 2 0.04354753 0.09341638
#> 7 from x to x 3 0.27505399 0.42572708
#> 8 from x to m 3 0.43895163 0.52930052
#> 9 from x to y 3 0.23207899 0.28160738
#> 10 from x to x 4 0.18178975 0.32883844
#> 11 from x to m 4 0.36749533 0.48650604
#> 12 from x to y 4 0.33393489 0.38807815
#> 13 from x to x 5 0.11929313 0.25743403
#> 14 from x to m 5 0.28840681 0.42580094
#> 15 from x to y 5 0.35066698 0.42679774
print(boot, type = "bc") # bias-corrected
#>
#> Total, Direct, and Indirect Effects
#> type = bc
#> $`1`
#> interval est se R 2.5% 97.5%
#> from x to x 1 0.6998 0.0462 10 0.6247 0.7391
#> from x to m 1 0.3888 0.0195 10 0.3620 0.4135
#> from x to y 1 -0.1069 0.0146 10 -0.1156 -0.0966
#> from m to x 1 0.0000 0.0607 10 -0.0633 0.1097
#> from m to m 1 0.5999 0.0277 10 0.5653 0.6134
#> from m to y 1 0.5494 0.0196 10 0.5280 0.5823
#> from y to x 1 0.0000 0.0379 10 -0.0687 0.0476
#> from y to m 1 0.0000 0.0200 10 -0.0243 0.0355
#> from y to y 1 0.5001 0.0157 10 0.4886 0.5323
#>
#> $`2`
#> interval est se R 2.5% 97.5%
#> from x to x 2 0.4897 0.0483 10 0.3995 0.5203
#> from x to m 2 0.5053 0.0258 10 0.4619 0.5289
#> from x to y 2 0.0854 0.0170 10 0.0711 0.0945
#> from m to x 2 0.0000 0.0632 10 -0.0598 0.1086
#> from m to m 2 0.3599 0.0460 10 0.3177 0.4386
#> from m to y 2 0.6044 0.0217 10 0.5804 0.6336
#> from y to x 2 0.0000 0.0465 10 -0.0841 0.0600
#> from y to m 2 0.0000 0.0322 10 -0.0508 0.0405
#> from y to y 2 0.2501 0.0190 10 0.2339 0.2829
#>
#> $`3`
#> interval est se R 2.5% 97.5%
#> from x to x 3 0.3427 0.0463 10 0.2607 0.3854
#> from x to m 3 0.4936 0.0310 10 0.4303 0.5197
#> from x to y 3 0.2680 0.0175 10 0.2652 0.2856
#> from m to x 3 0.0000 0.0518 10 -0.0557 0.0783
#> from m to m 3 0.2159 0.0528 10 0.1761 0.3210
#> from m to y 3 0.4999 0.0314 10 0.4751 0.5440
#> from y to x 3 0.0000 0.0435 10 -0.0800 0.0559
#> from y to m 3 0.0000 0.0395 10 -0.0690 0.0401
#> from y to y 3 0.1251 0.0217 10 0.0990 0.1432
#>
#> $`4`
#> interval est se R 2.5% 97.5%
#> from x to x 4 0.2398 0.0451 10 0.1710 0.2551
#> from x to m 4 0.4293 0.0370 10 0.3537 0.4512
#> from x to y 4 0.3686 0.0193 10 0.3357 0.3882
#> from m to x 4 0.0000 0.0407 10 -0.0494 0.0537
#> from m to m 4 0.1295 0.0508 10 0.0907 0.2251
#> from m to y 4 0.3686 0.0420 10 0.3361 0.4247
#> from y to x 4 0.0000 0.0366 10 -0.0691 0.0460
#> from y to m 4 0.0000 0.0417 10 -0.0760 0.0425
#> from y to y 4 0.0625 0.0266 10 0.0246 0.0917
#>
#> $`5`
#> interval est se R 2.5% 97.5%
#> from x to x 5 0.1678 0.0436 10 0.1135 0.2148
#> from x to m 5 0.3508 0.0418 10 0.2717 0.3772
#> from x to y 5 0.3946 0.0256 10 0.3440 0.4258
#> from m to x 5 0.0000 0.0327 10 -0.0543 0.0472
#> from m to m 5 0.0777 0.0448 10 0.0412 0.1572
#> from m to y 5 0.2555 0.0473 10 0.2231 0.3556
#> from y to x 5 0.0000 0.0292 10 -0.0566 0.0356
#> from y to m 5 0.0000 0.0400 10 -0.0749 0.0424
#> from y to y 5 0.0313 0.0316 10 -0.0152 0.0641
#>
summary(boot, type = "bc")
#> effect interval est se R 2.5% 97.5%
#> 1 from x to x 1 0.69977250 0.04619116 10 0.62468140 0.73907938
#> 2 from x to m 1 0.38882458 0.01953203 10 0.36196513 0.41348561
#> 3 from x to y 1 -0.10689374 0.01457135 10 -0.11556784 -0.09656558
#> 4 from m to x 1 0.00000000 0.06073486 10 -0.06326864 0.10973836
#> 5 from m to m 1 0.59989538 0.02765975 10 0.56533542 0.61343471
#> 6 from m to y 1 0.54943087 0.01959635 10 0.52803581 0.58233075
#> 7 from y to x 1 0.00000000 0.03787369 10 -0.06873167 0.04761120
#> 8 from y to m 1 0.00000000 0.02001760 10 -0.02431892 0.03549856
#> 9 from y to y 1 0.50007360 0.01565101 10 0.48863283 0.53227520
#> 10 from x to x 2 0.48968155 0.04829661 10 0.39951058 0.52028969
#> 11 from x to m 2 0.50534282 0.02575876 10 0.46193377 0.52888561
#> 12 from x to y 2 0.08537619 0.01700777 10 0.07107420 0.09450813
#> 13 from m to x 2 0.00000000 0.06319917 10 -0.05983395 0.10862931
#> 14 from m to m 2 0.35987447 0.04599035 10 0.31766333 0.43855897
#> 15 from m to y 2 0.60435691 0.02171160 10 0.58044349 0.63358363
#> 16 from y to x 2 0.00000000 0.04647067 10 -0.08413191 0.05999321
#> 17 from y to m 2 0.00000000 0.03217802 10 -0.05083872 0.04051302
#> 18 from y to y 2 0.25007360 0.01902263 10 0.23392510 0.28285536
#> 19 from x to x 3 0.34266568 0.04625981 10 0.26069578 0.38535309
#> 20 from x to m 3 0.49355305 0.03103092 10 0.43031824 0.51967621
#> 21 from x to y 3 0.26800143 0.01745794 10 0.26519759 0.28556433
#> 22 from m to x 3 0.00000000 0.05182092 10 -0.05567425 0.07831864
#> 23 from m to m 3 0.21588703 0.05277385 10 0.17613806 0.32096736
#> 24 from m to y 3 0.49994907 0.03139222 10 0.47505535 0.54396596
#> 25 from y to x 3 0.00000000 0.04348230 10 -0.07996316 0.05587709
#> 26 from y to m 3 0.00000000 0.03946202 10 -0.06895053 0.04010735
#> 27 from y to y 3 0.12505520 0.02167083 10 0.09901812 0.14317853
#> 28 from x to x 4 0.23978802 0.04513964 10 0.17104675 0.25509649
#> 29 from x to m 4 0.42931704 0.03695913 10 0.35373868 0.45122545
#> 30 from x to y 4 0.36856490 0.01930720 10 0.33570846 0.38818798
#> 31 from m to x 4 0.00000000 0.04073717 10 -0.04944213 0.05367381
#> 32 from m to m 4 0.12950963 0.05084726 10 0.09070625 0.22505825
#> 33 from m to y 4 0.36862633 0.04200137 10 0.33610824 0.42472686
#> 34 from y to x 4 0.00000000 0.03662452 10 -0.06907513 0.04599297
#> 35 from y to m 4 0.00000000 0.04169749 10 -0.07602734 0.04248806
#> 36 from y to y 4 0.06253681 0.02659055 10 0.02457317 0.09166099
#> 37 from x to x 5 0.16779706 0.04357747 10 0.11350347 0.21483345
#> 38 from x to m 5 0.35078078 0.04177677 10 0.27173887 0.37722926
#> 39 from x to y 5 0.39455777 0.02561383 10 0.34399803 0.42575955
#> 40 from m to x 5 0.00000000 0.03265509 10 -0.05429136 0.04717457
#> 41 from m to m 5 0.07769223 0.04484573 10 0.04123415 0.15717773
#> 42 from m to y 5 0.25549689 0.04730229 10 0.22314814 0.35557279
#> 43 from y to x 5 0.00000000 0.02922052 10 -0.05661104 0.03561862
#> 44 from y to m 5 0.00000000 0.03997550 10 -0.07487555 0.04241948
#> 45 from y to y 5 0.03127301 0.03156738 10 -0.01516324 0.06407115
confint(boot, level = 0.95, type = "bc")
#> effect interval 2.5 % 97.5 %
#> 1 from x to x 1 0.6246814 0.73907938
#> 2 from x to m 1 0.3619651 0.41348561
#> 3 from x to y 1 -0.1155678 -0.09656558
#> 4 from x to x 2 0.3995106 0.52028969
#> 5 from x to m 2 0.4619338 0.52888561
#> 6 from x to y 2 0.0710742 0.09450813
#> 7 from x to x 3 0.2606958 0.38535309
#> 8 from x to m 3 0.4303182 0.51967621
#> 9 from x to y 3 0.2651976 0.28556433
#> 10 from x to x 4 0.1710467 0.25509649
#> 11 from x to m 4 0.3537387 0.45122545
#> 12 from x to y 4 0.3357085 0.38818798
#> 13 from x to x 5 0.1135035 0.21483345
#> 14 from x to m 5 0.2717389 0.37722926
#> 15 from x to y 5 0.3439980 0.42575955
# }