<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/non-gaussian-time-series-lets-handle-it-with-score-driven-models/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://insightr.wordpress.com/2017/06/07/non-gaussian-time-series-lets-handle-it-with-score-driven-models/"> R – insightR</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><strong>By Henrique Helfer</strong></p>
<h2>Motivation</h2>
<p>Until very recently, only a very limited classes of feasible non Gaussian time series models were available. For example, one could use extensions of state space models to non Gaussian environments (see, for example, Durbin and Koopman (2012)), but extensive Monte Carlo simulation is required to numerically evaluate the conditional densities that define the estimation process of such models.</p>
<p><span></span></p>
<p>The high technicalities involved in implementing these algorithms and its accompanying computational cost have not helped its widespread use by practitioners. On the other hand, different attempts to extend ARMA type models with conditional non Gaussian distributions have been more successful. For example, the use of GARCH type models to deal with heavy tailed distributions in finance (Engle and Bollerslev (1986)), the Autoregressive Conditional Duration (ACD) model of Engle and Russell (1998) to tackle asymmetric distributions in time duration and the Poisson count models of Davis et al (2003) for the modelling of discrete events in time. But, so far, these extensions have lacked an unifying framework that would allow the specification, estimation and forecasting of a model based on an arbitrary non Gaussian distribution. The recently proposed Generalized Autoregressive Scores (GAS) models by Creal et al (2008, 2013), or dynamic conditional score (DCS) from Harvey (2013), offer an unifying framework to derive and estimate time series model with any conditional non-Gaussian distribution, either discrete or continuous, univariate or multivariate. More specifically, in GAS models, conditional on past observations, a proper probability model, possibly non Gaussian, is chosen for the response variable at time <img alt="t " title="t " src="https://s0.wp.com/latex.php?latex=t+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">. Then, by construction, time varying parameters can be accommodated according to an updating mechanism that uses the score as its driving force. The use of the score for updating time-varying parameters is intuitive given that it defines the steepest ascent direction for improving the model’s local fit in terms of the likelihood or density at time <img alt="t " title="t " src="https://s0.wp.com/latex.php?latex=t+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, given the current parameter position. In such an updating mechanism information from the whole density is used to track the evolution of time varying parameters.</p>
<p>Of course, in this post I will briefly explain the estimation framework of such models for our community, however I deeply encourage you our fellow “insighteR” to pay a visit to <a rel="nofollow" href="http://gasmodel.com/" target="_blank">gasmodel.com</a>, where you can find a whole section devoted to GAS models papers and see for yourself the diversity of applications.</p>
<h2>Score driven models</h2>
<p>First of all, one should choose an specific distribution which support accommodates the range of values assumed by the time series of interest <img alt="y_t " title="y_t " src="https://s0.wp.com/latex.php?latex=y_t+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">,</p>
<p align="”center”"><img alt="displaystyle p(y_{it}|f_{it},mathcal{F}_{t-1};theta) " title="displaystyle p(y_{it}|f_{it},mathcal{F}_{t-1};theta) " src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+p%28y_%7Bit%7D%7Cf_%7Bit%7D%2C%5Cmathcal%7BF%7D_%7Bt-1%7D%3B%5Ctheta%29+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p>where <img alt="f_{t}" title="f_{t}" src="https://s0.wp.com/latex.php?latex=f_%7Bt%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> is the time varying parameter vector, while <img alt="theta" title="theta" src="https://s0.wp.com/latex.php?latex=%5Ctheta&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> makes reference to the fixed parameter vector that will be estimated by maximum likelihood and <img alt="mathcal{F}_{t-1}" title="mathcal{F}_{t-1}" src="https://s0.wp.com/latex.php?latex=%5Cmathcal%7BF%7D_%7Bt-1%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> collects all relevant information up to time <img alt="t-1" title="t-1" src="https://s0.wp.com/latex.php?latex=t-1&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">.</p>
<p>Next, to fully specify a GAS model, one has to choose which parameters of the distribution will evolve in time and those that will be fixed. The time varying parameters will then follow a GAS(p,q) updating mechanism given by:</p>
<p align="”center”"><img alt="displaystyle {f}_{t+1} = omega + sum_{i=1}^{p} A_{i}s_{t-i+1} + sum_{j=1}^{q} B_{j}f_{t-j+1} " title="displaystyle {f}_{t+1} = omega + sum_{i=1}^{p} A_{i}s_{t-i+1} + sum_{j=1}^{q} B_{j}f_{t-j+1} " src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%7Bf%7D_%7Bt%2B1%7D+%3D+%5Comega+%2B+%5Csum_%7Bi%3D1%7D%5E%7Bp%7D+A_%7Bi%7Ds_%7Bt-i%2B1%7D+%2B+%5Csum_%7Bj%3D1%7D%5E%7Bq%7D+B_%7Bj%7Df_%7Bt-j%2B1%7D+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p>where <img alt="(omega, A, B) in theta" title="(omega, A, B) in theta" src="https://s0.wp.com/latex.php?latex=%28%5Comega%2C+A%2C+B%29+%5Cin+%5Ctheta&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">.</p>
<p>To complete the description of the the updating mechanism of GAS models it is necessary to define the score <img alt="s_{t}" title="s_{t}" src="https://s0.wp.com/latex.php?latex=s_%7Bt%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> given by,</p>
<p align="”center”"><img alt="displaystyle s_{t} = mathcal{I}_{t|t-1}^{-d} cdot nabla_{t} " title="displaystyle s_{t} = mathcal{I}_{t|t-1}^{-d} cdot nabla_{t} " src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+s_%7Bt%7D+%3D+%5Cmathcal%7BI%7D_%7Bt%7Ct-1%7D%5E%7B-d%7D+%5Ccdot+%5Cnabla_%7Bt%7D+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p align="”center”"><img alt="displaystyle nabla_{t} = frac{partial ln p(y_{t}|f_{t},mathcal{F}_{t-1};theta)}{partial f_{t}} " title="displaystyle nabla_{t} = frac{partial ln p(y_{t}|f_{t},mathcal{F}_{t-1};theta)}{partial f_{t}} " src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5Cnabla_%7Bt%7D+%3D+%5Cfrac%7B%5Cpartial+%5Cln+p%28y_%7Bt%7D%7Cf_%7Bt%7D%2C%5Cmathcal%7BF%7D_%7Bt-1%7D%3B%5Ctheta%29%7D%7B%5Cpartial+f_%7Bt%7D%7D+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p align="”center”"><img alt="displaystylemathcal{I}_{t|t-1} = E_{t|t-1}[nabla_{t}^Tnabla_{t}] " title="displaystylemathcal{I}_{t|t-1} = E_{t|t-1}[nabla_{t}^Tnabla_{t}] " src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle%5Cmathcal%7BI%7D_%7Bt%7Ct-1%7D+%3D+E_%7Bt%7Ct-1%7D%5B%5Cnabla_%7Bt%7D%5ET%5Cnabla_%7Bt%7D%5D+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p>where <img alt="p(y_{t}|f_{t},mathcal{F}_{t-1};theta)" title="p(y_{t}|f_{t},mathcal{F}_{t-1};theta)" src="https://s0.wp.com/latex.php?latex=p%28y_%7Bt%7D%7Cf_%7Bt%7D%2C%5Cmathcal%7BF%7D_%7Bt-1%7D%3B%5Ctheta%29&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> is the observation density function and <img alt="mathcal{I}_{t|t-1}" title="mathcal{I}_{t|t-1}" src="https://s0.wp.com/latex.php?latex=%5Cmathcal%7BI%7D_%7Bt%7Ct-1%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> is a scaling matrix with appropriate dimensions. Different choices of <img alt="d" title="d" src="https://s0.wp.com/latex.php?latex=d&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> results in different GAS models: <img alt="d=1" title="d=1" src="https://s0.wp.com/latex.php?latex=d%3D1&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> means that it will be use the inverse of Fisher Information matrix, <img alt="d=frac{1}{2}" title="d=frac{1}{2}" src="https://s0.wp.com/latex.php?latex=d%3D%5Cfrac%7B1%7D%7B2%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> the pseudo-inverse of Fisher Information matrix <img alt="d=0" title="d=0" src="https://s0.wp.com/latex.php?latex=d%3D0&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> the identity matrix.</p>
<h3>Parametrization</h3>
<p>If we assume for instance the intensity of a poisson density, <img alt="lambda_{t}&gt;0" title="lambda_{t}&gt;0" src="https://s0.wp.com/latex.php?latex=%5Clambda_%7Bt%7D%3E0&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, it is natural to choose <img alt="f_t = ln(lambda_{t})" title="f_t = ln(lambda_{t})" src="https://s0.wp.com/latex.php?latex=f_t+%3D+ln%28%5Clambda_%7Bt%7D%29&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">. From this, the previous Equations should also be re-parametrized with regard to <img alt="ln(lambda_t)" title="ln(lambda_t)" src="https://s0.wp.com/latex.php?latex=%5Cln%28%5Clambda_t%29&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">. Considering a monotonically increasing mapping function <img alt="h(cdot)" title="h(cdot)" src="https://s0.wp.com/latex.php?latex=h%28%5Ccdot%29&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, then <img alt="tilde{f}_{t}=h(f_{t})" title="tilde{f}_{t}=h(f_{t})" src="https://s0.wp.com/latex.php?latex=%5Ctilde%7Bf%7D_%7Bt%7D%3Dh%28f_%7Bt%7D%29&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">. Taking <img alt="dot{h_{t}} = partial frac{h(f_{t})}{f_{t}'}" title="dot{h_{t}} = partial frac{h(f_{t})}{f_{t}'}" src="https://s0.wp.com/latex.php?latex=%5Cdot%7Bh_%7Bt%7D%7D+%3D+%5Cpartial+%5Cfrac%7Bh%28f_%7Bt%7D%29%7D%7Bf_%7Bt%7D%27%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, the poisson GAS specification updating mechanism, will be</p>
<p align="”center”"><img alt="displaystyle dot{h}_{t} = frac{1}{lambda_{t}} " title="displaystyle dot{h}_{t} = frac{1}{lambda_{t}} " src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5Cdot%7Bh%7D_%7Bt%7D+%3D+%5Cfrac%7B1%7D%7B%5Clambda_%7Bt%7D%7D+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p align="”center”"><img alt="displaystyle tilde{nabla_{t}}= (dot{h}_{t})^{-1}nabla_{t}" title="displaystyle tilde{nabla_{t}}= (dot{h}_{t})^{-1}nabla_{t}" src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5Ctilde%7B%5Cnabla_%7Bt%7D%7D%3D+%28%5Cdot%7Bh%7D_%7Bt%7D%29%5E%7B-1%7D%5Cnabla_%7Bt%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<h2>Application</h2>
<p>To elucidate a potential application, in this section we will generate and model a cont time series using GAS framework. More specifically, we will adopt a poisson density with its intensity parameter <img alt="lambda_t=ln(f_t)" title="lambda_t=ln(f_t)" src="https://s0.wp.com/latex.php?latex=%5Clambda_t%3Dln%28f_t%29&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> being updated trough a GAS mechanism. Also we will fix <img alt="d=1" title="d=1" src="https://s0.wp.com/latex.php?latex=d%3D1&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> as scaling matrix. Following Table 1 from Creal et al (2008), the score is given by,</p>
<p align="”center”"><img alt="displaystyle s_{t} = (y_t - lambda_t) times lambda_t " title="displaystyle s_{t} = (y_t - lambda_t) times lambda_t " src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+s_%7Bt%7D+%3D+%28y_t+-+%5Clambda_t%29+%5Ctimes+%5Clambda_t+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p>First of all, let’s create a function which simulates a cont time series from a poisson model with its intensity parameter <img alt="lambda_t" title="lambda_t" src="https://s0.wp.com/latex.php?latex=%5Clambda_t&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> following a GAS mechanism.</p>
<p> </p>
<pre>##################################
#### GENERATING DGP
##################################
A = 0.101
B = -0.395
w = 0.183

GAS_POISSON_GENERATE = function (w,A,B,size){
  y = f = s  = NULL

  ###############################################
  # Initial conditions for the recursion:
  ###############################################
  t=1
  f[1] = 1
  y[1] = rpois(1,f[1])

  ###############################################
  # GAS mechanism:
  ###############################################

  for (t in 1:size){

    s[t] = (y[t]-exp(f[t]))*(exp(f[t]))

    f[t+1] = w + A * s[t] + B * f[t]

    y[t+1] = rpois(1,exp(f[t+1]))

  }

  return(list(&quot;y&quot;=y,&quot;f&quot;=f))

}
</pre>
<p>In the sequel, one can simulate the values of a cont time-series using the previous function. For instance, let us simulate a time series of size 1000 with <img alt="A = 0.101" title="A = 0.101" src="https://s0.wp.com/latex.php?latex=A+%3D+0.101&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, <img alt="B = -0.395" title="B = -0.395" src="https://s0.wp.com/latex.php?latex=B+%3D+-0.395&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> and <img alt="w = 0.183" title="w = 0.183" src="https://s0.wp.com/latex.php?latex=w+%3D+0.183&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">.</p>
<pre>set.seed(201930)
serie.sim = GAS_POISSON_GENERATE(w,A,B,1000)

par(mfrow=c(2,1))
ts.plot(serie.sim$y,ylab = &quot;y&quot;)
ts.plot(exp(serie.sim$f),ylab = &quot;lambda&quot;)
</pre>
<p><img alt="plot of chunk unnamed-chunk-2" src="https://i0.wp.com/i.imgur.com/4RHAVjz.png"></p>
<p>To estimate the values of <img alt="theta" title="theta" src="https://s0.wp.com/latex.php?latex=%5Ctheta&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, we will use Maximum likelihood as described in the original paper of Creal et al. (2013). To do this in R, we need to create a function which will maximize some quantity, i.e., log-likelihood.</p>
<pre>##################################
#### ESTIMATING ML
##################################
GAS_POISSON = function (q, y=y){

  A = q[1]
  B = q[2]
  w = q[3]

  #####

  n = length(y)
  s = NULL
  f = NULL
  #####

  f[1] = 0

  for (t in 1 : n){
    s[t] = (y[t]-exp(f[t]))*(exp(f[t]))

    f[t+1] = w + A * s[t] + B * f[t]
  }

  # Here we have the loglikelihood.
  sum = 0
  for (t in 2:length(y)){
    sum = sum + dpois(y[t], lambda = exp(f[t]), log = TRUE)
  }

  return(sum/n)
}
</pre>
<p>With the Maximum likelihood function in hands, we can do the parameter optimization, using as initial condition for the parameters in <img alt="theta" title="theta" src="https://s0.wp.com/latex.php?latex=%5Ctheta&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> a uniform between 0 and 0.1.</p>
<pre>f = NULL; s= NULL
y = serie.sim$y
set.seed(8456)
result =  optim(runif(3,0,0.1), y=y,GAS_POISSON , method=&quot;BFGS&quot;, hessian=TRUE, control=list(fnscale=-1))
param = result$par
</pre>
<p>The standard errors can be calculated using the Hessian inverse evaluated at the optimum point, i.e., under some mild conditions, the maximum likelihood estimator <img alt="hat{theta}" title="hat{theta}" src="https://s0.wp.com/latex.php?latex=%5Chat%7B%5Ctheta%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> of <img alt="theta" title="theta" src="https://s0.wp.com/latex.php?latex=%5Ctheta&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> is consistent and converges in distribution to</p>
<p align="”center”"><img alt="displaystyle  sqrt{n}(hat{theta} - theta) overset{d}{to} N(0,H^{-1}) " title="displaystyle  sqrt{n}(hat{theta} - theta) overset{d}{to} N(0,H^{-1}) " src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle%C2%A0+%5Csqrt%7Bn%7D%28%5Chat%7B%5Ctheta%7D+-+%5Ctheta%29+%5Coverset%7Bd%7D%7B%5Cto%7D+N%280%2CH%5E%7B-1%7D%29+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p> </p>
<pre>hessian = -solve(as.matrix((length(y))*result$hessian))
inv.hessian = hessian
stderrors = array(0,length(param))
for (t in 1:length(param)){stderrors[t] = sqrt(hessian[t,t])}

estim = cbind(param,stderrors)
estim
</pre>
<pre>##            param  stderrors
## [1,]  0.07543154 0.01999293
## [2,] -0.56880833 0.11422324
## [3,]  0.20280978 0.05132407
</pre>
<p>Regarding the forecasting, similar to GARH models, the <img alt="k" title="k" src="https://s0.wp.com/latex.php?latex=k&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> steps ahead distribution conditional on observations up to time <img alt="t" title="t" src="https://s0.wp.com/latex.php?latex=t&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, <img alt="p(y_{t+k}|mathcal{F}_{t} )" title="p(y_{t+k}|mathcal{F}_{t} )" src="https://s0.wp.com/latex.php?latex=p%28y_%7Bt%2Bk%7D%7C%5Cmathcal%7BF%7D_%7Bt%7D+%29&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, is only analytical for <img alt="k=1" title="k=1" src="https://s0.wp.com/latex.php?latex=k%3D1&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, when it coincides with the chosen probability model. However, for <img alt="k&gt;1" title="k&gt;1" src="https://s0.wp.com/latex.php?latex=k%3E1&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> it has to be evaluated using Monte Carlo simulation.</p>
<p>But first, let us create a function to calculate the series of time-varying parameters with our estimated parameters, <img alt="hat{theta}" title="hat{theta}" src="https://s0.wp.com/latex.php?latex=%5Chat%7B%5Ctheta%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">.</p>
<pre>GAS_POISSON_CALCULATE = function (par,y){
  A = par[1] ; B = par[2] ; w=par[3]
  f = s  = NULL

  f[1] = 0
  n = length(y)
  #####

  for (t in 1 : n){
    s[t] = (y[t]-exp(f[t]))*(exp(f[t]))

    f[t+1] = w + A * s[t] + B * f[t]
  }
  #####

  return(list(&quot;y&quot;=y,&quot;f&quot;=f))

}

# Here we save the time varying parameter series
model.values = GAS_POISSON_CALCULATE(result$par,y)
</pre>
<p>Now we can use the last point of <img alt="f_t" title="f_t" src="https://s0.wp.com/latex.php?latex=f_t&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> series to obtain an “initial condition” for the forecasting simulation. Let us create a function to calculate our predictions with confidence intervals.</p>
<pre>GAS_POISSON_FORECATING = function(f.mod,steps.ahead,par){

  f = f.mod[length(f.mod)]

  ##################################################
  n.sim=2000 # Number of Monte Carlo Simulations
  dens.pred = matrix(NA,steps.ahead,n.sim) # Matrix of simulated values with dimension steps ahead x MC simulations
  f.prev = NULL # simulated series of time-varying parameter f for each MC
  s.prev = NULL # simulated series of score s

  # Estimated parameters from theta
  A = par[1] ; B = par[2] ; w=par[3]
  ##################################################

  for(j in 1:n.sim){

    #f.prev[1] = f[length(y)+1]
    f.prev[1] = f

    for (t in 1:steps.ahead){

      dens.pred[t,j] = rpois(1, lambda = exp(f.prev[t])) # generate a random poisson value with intensity parameter modeled by GAS

      s.prev[t] = (dens.pred[t,j]-exp(f.prev[t]))*(exp(f.prev[t])) # calculate the score

      f.prev[t+1] = w + A*s.prev[t] + B*f.prev[t] # update lambda

    }
    f.prev = NULL
    s.prev = NULL
  }

  ##################################################
  # Here we calculate the expected value of the predictive density and calculate the confidence intervals
  forecasting = NULL
  CI.sup = NULL
  CI.inf = NULL
  for(i in 1:steps.ahead){
    forecasting[i]=mean(dens.pred[i,])
    CI.sup[i] = quantile(dens.pred[i,],probs=0.975)
    CI.inf[i] = quantile(dens.pred[i,],probs=0.025)
  }

  return(list(&quot;forecasting&quot;=forecasting,&quot;CI.sup&quot; = CI.sup, &quot;CI.inf&quot; = CI.inf))
}
</pre>
<p>With the forecasting function already defined, one should only use as input the last value of the series <img alt="f_t" title="f_t" src="https://s0.wp.com/latex.php?latex=f_t&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, the number of steps ahead and <img alt="hat{theta}" title="hat{theta}" src="https://s0.wp.com/latex.php?latex=%5Chat%7B%5Ctheta%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">.</p>
<pre>forecast = GAS_POISSON_FORECATING(model.values$f,5,result$par)

final.pred = cbind(forecast$forecasting,forecast$CI.sup,forecast$CI.inf)
colnames(final.pred) = c(&quot;Mean&quot;, &quot;UB&quot;, &quot;LB&quot;)
print(final.pred)
</pre>
<pre>##        Mean UB LB
## [1,] 1.0320  3  0
## [2,] 1.2320  4  0
## [3,] 1.1270  4  0
## [4,] 1.1615  4  0
## [5,] 1.1125  3  0
</pre>
<h2>References</h2>
<p>Creal, D., Koopman, S. J., &amp; Lucas, A. (2008). A general framework for observation driven time-varying parameter models, Tinbergen Institute,Tech. Rep.</p>
<p>Creal, D., Koopman, S. J., &amp; Lucas, A. (2013). Generalized autoregressive score models with applications. Journal of Applied Econometrics, 28(5), 777-795.</p>
<p>Davis, R. A., Dunsmuir, W. T., &amp; Streett, S. B. (2003). Observation-driven models for Poisson counts. Biometrika, 777-790.</p>
<p>Durbin, J., &amp; Koopman, S. J. (2012). Time series analysis by state space methods (Vol. 38). OUP Oxford.</p>
<p>Engle, R. F., &amp; Bollerslev, T. (1986). Modelling the persistence of conditional variances. Econometric reviews, 5(1), 1-50.</p>
<p>Engle, R. F., &amp; Russell, J. R. (1998). Autoregressive conditional duration: a new model for irregularly spaced transaction data. Econometrica, 1127-1162.</p>
<p>Harvey, A. C. (2013). Dynamic models for volatility and heavy tails: with applications to financial and economic time series (Vol. 52). Cambridge University Press.</p>
<p> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/insightr.wordpress.com/312/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/comments/insightr.wordpress.com/312/"></a> <img border="0" alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" data-recalc-dims="1"></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://insightr.wordpress.com/2017/06/07/non-gaussian-time-series-lets-handle-it-with-score-driven-models/"> R – insightR</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...

	<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/XFsYBZru9XY" height="1"></a></div>