Modeling structure

In this lecture we model observed time series data \(\{y_1,\ldots,y_n\}\) as a normal dynamic linear model (NDLM) with observation equation given by \[ y_t = x_t + v_t \qquad v_t \sim N(0,V), \] and system equation given by \[ x_t = \phi x_{t-1} + w_t \qquad w_t \sim N(0,W), \] and initial distribution \(x_0 \sim N(m_0,C_0)\).

The R funtion sim.dlm simulates data from the above NDLM:

sim.dlm = function(n,phi,V,W){
  sV  = sqrt(V)
  sW  = sqrt(W)
  x = rep(0,n)
  x[1] = rnorm(1,0,sW)
  for (t in 2:n)
    x[t] = rnorm(1,phi*x[t-1],sW)
  y = rnorm(n,x,sV)
  return(list(y=y,x=x))
}

Simulating time series data

We simulate a time series of \(n=200\) observations from \(x_0=0\), \(V=1\), \(W=0.25\) and \(\phi=0.95\).

set.seed(12345)
n   = 200
V   = 1.00
W   = 0.25
phi = 0.95
sim = sim.dlm(n,phi,V,W)
y   = sim$y
x   = sim$x

par(mfrow=c(1,1))
ts.plot(y,type="b",ylab="",main="y(t) vs x(t)")
lines(x,col=2,type="b")