by Jennylai » Tue Jul 14, 2009 8:08 am
Dear Tom,
I am now doing the predictive testing for State Space Model. May I ask for your advice and help? The thing is this: I chop my sample into two subsamples: sub1 for insample estimation using DLM, and sub2 for out-of-sample predictive testing (which is decribed by Harvey(1989) on P271). What I want to do is to compare the out-of-sample one-step-ahead prediction error (vps1) and the insample one-step-ahead prediction error (vt1) in a formula like this:
vps1=vps1/sqrt(svps1), vt1=vt1/sqrt(gt(1,1)) (standardize those two groups of prediction errors so that they will have the distribution of NID(0, sigmastar)).
epslon(l) = ([sum from j=1 to l (vps1(j)**2)]/l)/[sume from i=d+1 to T(vt1(i)**2)/(T-d)]
and epslon(l) has an F(l,T-d) distribution under the null.
I take reference from durkp162.r and the programme is as follows:
"
cal(m) 1999
open data FDI_EXPV.xls
data(format=xls,org=columns) 1999:01 2009:03 FDI AR1001MB AR1001MP AR1001MS NDF1M
...... (the middle part are the same as in durkp162.r, except that I use 'smpl' to get my sub1 period)
*
* We will 'smpl' the orginal series FDI to make way for insample estimation and out-of-sample
* predictive test. Here we use time period 1999:01 to 2008:01 for estimation.
*
smpl 1999:01 2008:01
*
dlm(method=bfgs,start=(sw=exp(2*phil)*swl~\exp(2*phis)*sws),$
y=FDI,a=a,c=c,exact,scale,sv=1.0,sw=sw,type=filter,vhat=vt,svhat=gt) / xfilter
compute sigmastar=%variance
set gt1 = gt(t)(1,1)*sigmastar
set vt1 = vt(t)(1)
set ehat = vt1/sqrt(gt1)
* Now we do the post sample predictive test for this model 2 + seasonality.
*(Here I basically want to use DLM and the estimated parameters I obtained from the above "DLM" command line to do the algorithm to obtain the X(T+j/T), Y(T+j/T), and one-step ahead prediction error during this prediction period. T+j/T reads as T+j conditional on time T)
smpl 2008:02 2009:03
dlm(y=FDI,a=a,c=c,exact,sv=sigmastar,sw=sw,x0=xsmooth(2008:01),sx0=psmooth(2008:01),$
type=filter,vhat=vps,svhat=svps) /
*
* calculate the out-of-sample one-step-ahead prediction error
*
set svps1 = svps(t)(1,1)
set vps1 = vt(t)(1)
(Exactly below this line, RATS returns an error message: ## MAT15. Subscripts Too Large or Non-Positive)
As a result, may I ask if you would give me some advice or idea of how to fix this problem?
Thank you very much for your kind help all the time!