kalmanFilter | R Documentation |
The basic Kalman filter for multivariate, linear, Gaussian processes.
kalmanFilter(object, X0 = rinit(object), A, Q, C, R, tol = 1e-06)
object |
a pomp object containing data; |
X0 |
length-m vector containing initial state. This is assumed known without uncertainty. |
A |
|
Q |
|
C |
|
R |
|
tol |
numeric;
the tolerance to be used in computing matrix pseudoinverses via singular-value decomposition.
Singular values smaller than |
If the latent state is X
, the observed variable is Y
,
X_t \in R^m
, Y_t \in R^n
, and
X_t \sim \mathrm{MVN}(A X_{t-1}, Q)
Y_t \sim \mathrm{MVN}(C X_t, R)
where \mathrm{MVN}(M,V)
denotes the multivariate normal distribution with mean M
and variance V
.
Then the Kalman filter computes the exact likelihood of Y
given A
, C
, Q
, and R
.
A named list containing the following elements:
the ‘pomp’ object
as in the call
E[X_t|y^*_1,\dots,y^*_t]
E[X_t|y^*_1,\dots,y^*_{t-1}]
E[Y_t|y^*_1,\dots,y^*_{t-1}]
f(y^*_t|y^*_1,\dots,y^*_{t-1})
f(y^*_1,\dots,y^*_T)
enkf
, eakf
# takes too long for R CMD check
if (require(dplyr)) {
gompertz() -> po
po |>
as.data.frame() |>
mutate(
logY=log(Y)
) |>
select(time,logY) |>
pomp(times="time",t0=0) |>
kalmanFilter(
X0=c(logX=0),
A=matrix(exp(-0.1),1,1),
Q=matrix(0.01,1,1),
C=matrix(1,1,1),
R=matrix(0.01,1,1)
) -> kf
po |>
pfilter(Np=1000) -> pf
kf$logLik
logLik(pf) + sum(log(obs(pf)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.