* * Martin, Hurn, Harris, "Econometric Modelling with Time Series" * Example 15.11, from pp 564-565 * A FVAR model of the Term Structure * open data "daily_finance.xls" data(format=xls,nolabels,org=columns,left=2,top=2) 1 4142 year month day sveny01 sveny02 \$ sveny03 sveny04 sveny05 sveny06 sveny07 sveny08 sveny09 sveny10 sveny11 sveny12 sveny13 sveny14 sveny15 \$ sveny16 sveny17 sveny18 sveny19 sveny20 sveny21 sveny22 sveny23 sveny24 sveny25 sveny26 sveny27 sveny28 \$ sveny29 sveny30 svenf01 svenf02 svenf03 svenf04 svenf05 svenf06 svenf07 svenf08 svenf09 svenf10 svenf11 \$ svenf12 svenf13 svenf14 svenf15 svenf16 svenf17 svenf18 svenf19 svenf20 svenf21 svenf22 svenf23 svenf24 \$ svenf25 svenf26 svenf27 svenf28 svenf29 svenf30 * * Number of factors * compute nf=3 * * Number of variables * compute n=30 * dec vect[series] y(n) compute i=1 dofor r = sveny01 to sveny30 diff(standardize) r / y(i) compute i=i+1 end dofor r * dec vect[series] s(nf) * dec vect[vect] lambda(n) ewise lambda(i)=%zeros(nf,1) * do iters=1,500 @princomp(ncomps=nf) / s # y * compute lambdacheck=0.0 do i=1,n linreg(noprint) y(i) # s y(i){1} * * This maintains the pre-sample values as otherwise we would lose * an extra data point with each iteration. * set y(i) = %if(t>=%regstart(),y(i)-%beta(%nreg)*y(i){1},y(i)) * * Pull out the factor loadings * compute lambda0=lambda(i) compute lambda(i)=%xsubvec(%beta,1,nf) compute lambdacheck=%max(lambdacheck,%testdiff(lambda0,lambda(i))) end do i if lambdacheck<.00001 { disp "Iterations Taken" iters break } end do iters * system(model=factorvar) variables s lags 1 end(system) * estimate * set lambda1 1 30 = lambda(t)(1) set lambda2 1 30 = lambda(t)(2) set lambda3 1 30 = lambda(t)(3) * * The signs of the factors aren't identified so while these have the * correct shape, it's appears that all have the opposite sign. * graph(nodates,footer="Figure 15.3 Stock-Watson factor loading estimates") 3 # lambda1 1 30 # lambda2 1 30 # lambda3 1 30