* * Illustration from section 2.8.1 * Out-of-sample forecasting * open data nile.dat calendar 1871 data(format=free,org=columns,skips=1) 1871:1 1970:1 nile * * To forecast out of sample, just run the filter beyond the range of the existing * data. * dlm(y=nile,a=1.0,c=1.0,sx0=1.e+7,sv=15099.0,sw=1469.1,yhat=yhat,svhat=fhat) $ 1871:1 2000:1 xstates vstates set a * 2000:1 = xstates(t)(1) set p * 2000:1 = vstates(t)(1,1) set lower * 2000:1 = a-%invnormal(.75)*sqrt(p) set upper * 2000:1 = a+%invnormal(.75)*sqrt(p) set f * 2000:1 = fhat(t)(1,1) set y * 2000:1 = yhat(t)(1) * spgraph(footer="Figure 2.6. Nile data and output of forecasting",vfields=2,hfields=2) graph(header="State forecast and 50% confidence intervals") 4 # a 1872:1 2000:1 # nile 1871:1 * # upper 1872:1 2000:1 3 # lower 1872:1 2000:1 3 graph # y 1872:1 2001:1 graph # p 1872:1 2000:1 graph # f 1872:1 2000:1 spgraph(done)