| Library: | kalman |
| See also: | kfilter ksmoother kem kemitor epscontnorm |
| Macro: | 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 | |
library("plot")
library("kalman")
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
state=setmask(state,"line","blue","thin")
obs=setmask(obs,"line","green","thin")
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")
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)]
library("plot")
library("kalman")
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
state=setmask(state,"line","blue","thin")
obs=setmask(obs,"line","green","thin")
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")
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)]
| Library: | kalman |
| See also: | kfilter ksmoother kem kemitor epscontnorm |