Lopes and Tsay’s (2011) R code

Example 1: Local level model – state filtering: Comparison of four particle filters for the local level model. For t = 1,…,n, the local level model can be written as y[t] ~ N(x[t],sig2) and x[t] ~ N(alpha*x[t-1],tau2), with initial value x[0] ~ N(m0,C0) and known quantities (alpha,sig2,tau2,m0,C0).  The four particle filters are i) bootstrap filter (Gordon et al, 1993), ii) auxiliary particle filter (Pitt and Shephard, 1999), iii) optimal bootstrap filter, and iv) optimal auxiliary particle filter.

 

Example 4: Local level model – state filtering & parameter learning: Comparison of three particle filters for the local level model when parameter learning is also taken into account.  For t=1,…,n, the model can be written as y[t]|x[t] ~ N(x[t],sig2) and x[t]|x[t-1] ~ N(alpha+beta*x[t-1],tau2), with x[0] ~ N(m0,C0), sig2 ~ IG(a0,A0), alpha|tau2 ~ N(b0[1],tau2*B0[1]), beta|tau2  ~ N(b0[2],tau2*B0[2]), tau2 ~ IG(nu0/2,nu0*tau20/2), and known quantities (m0,C0), (a0,A0), (b0,B0) and (nu0,tau20).  The three filters are i)Liu and West filter (Liu and West, 2001), ii) Storvik filter (Storvik, 2002), and iii) Particle learning (Carvalho et al., 2010)

 

Example 4: Local level model – particle learning versus MCMC: Same context as the above example:  i) Comparison of MCMC and optimal auxiliary particle filter, ii) Comparison of MCMC and particle learning.

 

Application 1: Dynamic Beta regression: Data: Brazilian monthly unemployment rate from March 2002 to December 2009. Source: Brazilian Institute for Geography and Statistics. URL: http://www.sidra.ibge.gov.br/bda/pesquisas/pme/default.asp#dead

 

Application 2: Stochastic volatility model: For t=1,…,n, the basic normal stochastic volatility model can be written as y[t]|x[t] ~ N(0,exp(x[t]/2)) and x[t]|x[t-1] ~ N(alpha+beta*x[t-1],tau2), with x[0] ~ N(m0,C0), alpha|tau2 ~ N(b0[1],tau2*B0[1]) beta|tau2  ~ N(b0[2],tau2*B0[2]), where tau2 ~ IG(nu0/2,nu0*tau20/2)  and known hyper-parameters m0,C0,b0,B0,nu0 and tau20.  Data: Monthly log returns of GE stock.  Period: January 1926 to December 1999 (888 observations).  Source: Tsay (2005), Chapter 12, Example 12.6, page 591.

http://faculty.chicagobooth.edu/ruey.tsay/teaching/fts2/m-geln.txt

 

Application 3: Realized volatility: We entertain two realized volatility models:  (i) Three RV time series are modeled by independent univariate local level models (ii) Trivariate vector of RV time series is modeled by a multivariate local level.  Data: Intradaily realized volatility of Alcoa stock (5m, 10m, 20m) from 2 January 2003 to 7 May 2004 for 340 observations.  The daily realized volatilities used are the the sums of squares of intraday 5 min, 10 min and 20 min log returns measured in percentages.  Tsay (2005), Chapter 11: State-Space Models and Kalman Filter.  http://faculty.chicagobooth.edu/ruey.tsay/teaching/fts2/aa-3rv.txt.