Skip to contents

Model

The measurement model is given by ๐’ši,t=๐‚+๐šฒ๐œผi,t+๐œบi,t,with๐œบi,tโˆผ๐’ฉ(๐ŸŽ,๐šฏ)\begin{equation} \mathbf{y}_{i, t} = \boldsymbol{\nu} + \boldsymbol{\Lambda} \boldsymbol{\eta}_{i, t} + \boldsymbol{\varepsilon}_{i, t}, \quad \mathrm{with} \quad \boldsymbol{\varepsilon}_{i, t} \sim \mathcal{N} \left( \mathbf{0}, \boldsymbol{\Theta} \right) \end{equation} where ๐’ši,t\mathbf{y}_{i, t}, ๐œผi,t\boldsymbol{\eta}_{i, t}, and ๐œบi,t\boldsymbol{\varepsilon}_{i, t} are random variables and ๐‚\boldsymbol{\nu}, ๐šฒ\boldsymbol{\Lambda}, and ๐šฏ\boldsymbol{\Theta} are model parameters. ๐’ši,t\mathbf{y}_{i, t} represents a vector of observed random variables, ๐œผi,t\boldsymbol{\eta}_{i, t} a vector of latent random variables, and ๐œบi,t\boldsymbol{\varepsilon}_{i, t} a vector of random measurement errors, at time tt and individual ii. ๐‚\boldsymbol{\nu} denotes a vector of intercepts, ๐šฒ\boldsymbol{\Lambda} a matrix of factor loadings, and ๐šฏ\boldsymbol{\Theta} the covariance matrix of ๐œบ\boldsymbol{\varepsilon}.

An alternative representation of the measurement error is given by ๐œบi,t=๐šฏ12๐’›i,t,with๐’›i,tโˆผ๐’ฉ(๐ŸŽ,๐‘ฐ)\begin{equation} \boldsymbol{\varepsilon}_{i, t} = \boldsymbol{\Theta}^{\frac{1}{2}} \mathbf{z}_{i, t}, \quad \mathrm{with} \quad \mathbf{z}_{i, t} \sim \mathcal{N} \left( \mathbf{0}, \mathbf{I} \right) \end{equation} where ๐’›i,t\mathbf{z}_{i, t} is a vector of independent standard normal random variables and (๐šฏ12)(๐šฏ12)โ€ฒ=๐šฏ\left( \boldsymbol{\Theta}^{\frac{1}{2}} \right) \left( \boldsymbol{\Theta}^{\frac{1}{2}} \right)^{\prime} = \boldsymbol{\Theta} .

The dynamic structure is given by d๐œผi,t=๐šฝ(๐œผi,tโˆ’๐)dt+๐šบ12d๐‘พi,t\begin{equation} \mathrm{d} \boldsymbol{\eta}_{i, t} = \boldsymbol{\Phi} \left( \boldsymbol{\eta}_{i, t} - \boldsymbol{\mu} \right) \mathrm{d}t + \boldsymbol{\Sigma}^{\frac{1}{2}} \mathrm{d} \mathbf{W}_{i, t} \end{equation} where ๐\boldsymbol{\mu} is the long-term mean or equilibrium level, ๐šฝ\boldsymbol{\Phi} is the rate of mean reversion, determining how quickly the variable returns to its mean, ๐šบ\boldsymbol{\Sigma} is the matrix of volatility or randomness in the process, and d๐‘พ\mathrm{d}\boldsymbol{W} is a Wiener process or Brownian motion, which represents random fluctuations.

Parameters

Notation

Let t=100t = 100 be the number of time points and n=5n = 5 be the number of individuals.

Let the measurement model intecept vector ๐‚\boldsymbol{\nu} be given by

๐‚=(000).\begin{equation} \boldsymbol{\nu} = \left( \begin{array}{c} 0 \\ 0 \\ 0 \\ \end{array} \right) . \end{equation}

Let the factor loadings matrix ๐šฒ\boldsymbol{\Lambda} be given by

๐šฒ=(100010001).\begin{equation} \boldsymbol{\Lambda} = \left( \begin{array}{ccc} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array} \right) . \end{equation}

Let the measurement error covariance matrix ๐šฏ\boldsymbol{\Theta} be given by

๐šฏ=(0.20000.20000.2).\begin{equation} \boldsymbol{\Theta} = \left( \begin{array}{ccc} 0.2 & 0 & 0 \\ 0 & 0.2 & 0 \\ 0 & 0 & 0.2 \\ \end{array} \right) . \end{equation}

Let the initial condition ๐œผ0\boldsymbol{\eta}_{0} be given by

๐œผ0โˆผ๐’ฉ(๐๐œผโˆฃ0,๐šบ๐œผโˆฃ0)\begin{equation} \boldsymbol{\eta}_{0} \sim \mathcal{N} \left( \boldsymbol{\mu}_{\boldsymbol{\eta} \mid 0}, \boldsymbol{\Sigma}_{\boldsymbol{\eta} \mid 0} \right) \end{equation}

๐๐œผโˆฃ0=(000)\begin{equation} \boldsymbol{\mu}_{\boldsymbol{\eta} \mid 0} = \left( \begin{array}{c} 0 \\ 0 \\ 0 \\ \end{array} \right) \end{equation}

๐šบ๐œผโˆฃ0=(10.20.20.210.20.20.21).\begin{equation} \boldsymbol{\Sigma}_{\boldsymbol{\eta} \mid 0} = \left( \begin{array}{ccc} 1 & 0.2 & 0.2 \\ 0.2 & 1 & 0.2 \\ 0.2 & 0.2 & 1 \\ \end{array} \right) . \end{equation}

Let the long-term mean vector ๐\boldsymbol{\mu} be given by

๐=(000).\begin{equation} \boldsymbol{\mu} = \left( \begin{array}{c} 0 \\ 0 \\ 0 \\ \end{array} \right) . \end{equation}

Let the rate of mean reversion matrix ๐šฝ\boldsymbol{\Phi} be given by

๐šฝ=(โˆ’0.357000.771โˆ’0.5110โˆ’0.450.729โˆ’0.693).\begin{equation} \boldsymbol{\Phi} = \left( \begin{array}{ccc} -0.357 & 0 & 0 \\ 0.771 & -0.511 & 0 \\ -0.45 & 0.729 & -0.693 \\ \end{array} \right) . \end{equation}

Let the dynamic process noise covariance matrix ๐šบ\boldsymbol{\Sigma} be given by

๐šบ=(0.24455560.0220159โˆ’0.05004760.02201590.0706780.0153946โˆ’0.05004760.01539460.0755306).\begin{equation} \boldsymbol{\Sigma} = \left( \begin{array}{ccc} 0.2445556 & 0.0220159 & -0.0500476 \\ 0.0220159 & 0.070678 & 0.0153946 \\ -0.0500476 & 0.0153946 & 0.0755306 \\ \end{array} \right) . \end{equation}

Let ฮ”t=0.1\Delta t = 0.1.

R Function Arguments

n
#> [1] 5
time
#> [1] 100
delta_t
#> [1] 0.1
mu0
#> [1] 0 0 0
sigma0
#>      [,1] [,2] [,3]
#> [1,]  1.0  0.2  0.2
#> [2,]  0.2  1.0  0.2
#> [3,]  0.2  0.2  1.0
sigma0_l # sigma0_l <- t(chol(sigma0))
#>      [,1]      [,2]      [,3]
#> [1,]  1.0 0.0000000 0.0000000
#> [2,]  0.2 0.9797959 0.0000000
#> [3,]  0.2 0.1632993 0.9660918
mu
#> [1] 0 0 0
phi
#>        [,1]   [,2]   [,3]
#> [1,] -0.357  0.000  0.000
#> [2,]  0.771 -0.511  0.000
#> [3,] -0.450  0.729 -0.693
sigma
#>             [,1]       [,2]        [,3]
#> [1,]  0.24455556 0.02201587 -0.05004762
#> [2,]  0.02201587 0.07067800  0.01539456
#> [3,] -0.05004762 0.01539456  0.07553061
sigma_l # sigma_l <- t(chol(sigma))
#>             [,1]      [,2]     [,3]
#> [1,]  0.49452559 0.0000000 0.000000
#> [2,]  0.04451917 0.2620993 0.000000
#> [3,] -0.10120330 0.0759256 0.243975
nu
#> [1] 0 0 0
lambda
#>      [,1] [,2] [,3]
#> [1,]    1    0    0
#> [2,]    0    1    0
#> [3,]    0    0    1
theta
#>      [,1] [,2] [,3]
#> [1,]  0.2  0.0  0.0
#> [2,]  0.0  0.2  0.0
#> [3,]  0.0  0.0  0.2
theta_l # theta_l <- t(chol(theta))
#>           [,1]      [,2]      [,3]
#> [1,] 0.4472136 0.0000000 0.0000000
#> [2,] 0.0000000 0.4472136 0.0000000
#> [3,] 0.0000000 0.0000000 0.4472136

Parametric Bootstrap

R <- 5L # use at least 1000 in actual research
path <- getwd()
prefix <- "ou"

We use the PBSSMOUFixed function from the bootStateSpace package to perform parametric bootstraping using the parameters described above. The argument R specifies the number of bootstrap replications. The generated data and model estimates are stored in path using the specified prefix for the file names. The ncores = parallel::detectCores() argument instructs the function to use all available CPU cores in the system.

NOTE: Fitting the Ornsteinโ€“Uhlenbeck model multiple times is computationally intensive.

library(bootStateSpace)
pb <- PBSSMOUFixed(
  R = R,
  path = path,
  prefix = prefix,
  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 = parallel::detectCores(),
  seed = 42
)
#> Registered S3 method overwritten by 'car':
#>   method           from
#>   na.action.merMod lme4
summary(pb)
#> Call:
#> PBSSMOUFixed(R = R, path = path, prefix = prefix, 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 = parallel::detectCores(), seed = 42)
#> 
#> Parametric bootstrap confidence intervals.
#> type = "pc"
#>                est     se R    2.5%   97.5%
#> phi_1_1    -0.3570 0.4864 5 -1.0834 -0.0160
#> phi_2_1     0.7710 0.2406 5  0.5641  1.0874
#> phi_3_1    -0.4500 0.1743 5 -0.7544 -0.3578
#> phi_1_2     0.0000 0.4495 5 -0.3229  0.6989
#> phi_2_2    -0.5110 0.2466 5 -0.8879 -0.3256
#> phi_3_2     0.7290 0.1114 5  0.6375  0.9084
#> phi_1_3     0.0000 0.5056 5 -0.7566  0.3762
#> phi_2_3     0.0000 0.1899 5 -0.1791  0.2622
#> phi_3_3    -0.6930 0.1527 5 -0.8326 -0.4929
#> sigma_1_1   0.2446 0.1076 5  0.1930  0.4290
#> sigma_2_1   0.0220 0.0303 5 -0.0159  0.0531
#> sigma_3_1  -0.0500 0.0248 5 -0.0468  0.0098
#> sigma_2_2   0.0707 0.0178 5  0.0325  0.0686
#> sigma_3_2   0.0154 0.0054 5  0.0139  0.0260
#> sigma_3_3   0.0755 0.0238 5  0.0235  0.0800
#> theta_1_1   0.2000 0.0203 5  0.1652  0.2103
#> theta_2_2   0.2000 0.0086 5  0.1967  0.2155
#> theta_3_3   0.2000 0.0125 5  0.1966  0.2247
#> mu0_1_1     0.0000 0.3793 5 -0.3819  0.4526
#> mu0_2_1     0.0000 0.5071 5 -0.8941  0.3087
#> mu0_3_1     0.0000 0.5265 5 -0.4844  0.7875
#> sigma0_1_1  1.0000 0.2836 5  0.1566  0.8458
#> sigma0_2_1  0.2000 0.5414 5 -0.4823  0.8334
#> sigma0_3_1  0.2000 0.1395 5 -0.2582  0.0425
#> sigma0_2_2  1.0000 0.5305 5  0.2520  1.5665
#> sigma0_3_2  0.2000 0.3436 5 -0.1686  0.6278
#> sigma0_3_3  1.0000 0.4836 5  0.2765  1.2750
summary(pb, type = "bc")
#> Call:
#> PBSSMOUFixed(R = R, path = path, prefix = prefix, 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 = parallel::detectCores(), seed = 42)
#> 
#> Parametric bootstrap confidence intervals.
#> type = "bc"
#>                est     se R    2.5%   97.5%
#> phi_1_1    -0.3570 0.4864 5 -1.0919 -0.0599
#> phi_2_1     0.7710 0.2406 5  0.5586  1.0665
#> phi_3_1    -0.4500 0.1743 5 -0.6360 -0.3398
#> phi_1_2     0.0000 0.4495 5 -0.3001  0.7371
#> phi_2_2    -0.5110 0.2466 5 -0.8632 -0.3182
#> phi_3_2     0.7290 0.1114 5  0.6227  0.8390
#> phi_1_3     0.0000 0.5056 5 -0.8580  0.2357
#> phi_2_3     0.0000 0.1899 5 -0.1830  0.2344
#> phi_3_3    -0.6930 0.1527 5 -0.8343 -0.5073
#> sigma_1_1   0.2446 0.1076 5  0.1914  0.4186
#> sigma_2_1   0.0220 0.0303 5 -0.0181  0.0515
#> sigma_3_1  -0.0500 0.0248 5 -0.0498 -0.0498
#> sigma_2_2   0.0707 0.0178 5  0.0687  0.0687
#> sigma_3_2   0.0154 0.0054 5  0.0131  0.0250
#> sigma_3_3   0.0755 0.0238 5  0.0350  0.0835
#> theta_1_1   0.2000 0.0203 5  0.1640  0.2097
#> theta_2_2   0.2000 0.0086 5  0.1971  0.2160
#> theta_3_3   0.2000 0.0125 5  0.1965  0.2213
#> mu0_1_1     0.0000 0.3793 5 -0.3850  0.4151
#> mu0_2_1     0.0000 0.5071 5 -0.9572  0.2713
#> mu0_3_1     0.0000 0.5265 5 -0.1539  0.8842
#> sigma0_1_1  1.0000 0.2836 5  0.8570  0.8570
#> sigma0_2_1  0.2000 0.5414 5 -0.5121  0.7623
#> sigma0_3_1  0.2000 0.1395 5  0.0458  0.0458
#> sigma0_2_2  1.0000 0.5305 5  0.6446  1.6390
#> sigma0_3_2  0.2000 0.3436 5 -0.2194  0.4991
#> sigma0_3_3  1.0000 0.4836 5  0.2876  1.2795

References

Chow, S.-M., Losardo, D., Park, J. J., & Molenaar, P. C. M. (2023). Continuous-time dynamic models: Connections to structural equation models and other discrete-time models. In R. H. Hoyle (Ed.), Handbook of structural equation modeling (2nd ed.). The Guilford Press.
Oravecz, Z., Tuerlinckx, F., & Vandekerckhove, J. (2011). A hierarchical latent stochastic differential equation model for affective dynamics. Psychological Methods, 16(4), 468โ€“490. https://doi.org/10.1037/a0024375
Ou, L., Hunter, M. D., & Chow, S.-M. (2019). Whatโ€™s for dynr: A package for linear and nonlinear dynamic modeling in R. The R Journal, 11(1), 91. https://doi.org/10.32614/rj-2019-012
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. (2024). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/
Uhlenbeck, G. E., & Ornstein, L. S. (1930). On the theory of the brownian motion. Physical Review, 36(5), 823โ€“841. https://doi.org/10.1103/physrev.36.823