Dear,
I wrote a code to perform the panel Granger test. The test is adopted by Dumitrescu-Hurlin (2012): "This test is calculated by simply running standard Granger Causality regressions for each cross-section individually. The nest step is to take the average of the test statistics, which are termed the Wbar statistic. They show that the standardized version of this statistic, appropriately weighted in unbalanced panels, follows a standard normal distribution. This is termed the Zbar statistic."
Please give comment on the following code:
Any comment is appreciated.
I wrote a code to perform the panel Granger test. The test is adopted by Dumitrescu-Hurlin (2012): "This test is calculated by simply running standard Granger Causality regressions for each cross-section individually. The nest step is to take the average of the test statistics, which are termed the Wbar statistic. They show that the standardized version of this statistic, appropriately weighted in unbalanced panels, follows a standard normal distribution. This is termed the Zbar statistic."
Please give comment on the following code:
use asean5, clear
. version 13
. xtset id t
panel variable: id (strongly balanced)
time variable: t, 1960 to 2015
delta: 1 unit
. xtbalance, range(2001 2014)
(210 observations deleted due to out of range)
.
. global varlist lnrgdp lnpcap lnpcr lnbcr lnbmn lngfk inf
.
. local lower = 1
. local upper = _N - (2*`lower') - 1
.
. matrix W = J(4,1,0)
. local ID 122 153 186 224
.
. forvalues i=1/4 {
2. local idc: word `i' of `ID'
3. preserve
4.
. qui keep if id==`idc'
5. qui tsset t
6. qui gcause lnpcr lnrgdp , lag(`lower')
7. matrix W[`i',1]=r(F)
8.
. restore
9. }
. mata
------------------------------------------------- mata (type end to exit) -----------------------------------------------------------------------------
:
: w = st_matrix("W")
: wbar = mean(w)
: st_numscalar("r(w)", wbar)
: end
-------------------------------------------------------------------------------------------------------------------------------------------------------
.
. scalar prob = fprob(`lower',`upper',`r(w)')
.
. display "H0: lnrgdp does not Granger-cause lnpcr"
H0: lnrgdp does not Granger-cause lnpcr
. display "F = " r(w) " Prob > F = " prob
F = 13.154937 Prob > F = .00055444
. version 13
. xtset id t
panel variable: id (strongly balanced)
time variable: t, 1960 to 2015
delta: 1 unit
. xtbalance, range(2001 2014)
(210 observations deleted due to out of range)
.
. global varlist lnrgdp lnpcap lnpcr lnbcr lnbmn lngfk inf
.
. local lower = 1
. local upper = _N - (2*`lower') - 1
.
. matrix W = J(4,1,0)
. local ID 122 153 186 224
.
. forvalues i=1/4 {
2. local idc: word `i' of `ID'
3. preserve
4.
. qui keep if id==`idc'
5. qui tsset t
6. qui gcause lnpcr lnrgdp , lag(`lower')
7. matrix W[`i',1]=r(F)
8.
. restore
9. }
. mata
------------------------------------------------- mata (type end to exit) -----------------------------------------------------------------------------
:
: w = st_matrix("W")
: wbar = mean(w)
: st_numscalar("r(w)", wbar)
: end
-------------------------------------------------------------------------------------------------------------------------------------------------------
.
. scalar prob = fprob(`lower',`upper',`r(w)')
.
. display "H0: lnrgdp does not Granger-cause lnpcr"
H0: lnrgdp does not Granger-cause lnpcr
. display "F = " r(w) " Prob > F = " prob
F = 13.154937 Prob > F = .00055444
Any comment is appreciated.
Comment