* * Chapter 7, 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 pulse dummies * set d1975q2 = (t==1975:2) set d1979q3 = (t==1979:3) * * Create the standard level + seasonal model * @LocalDLM(type=level,a=al,c=cl,f=fl) @SeasonalDLM(type=additive,a=as,c=cs,f=fs) compute a=al~\as,f=fl~\fs,c=cl~~cs * seasonal seasons linreg ukinflation # constant d1975q2 d1979q3 seasons{0 to -2} * compute del1=%beta(2),del2=%beta(3) compute sigsqeps=%sigmasq * nonlin sigsqeps sigsqxi sigsqomega del1 del2 compute sigsqxi=sigsqeps*.01,sigsqomega=sigsqeps*.01 * frml explan = del1*d1975q2+del2*d1979q3 dlm(a=a,c=c,sv=sigsqeps,f=f,sw=%diag(||sigsqxi,sigsqomega||),exact,y=ukinflation-explan,$ 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-explan,$ type=smooth) / xstates set fitted = %dot(c,xstates) set seasonal = xstates(t)(2) set fitplus = fitted+explan set irreg = ukinflation-fitplus * spgraph(vfields=3,footer="Figure 7.7 UK inflation series",samesize) graph(key=upleft,klabels=||"quarterly price changes in UK","stochastic level+intervention variables"||) 2 # ukinflation # fitplus graph(key=upleft,klabels=||"stochastic seasonal"||) # seasonal graph(key=upleft,klabels=||"irregular"||) # irreg spgraph(done)