SS.solve: Optimal Estimation

Description Usage Arguments Details Value Note Examples

View source: R/SS.solve.R

Description

Solve a state space system using the Kalman Filter

Usage

1
SS.solve(Z, F, H, Q, R, length.out, P0, beta0=0)

Arguments

Z

A T x n data matrix.

F

The state matrix. A scalar, or vector of length d, or a d x d matrix. When scalar, F is constant diagonal. When a vector, F is diagonal.

H

The measurement matrix. Must be n x d.

Q

The state variance. A scalar, or vector of length d, or a d x d matrix. When scalar, Q is constant diagonal. When a vector, Q is diagonal.

R

The measurement variance. A scalar, or vector of length n, or an n x n matrix. When scalar, R is constant diagonal. When a vector, R is diagonal.

length.out

Scalar integer.

P0

Initial a priori prediction error.

beta0

Initial state value. A scalar, or a vector of length d.

Details

H is the master argument from which system dimensionality is determined.

Value

A named list.

B.apri

A T x d matrix, the ith row of which is the best state estimate prior to observing data at time i.

B.apos

A T x d matrix, the ith row of which is the best state estimate given the observation at time i.

Note

For a definition of the system of interest, please see SSsimple.

Examples

1
2
3
4
5
6
7
8
9
set.seed(999)
H <- matrix(1)
x <- SS.sim( 1, H, 1, 1, 100, 0 )
y <- SS.solve( x$Z, 1, H, 1, 1, 100, 10^5, 0 )

z.hat <- t( H %*% t( y$B.apri ) )

plot( x$Z, type="l", col="blue" )
points( z.hat[ ,1], type="l", col="red" )

SSsimple documentation built on Dec. 7, 2019, 9:06 a.m.