Base class for CSI models.
Let Xt
denote an N x d
matrix of particle positions recorded at intervals of dt
, where d = 1,2,3
is the number of recorded dimensions. A CSI model for Xt
is of the form
where:
R(phi)
is an N x p
matrix of drift terms, possibly dependent on a parameter phi
. In most cases though, R(phi) = t((1:N-1) * dt)
is used to model linear drift.
mu
is a p x d
matrix of drift parameters. For linear drift, it represents the drift velocity in each of the d
dimensions.
Sigma
is a d x d
variance matrix.
Z
is an N x d
matrix where each column is an iid realization of N
values of a Gaussian continuous stationary increments (CSI) process. Such processes are completely determined by the mean square displacement (MSD) function
where the MSD function also depends on the parameter phi
.
The csi_model
class is a base class for CSI models which requires the user to specify the drift and msd functions, based on which it provides generic methods for parameter inference, simulation, etc. For further details about the CSI model see vignette("subdiff")
.
phi_names
Vector of kernel parameter names (on the original scale). Setting to NULL
means there are no kernel parameters (n_phi = 0
).
Xt
Particle trajectory. A matrix where row n
is the position of the particle at time t = n * dt
and each column is a measurement dimension. Only reallocates memory for the internal Toeplitz matrix if necessary.
dt
Interobservation time (scalar).
acf()
Increment autocorrelation function.
msd()
Position mean square displacement function.
phi
Kernel parameters in the original basis.
t
Vector of time points at which to calculate the MSD.
This method can be directly supplied by the derived class. Otherwise, it uses SuperGauss::acf2msd()
to calculate the MSD from self$acf()
at intervals of self$dt
, and interpolates linearly between these timepoints at the desired values in t
.
The self$msd()
method is defined this way because the MSD of some CSI models (e.g., fsd
and farma
) is not defined in continuous time, and thus intrinsically depends on the interobservation time dt
. Thus, the default self$msd()
method throws an error if self$dt
has not yet been set.
drift()
Increment autocorrelation function.
get_vcov()
Convert a Fisher information matrix to a variance matrix.
fit()
Calculate the maximum likelihood parameter values.
psi0
Vector of kernel parameter values (on the computational scale) to initialize the optimization if n_phi > 1
. If n_phi == 1
, a vector of length 2 giving the range in which to perform the optimum search.
vcov
Whether to also calculate the MLE variance estimate.
...
Additional arguments to stats::optim()
or stats::optimize()
for n_phi == 1
.
resid()
Calculate the model residuals.
A matrix of residuals the same size as dX
as calculated with csi_resid()
, upon using the model's drift()
and acf()
specifications.
sim()
Simulate trajectories from the model.
phi
Kernel parameters in the original basis.
mu
Drift coefficients.
Sigma
Scale matrix.
nsim
Number of trajectories to simulate.
fft, nkeep, tol
Optional arguments to SuperGauss::rnormtz()
.
new()
Model object constructor.
csi_model$new(Xt, dt, drift = "linear", n_drift)
Xt
Matrix of particle positions.
dt
Interobservation time.
drift
Drift specification. Either one of the strings "none", "linear", "quadratric", or a function with signature function(phi, dt, N)
.
n_drift
Integer number of drift terms. Ignored if drift
is one of the default strings. Required otherwise.
The value of n_phi
is automatically determined from phi_names
. But this means the latter must be set by derived$initialize()
before super$initialize()
is called. Otherwise an error is thrown.
The constructor can be called without Xt
for accessing methods which don't require it, e.g.,
Development Notes
Should a validator be (optionally) called after the constructor?
Should psi
necessarily contain the origin, to facilitate the validator?