I study business cycle synchornization between countries. I simply modify the code of Stock and Watson(1991), "A Probability Model of the Coincident Economic Indicators," for two countries.
I get gamma(1)=2.5>1, is it right? I exchange the order of tow series, gamma(1) is still more than 2.
first : i_cn i_xj
Code: Select all
open data gdp_cn_xj.txt
calendar(q) 1997
data(format=free,org=columns) 1997:1 2012:4 gdp_cn gdp_xj
*
set i_cn = 100.0*log(gdp_cn/gdp_cn{1})
set i_xj = 100.0*log(gdp_xj/gdp_xj{1})
*
* Parameters for index
*
dec vect phi(2)
compute phi=%zeros(2,1)
dec real sigmac
compute sigmac=1.0
*
* Parameters for the series. sigma is initialized based upon the sample
* means.
*
dec vect beta(2) gamma(2)
dec vect sigma(2)
dec vect[vect] d(2)
ewise d(i)=%zeros(2,1)
*
compute gamma=%const(1.0)
stats(noprint) i_cn
compute beta(1)=%mean,sigma(1)=%variance*.5
stats(noprint) i_xj
compute beta(2)=%mean,sigma(2)=%variance*.5
*
* Construct fixed parts of the A matrix
*
dec rect a(6,6)
compute ar2=||0.0,0.0|1.0,0.0||
compute a=ar2~\ar2~\ar2
*
* Construct the F matrix (always fixed)
*
dec rect f(6,3)
compute f2=||1.0|0.0||
compute f=f2~\f2~\f2
*
* Construct the fixed parts of the C matrix
*
dec rect c(6,2)
compute c=%zeros(2,2)~~(f2~\f2)
*
dec symm sw(3,3)
*
function %%DLMSetup
compute %psubmat(a,1,1,tr(phi))
do i=1,2
compute %psubmat(a,2*i+1,2*i+1,tr(d(i)))
end do i
compute %psubmat(c,1,1,tr(gamma))
compute sw=%diag(sigmac~~sigma)
end %%DLMSetup
*
*
dec frml[vect] yf
frml yf = ||i_cn-beta(1),i_xj-beta(2) ||
*
* Estimate the parameters by maximum likelihood.
*
nonlin gamma d sigma phi
*
dlm(start=%%DLMSetup(),y=yf,sw=sw,c=c,a=a,f=f,$
presample=ergodic,type=filter,$
pmeth=simplex,piters=200,method=bfgs) 1997:2 * xstates
*
* As this is constructed, it somewhat arbitrarily fixes the pre-sample
* value of the indicator at zero.
*
set indicator_f 1997:2 * = xstates(t)(1)
acc indicator_f
graph(footer="Coincident Indicator, Filtered Version")
# indicator_f
*
dlm(start=%%DLMSetup(),y=yf,sw=sw,c=c,a=a,f=f,presample=ergodic,$
type=smooth,print,title="smooth") 1997:2 * xstates
set indicator_m 1997:2 * = xstates(t)(1)
acc indicator_m
graph(footer="Coincident Indicator, Smoothed Version")
# indicator_m
second : i_xj i_cn
Code: Select all
open data gdp_cn_xj.txt
calendar(q) 1997
data(format=free,org=columns) 1997:1 2012:4 gdp_cn gdp_xj
*
set i_cn = 100.0*log(gdp_cn/gdp_cn{1})
set i_xj = 100.0*log(gdp_xj/gdp_xj{1})
*
* Parameters for index
*
dec vect phi(2)
compute phi=%zeros(2,1)
dec real sigmac
compute sigmac=1.0
*
* Parameters for the series. sigma is initialized based upon the sample
* means.
*
dec vect beta(2) gamma(2)
dec vect sigma(2)
dec vect[vect] d(2)
ewise d(i)=%zeros(2,1)
*
compute gamma=%const(1.0)
stats(noprint) i_cn
compute beta(2)=%mean,sigma(2)=%variance*.5
stats(noprint) i_xj
compute beta(1)=%mean,sigma(1)=%variance*.5
*
* Construct fixed parts of the A matrix
*
dec rect a(6,6)
compute ar2=||0.0,0.0|1.0,0.0||
compute a=ar2~\ar2~\ar2
*
* Construct the F matrix (always fixed)
*
dec rect f(6,3)
compute f2=||1.0|0.0||
compute f=f2~\f2~\f2
*
* Construct the fixed parts of the C matrix
*
dec rect c(6,2)
compute c=%zeros(2,2)~~(f2~\f2)
*
dec symm sw(3,3)
*
function %%DLMSetup
compute %psubmat(a,1,1,tr(phi))
do i=1,2
compute %psubmat(a,2*i+1,2*i+1,tr(d(i)))
end do i
compute %psubmat(c,1,1,tr(gamma))
compute sw=%diag(sigmac~~sigma)
end %%DLMSetup
*
*
dec frml[vect] yf
frml yf = ||i_xj-beta(1),i_cn-beta(2) ||
*
* Estimate the parameters by maximum likelihood.
*
nonlin gamma d sigma phi
*
dlm(start=%%DLMSetup(),y=yf,sw=sw,c=c,a=a,f=f,$
presample=ergodic,type=filter,$
pmeth=simplex,piters=10,method=bfgs) 1997:2 * xstates
*
*
*
set indicator_f 1997:2 * = xstates(t)(1)
acc indicator_f
graph(footer="Coincident Indicator, Filtered Version")
# indicator_f
*
dlm(start=%%DLMSetup(),y=yf,sw=sw,c=c,a=a,f=f,presample=ergodic,$
type=smooth) 1997:2 * xstates
set indicator_m 1997:2 * = xstates(t)(1)
acc indicator_m
graph(footer="Coincident Indicator, Smoothed Version")
# indicator_m