Ivan Jacob Agaloos Pesigan
Provides a streamlined and user-friendly framework for bootstrapping in state space models, particularly when the number of subjects/units (n) exceeds one, a scenario commonly encountered in social and behavioral sciences. The parametric bootstrap implemented here was developed and applied in Pesigan, Russell, and Chow (2025: https://doi.org/10.1037/met0000779).
You can install the CRAN release of bootStateSpace with:
install.packages("bootStateSpace")You can install the development version of bootStateSpace from
GitHub with:
if (!require("pak")) install.packages("pak")
pak::pkg_install("jeksterslab/bootStateSpace")In this example, data are simulated from a first-order vector
autoregressive model with two variables for five individuals measured at
fifty time points, as in the example of
simStateSpace::SimSSMVARFixed(), and the sampling distribution of the
estimates is generated with the parametric bootstrap using the
PBSSMVARFixed() function. Each bootstrap sample is simulated from the
model and fitted with dynr.
library(package = "bootStateSpace")alpha <- c(0, 0)
beta <- matrix(
data = c(
0.5, 0.2,
0.0, 0.4
),
nrow = 2
)
psi <- diag(x = 0.1, nrow = 2)The initial condition is set to the steady-state mean vector and covariance matrix of the process.
mu0 <- simStateSpace::SSMMeanEta(beta = beta, alpha = alpha)
sigma0 <- simStateSpace::SSMCovEta(beta = beta, psi = psi)pb <- PBSSMVARFixed(
R = 10L, # use at least 1000 in actual research
path = tempdir(),
prefix = "var",
n = 5,
time = 50,
mu0 = mu0,
sigma0_l = t(x = chol(x = sigma0)),
alpha = alpha,
beta = beta,
psi_l = t(x = chol(x = psi)),
type = 0,
ncores = 1, # consider using multiple cores
seed = 42
)Percentile confidence intervals:
summary(object = pb)
#> Call:
#> PBSSMVARFixed(R = 10L, path = tempdir(), prefix = "var", n = 5,
#> time = 50, mu0 = mu0, sigma0_l = t(x = chol(x = sigma0)),
#> alpha = alpha, beta = beta, psi_l = t(x = chol(x = psi)),
#> type = 0, ncores = 1, seed = 42)
#>
#> Parametric bootstrap confidence intervals.
#> type = "pc"
#> est se R 2.5% 97.5%
#> beta_1_1 0.5000 0.0559 10 0.4082 0.5833
#> beta_2_1 0.2000 0.0717 10 0.0673 0.2928
#> beta_1_2 0.0000 0.0434 10 -0.0561 0.0766
#> beta_2_2 0.4000 0.0363 10 0.3054 0.4094
#> psi_1_1 0.1000 0.0087 10 0.0876 0.1134
#> psi_2_2 0.1000 0.0071 10 0.0919 0.1138
#> mu0_1_1 0.0000 0.1307 10 -0.1996 0.2111
#> mu0_2_1 0.0000 0.1232 10 -0.2102 0.1307
#> sigma0_1_1 0.1333 0.0582 10 0.0136 0.1824
#> sigma0_2_1 0.0167 0.0408 10 -0.0818 0.0444
#> sigma0_2_2 0.1286 0.0633 10 0.0174 0.2176Bias-corrected confidence intervals:
summary(object = pb, type = "bc")
#> Call:
#> PBSSMVARFixed(R = 10L, path = tempdir(), prefix = "var", n = 5,
#> time = 50, mu0 = mu0, sigma0_l = t(x = chol(x = sigma0)),
#> alpha = alpha, beta = beta, psi_l = t(x = chol(x = psi)),
#> type = 0, ncores = 1, seed = 42)
#>
#> Parametric bootstrap confidence intervals.
#> type = "bc"
#> est se R 2.5% 97.5%
#> beta_1_1 0.5000 0.0559 10 0.4140 0.5920
#> beta_2_1 0.2000 0.0717 10 0.0867 0.3011
#> beta_1_2 0.0000 0.0434 10 -0.0626 0.0696
#> beta_2_2 0.4000 0.0363 10 0.3621 0.4194
#> psi_1_1 0.1000 0.0087 10 0.0917 0.1156
#> psi_2_2 0.1000 0.0071 10 0.0919 0.1138
#> mu0_1_1 0.0000 0.1307 10 -0.1404 0.2300
#> mu0_2_1 0.0000 0.1232 10 -0.2102 0.1307
#> sigma0_1_1 0.1333 0.0582 10 0.0761 0.1871
#> sigma0_2_1 0.0167 0.0408 10 -0.0083 0.0516
#> sigma0_2_2 0.1286 0.0633 10 0.0575 0.2389The package provides the following functions, grouped as in the reference index.
| Function | Purpose |
|---|---|
PBSSMFixed() |
Parametric bootstrap for the state space model |
PBSSMVARFixed() |
Parametric bootstrap for the vector autoregressive model |
PBSSMLinSDEFixed() |
Parametric bootstrap for the linear stochastic differential equation model |
PBSSMOUFixed() |
Parametric bootstrap for the Ornstein-Uhlenbeck model |
extract() |
Bootstrap draws of a parameter matrix |
The print(), summary(), confint(), vcov(), and coef() methods
are available for the bootstrap results.
See GitHub Pages for package documentation, including examples for the state space, vector autoregressive, and Ornstein-Uhlenbeck models.
To cite bootStateSpace in publications, please cite Pesigan et al.
(2025).
Pesigan, I. J. A., Russell, M. A., & Chow, S.-M. (2025). Inferences and effect sizes for direct, indirect, and total effects in continuous-time mediation models. Psychological Methods. https://doi.org/10.1037/met0000779
R Core Team. (2025). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/