# Routines for the simulation of AO-contaminated state space models

### Description

For testing purposes, with these routines, AO-contaminated observations from a multivariate time-invariant, linear, Gaussian state space model may be generated

### Usage

 1 2 3 rcvmvnorm(runs, mi, Si, mc, Sc, r) simulateState(a, S, F, Qi, mc=0, Qc=Qi, runs = 1, tt, r=0) simulateObs(X, Z, Vi, mc=0, Vc=Vi, runs = 1, r=0) 

### Arguments

 runs number of runs to be generated mi mean of the ideal multivariate normal distribution mc mean of the contaminating multivariate normal distribution Si covariance of the ideal multivariate normal distribution Sc covariance of the contaminating multivariate normal distribution r convex contamination radius/probability a mean of the initial state S initial state covariance (see below) F innovation transition matrix (see below) Qi ideal innovation covariance (see below) Qc contaminating innovation covariance (see below) tt length of the simulated series of states/observations Z observation matrix (see below) Vi ideal observation error covariance (see below) mc contaminating observation error mean (see below) Vc contaminating observation error covariance (see below) X series of states on basis of which the observations are simulated

### Details

We work in the setup of the time-invariant, linear, Gaussian state space model (ti-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 x_{t-1} + v_t, v_t ~ N_p(0,Q), t>=1,

ideal observation equation

y_t = Z x_t + e_{t;id}, e_{t;id} ~ N_q(0,V_i), t>= 1,

realistic observation equation

y_t = Z x_t + e_{t;re}, e_{t;re} ~ (1-r) N_q(0,V_i) + r N_q(m_c,V_c), t>= 1,

and where all random variable x_0, v_t, e_{t;id} [respectively, e_{t;re}] 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 x_{t-1|t-1}, t>=1

\code{ } with error covariance

S_{t|t-1} = Cov(x_t-x_{t|t-1}) = F S_{t-1|t-1} F' + Q

(2) correction step

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

\code{ } for Kalman Gain

K_t = S_{t|t-1} Z' (Z S_{t|t-1} Z' + V )^-

\code{ } with error covariance

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

### Value

rcvmvnorm(mi, Si, mc, Sc, r) returns a (pseudo) random variable drawn from

(1-r){\cal N}_q(m_i,S_i)+r {\cal N}_q(m_c,S_c)

simulateState simulates a series of t=tt states plus one initial state from the (ti-l-G-SSM) given by the Hyper parameters — yielding a matrix p x (t+1)
simulateObs, on bases of the series of states X (initial state included) simulates a series of observations of length tt according to the Hyper parameters — giving a matrix q x t

### Author(s)

Peter Ruckdeschel Peter.Ruckdeschel@itwm.fraunhofer.de,

internalrLS
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 require(robKalman) a0 <- c(1, 0) SS0 <- matrix(0, 2, 2) F0 <- matrix(c(.7, 0.5, 0.2, 0), 2, 2) Q0 <- matrix(c(2, 0.5, 0.5, 1), 2, 2) TT <- 100 Z0 <- matrix(c(1, -0.5), 1, 2) V0i <- 1 m0c <- -30 V0c <- 0.1 ract <- 0.1 X <- simulateState( a = a0, S = SS0, F = F0, Qi = Q0, tt = TT) Y <- simulateObs(X = X, Z = Z0, Vi = V0i, mc = m0c, Vc = V0c, r = ract)