* * Illustration from section 2.4.3 * open data nile.dat calendar 1871 data(format=free,org=columns,skips=1) 1871:1 1970:1 nile * * This is the same model as the previous example, but with type=smooth * used to get smoothed rather than filtered estimates of the states and * variances. * dlm(type=smooth,y=nile,a=1.0,c=1.0,sx0=1.e+7,sv=15099.0,sw=1469.1) / xstates vstates set a = xstates(t)(1) set p = vstates(t)(1,1) set lower = a-sqrt(p)*%invnormal(.95) set upper = a+sqrt(p)*%invnormal(.95) * * With the smoothed estimates, the first data point can be included in the * graphs without distorting the picture. * spgraph(footer="Figure 2.2. Nile data and output of state smoothing recursion",hfields=2) graph(header="Smoothed state and 90% confidence intervals") 4 # a 1871:1 * # lower 1871:1 * 2 # upper 1871:1 * 2 # nile 1871:1 * 3 graph(header="Smoothed State Variance") # p 1871:1 * spgraph(done)