Page 1 of 1

Bootstrapping ARMA Model

Posted: Tue Jul 06, 2010 10:36 am
by TomDoan
Attached is an example of a parametric bootstrap for an ARMA model. This is quite a bit trickier than an AR model because the initial conditions (in effect, the lagged residuals) have to be inferred. As a result, the observed residuals from the first few periods have a higher predictive variance than those later in the sample, so the residuals need to be standardized before being reshuffled. However, the reshuffled residuals then have to be reflated to match the predictive variance at their new location.

This uses the "innovations" form of state space representation, which updates the state given a set of forecast errors.

In addition to the parametric bootstrap, this also includes the (much simpler) instructions for generating simulations of an ARMA model using random numbers.
armabootstrap.rpf
(2.42 KiB) Downloaded 1373 times
Data file:
income.asc
(2.95 KiB) Downloaded 1133 times

Re: Bootstrapping ARMA Model

Posted: Wed Jul 07, 2010 12:36 pm
by ivory4

Code: Select all

* Bootstrap
* First, need to get the residuals and the predictive variances
*
dlm(method=solve,presample=ergodic,a=adlm,f=fdlm,y=dy-dymean,c=%unitv(%rows(adlm),1),sw=1.0,$
   type=filter,vhat=vhat,svhat=svhat) bstart bend xstates vstates

Why sw=1.0?

Re: Bootstrapping ARMA Model

Posted: Wed Jul 07, 2010 1:19 pm
by TomDoan
ivory4 wrote:

Code: Select all

* Bootstrap
* First, need to get the residuals and the predictive variances
*
dlm(method=solve,presample=ergodic,a=adlm,f=fdlm,y=dy-dymean,c=%unitv(%rows(adlm),1),sw=1.0,$
   type=filter,vhat=vhat,svhat=svhat) bstart bend xstates vstates

Why sw=1.0?
Simplicity. The scale factor cancels out if used consistently. If you put a different variance in there, it also has to be repeated in the two calculations involving %outerxx(fdlm) later:

Code: Select all

dlm(method=solve,presample=ergodic,a=adlm,f=fdlm,y=dy-dymean,c=%unitv(%rows(adlm),1),sw=1.0,$
   type=filter,vhat=vhat,svhat=svhat) bstart bend xstates vstates
...
compute [symm]  sx0=%psdinit(adlm,%outerxx(fdlm))
...
   compute sx0 =adlm*sx0*tr(adlm)+%outerxx(fdlm)

Re: Bootstrapping ARMA Model

Posted: Mon Jul 12, 2010 1:47 pm
by ivory4
What did UFORECAST do in terms of with-in sample simulation? Using simulated errors?

Re: Bootstrapping ARMA Model

Posted: Mon Jul 12, 2010 2:42 pm
by TomDoan
If you're talking about using UFORECAST with the BOOTSTRAP option, it just does a straight shuffle of the residuals and so isn't fully appropriate for a model with MA parts.

Re: Bootstrapping ARMA Model

Posted: Tue Jul 27, 2010 4:43 am
by ivory4
What about bootstrapping ARIMA model?
I would like to generate data for ARIMA model and then fit it to different variations of UC models.

I notice that data generated from this example is for deltaY.

For boxjenk(ar=2, ma=2, diffs=1) y and boxjenk(ar=2, ma=2) dy, they gave the same estimates of coefficients.
But for UC forms, Y_t=Tao_t+C_t where Tao_t=mu+Tao_t-1+eta_t; P(L)C_t=e_t; and
DeltaY_t=DTao_t+DC_t where Dtao_t=eta_t; P(L)C_t=e_t-e_t-1 are not generating the same coefficients.

This means using data generated in this example to fit UC model, I fail to get comparable results.

Is there a ARIMA equivalent function for @armadlm ?
Or no general rule is available, I need to specify manually
Manually for ARIMA(2,1,2)
A=[1 1 0|0 p1 1|0 p2 0]
F=[0 0 0|1 0 0|0 t1 t2]
c=[1 1 0]
x_t=[yt dyt-1 p2dyt-1+t1et+t2et-1]'

p1 p2 are AR coeffs, t1 t2 are MA coeffs

Re: Bootstrapping ARMA Model

Posted: Tue Jul 27, 2010 9:04 am
by TomDoan
ARMADLM will work fine for ARIMA equations as well. What happens when you Kalman filter with it is that you will get r NA's on the first residuals where r is the number of unit roots in the ARIMA model. As with the other state space model with unit roots, you bootstrap only the residuals after that point and condition on the situation after r data points.

Re: Bootstrapping ARMA Model

Posted: Tue Jul 27, 2010 9:52 am
by ivory4
It means that it works after Boxjenk(ar=2, ma=1, diffs=1)?

Re: Bootstrapping ARMA Model

Posted: Tue Jul 27, 2010 11:48 am
by TomDoan
ivory4 wrote:It means that it works after Boxjenk(ar=2, ma=1, diffs=1)?
Yes. If you do

boxjenk(ar=2,ma=1,diffs=1,define=arimaeq)

and apply armadlm to arimaeq, it will produce a valid state space representation for the ARIMA model. The differencing, after all, is just a restriction on the AR polynomial.

Re: Bootstrapping ARMA Model

Posted: Tue Jul 27, 2010 2:19 pm
by ivory4
For arima I would like to generate coeffs vector, after estimating boxjenk(ar=2,ma=2,diffs=1,constant, define=arima) dy ( Which gives the same result as boxjenk(ar=2,ma=2, constant, define=arima) y )

Code: Select all

display arima
There are six elements because of (1-L). For this Arima(2,1,2),
1.constant/? (What is this one calculated?)
2. Ph1+1
3. Ph2-1
4. -Ph2
5. theta1
6. theta2


So when I generate coeffs I need to adjust it before I use %eqnsetcoeffs

Code: Select all

compute iim=%xx, mean=%beta
dec rect f
com f = %decomp(iim)
com draw=mean + %ranmvnormal(f)

* Then put them in the equation, without adjustment it does not match

dec vect xdraw
com xdraw(1)=draw(1)   (I think this needs to be changed?)
compute xdraw(2)= draw(2,1)+1
compute xdraw(3= draw(3,1)-1
compute xdraw(4)=-draw(3,1)
com xdraw(5)=draw(4,1)
com xdraw(6)=draw(5,1)

com %eqnsetcoeffs(arima, xrdaw)

@armadlm(adlm, fdlm) arima
 

Sorry my working station has no internet connection that's why I did not copy but input the code and also there might be typos.

Re: Bootstrapping ARMA Model

Posted: Tue Jul 27, 2010 4:34 pm
by TomDoan
You can use MODIFY and VREPLACE to convert an ARMA equation to a corresponding ARIMA equation.

The constant in the reduced form representation y(t)=alpha+phi(L)y(t)+(1+theta(L))e(t) will require a "Z" component in the state space representation which is (0,0,...,alpha). How the constant in the reduced form is produced is explained in the manual---you asked about that earlier.

Code: Select all

compute iim=%xx, mean=%beta
dec rect f
com f = %decomp(iim)
com draw=mean + %ranmvnormal(f)
isn't correct for drawing from an ARMA model; it's only correct for linear models where the posterior is actually, not approximately, Normal. If you want to do random simulation inference, you need to do either importance sampling or Metropolis within Gibbs to deal with the fact that the posterior isn't a known density.