* * Illustration 2.6 from pp 57-60 * ?? Correct this - x(1|0) ?? * open data table2_2.xls calendar(m) 1975 data(format=xls,org=columns) 1975:1 1984:7 usukxrate set usukxrate = usukxrate*.01 * graph(footer="Figure 2.6 USA/UK exchange rate index") # usukxrate * report(action=define) report(atrow=1,atcol=1) "delta" "MAD" "RMSE" "LLR" report(atrow=1,atcol=5,tocol=6,span) "90% Interval" report(atrow=1,atcol=7) "SD" * * In all the examples in the text, when a discount is used, it does *not* apply to * the initial time period. With DLM, sx0 is treated as the actual pre-sample * variance, and does get discounted. To match the results in the text, the sx0 * matrix needs to be multiplied by the discount. * dofor [real] delta = 1.0 0.9 0.8 0.7 dlm(y=usukxrate,a=1.0,c=1.0,sv=1.0,sx0=delta,discount=delta,$ variance=chisquare,pdf=1.0,pscale=.01,yhat=yhat) / xstates vstates set fcst = yhat(t)(1) @uforeerrors(noprint) usukxrate fcst compute gap=%invttest(.05,116)*sqrt(%variance*vstates(1984:7)(1,1)) if delta==1.0 compute baselogl=%logl,llr=0.0 else compute llr=%logl-baselogl report(row=new,atcol=1) delta %%ferrmae %%ferrmse llr xstates(1984:7)(1)-gap xstates(1984:7)(1)+gap sqrt(%variance) end dofor report(action=format,picture="*.###") report(action=show) * * Calculate the forecast specifically for delta=1.0 and delta=0.8 * dlm(y=usukxrate,a=1.0,c=1.0,sx0=1.0,sv=1.0,discount=1.0,$ variance=chisquare,pdf=1.0,pscale=.01,yhat=yhat) / xstates vstates set fcst10 = yhat(t)(1) dlm(y=usukxrate,a=1.0,c=1.0,sx0=0.8,sv=1.0,discount=0.8,$ variance=chisquare,pdf=1.0,pscale=.01,yhat=yhat) / xstates vstates set fcst08 = yhat(t)(1) * graph(footer="Figure 2.7 USA/UK exchange rate index and forecasts",overlay=dots,ovsame) 3 # fcst10 # fcst08 # usukxrate