Learn R Programming

pomp (version 4.2)

kalmanFilter: Kalman filter

Description

The basic Kalman filter for multivariate, linear, Gaussian processes.

Usage

kalmanFilter(object, X0, 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

\(m\times m\) latent state-process transition matrix. \(E[X(t+1) | X(t)] = A.X(t)\).

Q

\(m\times m\) latent state-process covariance matrix. \(Var[X(t+1) | X(t)] = Q\)

C

\(n\times m\) link matrix. \(E[Y(t) | X(t)] = C.X(t)\).

R

\(n\times n\) observation process covariance matrix. \(Var[Y(t) | X(t)] = R\)

tol

numeric; the tolerance to be used in computing matrix pseudoinverses via singular-value decomposition. Singular values smaller than tol are set to zero.

Value

A named list containing the following elements:

object

the ‘pomp’ object

A, Q, C, R

as in the call

filter.mean

\(E[X(t)|y^*(1),\dots,y^*(t)]\)

pred.mean

\(E[X(t)|y^*(1),\dots,y^*(t-1)]\)

forecast

\(E[Y(t)|y^*(1),\dots,y^*(t-1)]\)

cond.logLik

\(f(y^*(t)|y^*(1),\dots,y^*(t-1))\)

logLik

\(f(y^*(1),\dots,y^*(T))\)

Details

If the latent state is \(X\), the observed variable is \(Y\), \(X(t) \in R^m\), \(Y(t) \in R^n\), and $$X(t) ~ MultivariateNormal(A X(t-1), Q)$$ $$Y(t) ~ MultivariateNormal(C X(t), R)$$ Then the Kalman filter computes the exact likelihood of \(Y\) given \(A\), \(C\), \(Q\), and \(R\).

See Also

enkf, eakf

Examples

Run this code
# NOT RUN {
  library(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)))
  
# }

Run the code above in your browser using DataLab