* * Example 3.4.2 from pp 84-91 * cal(q) 1975 open data table3_3.xls data(format=xls,org=columns) 1975:1 1985:2 y f * spgraph(vfields=2,footer="Figure 3.3 Company sales and total market series") graph(header="Market") # f graph(header="Sales") # y spgraph(done) * * Do figure 3.4, which includes a regression line through the origin. The lines * on a scatter plot are done with the LINE option, which (for a single line) will * take the form LINE=||intercept,slope|| for a y=intercept+slope x representation * of the line. To get 0,0 in the lower left, use vmin=0.0 and hmin=0.0. * linreg(noprint) y # f scatter(footer="Figure 3.4 Company sales versus total market sales",$ vlabel="Sales",hlabel="Market",line=||0.0,%beta(1)||,vmin=0.0,hmin=0.0) # f y * * Analysis with a .6 discount factor * dlm(y=y,c=f,a=1.0,vhat=vhat,dfhist=dfhist,sighist=sighist,$ sv=1.0,var=chisquared,pdf=1.0,pscale=1.0,$ discount=0.6,sx0=.0025*0.6,x0=.45) / xs vs set error = vhat(t)(1) set xx = xs(t)(1) set vx = sqrt(vs(t)(1,1)*sighist) set xlower = xx-%invttest(.10,dfhist)*vx set xupper = xx+%invttest(.10,dfhist)*vx set xx06 = xx * graph(footer="Figure 3.5 One-step ahead forecast errors with delta=.6") # error graph(footer="Figure 3.6 On-line estimated trajectory of coefficient with delta=.6") 3 # xx # xlower # xupper * * Repeated with a 1.0 discount factor. * dlm(y=y,c=f,a=1.0,vhat=vhat,dfhist=dfhist,sighist=sighist,$ sv=1.0,var=chisquared,pdf=1.0,pscale=1.0,$ discount=1.0,sx0=.0025,x0=.45) / xs vs set error = vhat(t)(1) set xx = xs(t)(1) set vx = sqrt(vs(t)(1,1)*sighist) set xlower = xx-%invttest(.10,dfhist)*vx set xupper = xx+%invttest(.10,dfhist)*vx set xx10 = xx * graph(footer="Figure 3.7 One-step ahead forecast errors with delta=1.0") # error graph(footer="Figure 3.6 On-line estimated trajectory of coefficient with delta=1.0") 3 # xx # xlower # xupper * set y_f = y/f graph(footer="Figure 3.9 Y/F ratio with on-line estimates",overlay=dots,ovsame) 3 # xx10 # xx06 # y_f