| fit_ou | R Documentation |
Implements the EM algorithm to perform inference on the parameters of an Ornstein–Uhlenbeck process with mixed drift effects.
fit_ou(df,
mu = "at^1",
tol = 1e-4,
max_iter = 100,
theta = NULL,
M = 100,
verbose = TRUE,
mu_cond = NULL,
n_mcmc = 1000,
burnin = 500)
df |
Data frame with the observed data. It must include the columns
|
mu |
Functional form of the drift. Supported drifts include
|
tol |
Convergence tolerance for the EM algorithm. The algorithm stops when
the maximum absolute difference between the parameter estimates at two
consecutive EM iterations is smaller than |
max_iter |
Maximum number of EM iterations. |
theta |
Optional named vector of initial parameter values. If |
M |
Number of Monte Carlo samples used to approximate the conditional expectations in the E-step. |
verbose |
Logical indicating whether to print EM iteration progress. |
mu_cond |
Optional user-supplied function defining the conditional mean of
the process. If |
n_mcmc |
Number of MCMC iterations used in the E-step to sample the random effects. |
burnin |
Number of initial MCMC iterations discarded. |
The model is a one-dimensional Ornstein–Uhlenbeck diffusion defined by
dY_{kt} = \lambda\{\mu(t, a_k) - Y_{kt}\}\,dt + \sigma\,dW_{kt},
where \mu(t, a_k) is a user-specified drift function depending on a
unit-specific random effect a_k \sim \mathcal{N}(\mu_a, \sigma_a^2).
The parameter \lambda controls the strength of mean reversion toward the
time-dependent mean.
For discretely observed trajectories, the conditional mean is given by
E\{Y_{kt_i} \mid Y_{kt_{i-1}}, a_k\}
=
Y_{kt_{i-1}} e^{-\lambda \Delta t_i}
+
\lambda \int_{t_{i-1}}^{t_i}
e^{-\lambda (t_i - s)} \mu(s,a_k)\,ds.
The function mu_cond represents this conditional mean. If not provided, it
is constructed automatically from the drift specification supplied through
mu using closed-form expressions.
A named numeric vector containing the estimated model parameters:
mu_a |
Estimated mean of the random effects distribution. |
sigma2_a |
Estimated variance of the random effects distribution. |
sigma2 |
Estimated diffusion variance of the process. |
lambda |
Estimated mean reversion parameter. |
library(mixediffusion)
data(datasim03)
plot_paths(df = datasim03)
fit <- fit_ou(df = datasim03, mu = "at^1",
verbose = FALSE, max_iter = 2)
fit
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.