kalmanFilter {pomp} | R Documentation |
Kalman filter
Description
The basic Kalman filter for multivariate, linear, Gaussian processes.
Usage
kalmanFilter(object, X0 = rinit(object), A, Q, C, R, tol = 1e-06)
Arguments
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 |
Details
If the latent state is , the observed variable is
,
,
, and
where denotes the multivariate normal distribution with mean
and variance
.
Then the Kalman filter computes the exact likelihood of
given
,
,
, and
.
Value
A named list containing the following elements:
- object
the ‘pomp’ object
- A, Q, C, R
as in the call
- filter.mean
- pred.mean
- forecast
- cond.logLik
- logLik
See Also
Examples
# 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)))
}