Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 Quantlet: kemitor2 Description: Simulates observations and states of a given state-space-model - just as kemitor by Petr Franek (quantlib times) - but this time also the states are returned. The state-space model is assumed to be in the following form: y_t = H x_t + ErrY_t x_t = F x_t-1 + ErrX_t x_0 = mu

 Usage: {X,Y} = kemitor2(T,mu,H,F,ErrY,ErrX) Input: T number of observations to be generated mu n x 1 vector (starting point of the model) H m x n matrix F n x n matrix ErrY T x m matrix of errors ErrX T x n matrix of errors Output: X T x n matrix of generated states, T is the number of generated states, n is the dimension of generated states Y T x m matrix of generated time series, T is the number of generated observations, m is the dimension of generated time series

Example:
```library("plot")
library("kalman")
c.f. original kemitor by P.Franek for more examples
randomize(0)
T = 100
mu=0
H = 1
F = 1
mid=0
Cid=1
mcont=10
Ccont=0.1
eps=0.1
ErrX = normal(T)
ErrY = epscontnorm(T,eps,mid,Cid,mcont,Ccont,0)
sim = kemitor2(T,mu,H,F,ErrY,ErrX)
state =(1:100)~(sim.X)
obs=(1:100)~(sim.Y)
ind =(ErrY.Ind)
ind=ind/ind*0 ;           sets all "0" to missing and all "1" to 0
ind =(1:100)~ind
setmaskp(ind,4, 3, 8)  ;       on all contam. instances a red flag is plotted
disp = createdisplay(1,1)
show(disp,1,1,state,obs,ind)
setgopt(disp,1,1, "title", "State Space Model(1 - dim steady state) under AO")

```
Result:
```Generates a simulation of length 100 of a steady state model (i.e. H=R=Q=F=1)
under a convex contaminated ErrY (AO) [radius=0.1, K=N(10,0.1)]
```
Example:
```library("plot")
library("kalman")
c.f. original kemitor by P.Franek for more examples
randomize(0)
T = 100
mu=0
H = 1
F = 1
mid=0
Cid=1
mcont=10
Ccont=0.1
eps=0.1
ErrY = normal(T)
ErrX = epscontnorm(T,eps,mid,Cid,mcont,Ccont,0)
sim = kemitor2(T,mu,H,F,ErrY,ErrX)
state =(1:100)~(sim.X)
obs=(1:100)~(sim.Y)
ind =(ErrX.Ind)
ind=ind/ind*0 ;           sets all "0" to missing and all "1" to 0
ind=(1:100)~ind
setmaskp(ind,4, 3, 8)  ;       on all contam. instances a red flag is plotted
disp = createdisplay(1,1)
show(disp,1,1,state,obs,ind)
setgopt(disp,1,1, "title", "State Space Model(1 - dim steady state) under IO")

```
Result:
```Generates a simulation of length 100 of a steady state model (i.e. H=R=Q=F=1)
under a convex contaminated ErrX (IO) [radius=0.1, K=N(10,0.1)]
```

Author: P. Ruckdeschel, 19991018
(C) MD*TECH Method and Data Technologies, 05.02.2006