# internalKalman: Internal functions of package robKalman for the classical... In robKalman: Robust Kalman Filtering

## Description

These functions are used internally by package robKalman

## Usage

 ```1 2 3 4 5 6 7``` ```.getDelta(S1, Z, V) .getKG(S1, Z, Delta) .getcorrCov(S1, K, Z) .getpredCov(S0, F, Q) .cKinitstep(a, S, ...) .cKpredstep(x0, S0, F, Q, ...) .cKcorrstep(y, x1, S1, Z, V, ...) ```

## Arguments

 `a` mean of the initial state `S` initial state covariance (see below) `Z` observation matrix (see below) `V` observation error covariance (see below) `F` innovation transition matrix (see below) `Q` innovation covariance (see below) `Delta` Covariance of Delta y_t `K` Kalman gain K_t `S1` prediction error covariance S_{t|t-1} of the classical Kalman filter `S0` filter error covariance S_{t-1|t-1} of the classical Kalman filter `y` observation y_t `x0` (classical Kalman)- filtered state x_{t-1|t-1} `x1` (classical Kalman)- predicted state x_{t|t-1} `...` not used here; for compatibility with signatures of other "step"-functions

## Details

We work in the setup of the linear, Gaussian state space model (l-G-SSM) with p dimensional states x_t and q dimensional observations y_t, with initial condition

x_0 ~ N_p(a,S),

state equation

x_t = F_t x_{t-1} + v_t, v_t ~ N_p(0,Q_t), t>=1,

observation equation

y_t = Z_t x_t + e_t, e_t ~ N_q(0,V_t), t>=1,

and where all random variable x_0, v_t, e_t are independent.

For notation, let us formulate the classical Kalman filter in this context:

(0) ininitial step

x_{0|0} = a

\code{ } with error covariance

S_{0|0} = Cov(x_0-x_{0|0}) = S

(1) prediction step

x_{t|t-1} = F_t x_{t-1|t-1}, t>=1

\code{ } with error covariance

S_{t|t-1} = Cov(x_t-x_{t|t-1}) = F_t S_{t-1|t-1} F_t' + Q_t

(2) correction step

x_{t|t} = x_{t|t-1} + K_t (y_t - Z_t x_{t|t-1}), t>=1

\code{ } for Kalman Gain

K_t = S_{t|t-1} Z_t' (Z_t S_{t|t-1} Z_t' + V_t )^-

\code{ } with error covariance

S_{t|t} = Cov(x_t-x_{t|t}) = S_{t|t-1} - K_t Z_t S_{t|t-1}

## Value

`.getDelta` calculates the covariance of Delta y_t for `S1 =`S_{t|t-1}, `Z`, `V` as above

`.getKG` calculates the Kalman Gain for `S1 =`S_{t|t-1}, `Z`, `V` as above

`.getcorrCov` calculates S_{t|t} for `S1 =` S_{t|t-1}, `K =`K_t and `Z` as above

`.getpredCov` calculates S_{t|t-1} for `S0 =` S_{t-1|t-1}, `F`, and `Q` as above

`.cKinitstep` calculates x_{0|0} for `a`, `S` as above
The return value is a list with components `x0` (the filtered value) `S0` (the filter error covariance)

`.cKpredstep` calculates x_{t|t-1} for `x0 =`x_{t-1|t-1}, `S0 =`S_{t-1|t-1}, and `F`, `Q`
The return value is a list with components `x1` (the predicted values), `S1` (the prediction error covariance), `Ind`(the indicators of clipped runs)

`.cKcorrstep` calculates x_{t|t} for `x1 =`x_{t|t-1}, `y =`y_{t}, `S1 =`S_{t|t-1}, and `Z`, `V`
The return value is a list with components `x0` (the filtered values), `K` (the Kalman gain), `S0` (the filter error covariance), `Delta` (the covariance of Delta y_t), `DeltaY` (the observation residuals Delta y_t), `Ind`(the indicators of clipped runs)

## Author(s)

Peter Ruckdeschel [email protected],

`internalrLS`