* * Example 8.7.2 from pp 392-395 * open data sp5may.dat data(format=free,org=columns) 1 7061 future spot time * * Patch series as described * do patch=1,5 ext(noprint) future compute future(%maxent)=.5*(future(%maxent-1)+future(%maxent+1)) compute future(%minent)=.5*(future(%minent-1)+future(%minent+1)) ext(noprint) spot compute spot(%maxent)=.5*(spot(%maxent-1)+spot(%maxent+1)) compute spot(%minent)=.5*(spot(%minent-1)+spot(%minent+1)) end do patch * set z = 100*(future-spot) * set df = future-future{1} set ds = spot-spot{1} * spgraph(vfields=3,footer="Figure 8.16 Time plots of 1-minute log returns of S&P 500 index future and cash prices") graph(header="(a) First differenced log(future)",vticks=5) # df graph(header="(b) First differenced log(price)",vticks=5) # ds graph(header="(c) z(t) series",vticks=5) # z spgraph(done) * compute [vector] g1=%SEQA(-.20,.20/50.0,50) compute [vector] g2=%SEQA(.025,.12/50.0,50) * sweep # df ds # constant df{1 to 8} ds{1 to 8} z{1} compute bestlogl=%logl * infobox(action=define) "Grid Search" dofor [real] g1t = g1 dofor [real] g2t = g2 set group = 1+(z{1}>=g1t)+(z{1}>=g2t) sweep(grouping=group) # df ds # constant df{1 to 8} ds{1 to 8} z{1} if %logl>bestlogl compute bestlogl=%logl,bestg1=g1t,bestg2=g2t infobox(action=modify) %strval(g1t,"*.###")+" "+%strval(g2t,"*.###")+%strval(bestg1,"*.###")+" "+%strval(bestg2,"*.###") end dofor g2t end dofor g1t infobox(action=remove) * set group = 1+(z{1}>=bestg1)+(z{1}>=bestg2) * system(model=twovar) variables df ds lags 1 to 8 det constant z{1} end(system) * * Estimate over the three regimes * do i=1,3 estimate(smpl=group==i) end do i