* * Chapter 4, UK inflation data * open data ukinflation.txt calendar(q) 1950 data(format=free,org=columns,skips=1) 1950:01 2001:04 ukinflation * * Rescaling data to percentages helps quite a bit by increasing the * variances by a factor of 10^4. * set ukinflation = ukinflation*100.0 * * Create the component models for the level and seasonal. * @LocalDLM(type=level,a=al,c=cl,f=fl) @SeasonalDLM(type=additive,a=as,c=cs,f=fs) * * Glue them together to make the full system matrices * compute a=al~\as,f=fl~\fs,c=cl~~cs * @LocalDLMInit(deseasonalize,irreg=sigsqeps) ukinflation * * Same model with variances freed * nonlin sigsqeps sigsqxi sigsqomega compute sigsqxi=sigsqeps*.01,sigsqomega=sigsqeps*.01 * dlm(a=a,c=c,sv=sigsqeps,f=f,sw=%diag(||sigsqxi,sigsqomega||),exact,y=ukinflation,$ method=bfgs,vhat=vhat,svhat=svhat) set resids = %scalar(vhat)/sqrt(%scalar(svhat)) @STAMPDiags(ncorrs=15) resids * dlm(a=a,c=c,sv=sigsqeps,f=f,sw=%diag(||sigsqxi,sigsqomega||),exact,y=ukinflation,$ type=smooth) / xstates set level = xstates(t)(1) set irreg = ukinflation-level set seasonal = xstates(t)(2) set fitted = %dot(c,xstates) * spgraph(vfields=3,footer="Figure 4.10 UK inflation series",samesize) graph(key=upleft,klabels=||"quarterly price changes in UK","stochastic level"||) 2 # ukinflation # level graph(key=upleft,klabels=||"stochastic seasonal"||) # seasonal graph(key=upleft,klabels=||"irregular"||) # irreg spgraph(done)