2
$\begingroup$

I saw this previous post from 2017 that talks about the same table but only focuses on OLS. I'm also working on replicating Table 8.1 in Baltagi's Economic Analysis of Panel data book. I can replicate the table in Stata and I can replicate most of the table using the plm package in R. Unfortunately, I cannot replicate the Arellano-Bond Twostep GMM values. I can confirm that I can get the same results as the Table using Stata but do not get the same results as those in the table using plm. I am confused what option or technique is causing the issue.

I've included the R code here for both the one-step and two-step GMM estimates. As shown, when estimating the one-step, the results match while when estimating the two-step they do not. I'm also including Table 8.1 at the bottom to show the results presented in the book.

library(plm)
#Loading the Baltagi dataset provided as part of the plm package
data(Cigar)

#transforming to real variables as required
Cigar$real_c <- with(Cigar, (sales*pop)/pop16)
Cigar$real_p <- with(Cigar, (price/cpi)*100)
Cigar$real_pimin <- with(Cigar, (pimin/cpi)*100)
Cigar$real_ndi <- with(Cigar, (ndi/cpi))



gmm_onestep <- pgmm(log(real_c) ~ lag(log(real_c), 1) + log(real_p) + log(real_pimin) + log(real_ndi) | 
                      lag(log(real_c), 2:99), data = Cigar, effect = "twoways", model = "onestep")

#match w/ Table 8.1: 0.84, -0.377, -0.016, 0.14
round(summary(gmm_onestep)$coef, 3)

#Two step does not match Table 8.1: 0.80, -0.379; -0.020, 0.24
gmm_twostep <- pgmm(log(real_c) ~ lag(log(real_c), 1) + log(real_p) + log(real_pimin) + log(real_ndi)  | 
                      lag(log(real_c), 2:99), data = Cigar, effect = "twoways", model = "twostep")

#pgmm reports 0.632, -0.358, -0.002, 0.386
round(summary(gmm_twostep)$coef, 3)

Any help would be greatly appreciated!

Baltagi_Table8.1

$\endgroup$
4
  • 1
    $\begingroup$ Thanks for showing the command in Stata that will replicate the results--perhaps I should have done that in the orignal post, but didn't want to confuse anyone of the issue. It's the fact that it will not replicate in R which is the concern. $\endgroup$
    – Tony
    Aug 9 '21 at 15:45
  • 1
    $\begingroup$ Interesting note: Baltagi (2005, 3rd), table 8.1 [what you are showing] has different values compared to Baltagi (2013/2021, 5th/6th) for the two-step GMM case where the difference stems from using xtabond2 and collapsed instruments in the newer editions (as opposed to xtabond and not mentioning of collapsed instruments in older edition). $\endgroup$
    – Helix123
    Aug 11 '21 at 23:28
  • $\begingroup$ @Helix123, I could get the same result in stata only with the following command: xtabond lnc lnrp lnrpn lnrdi year_65-year_92, lag(1) twostep noconstant $\endgroup$
    – garej
    Nov 19 '21 at 14:15
  • $\begingroup$ For clarfication, reference: what you show with xtabond as in the 2005 edition of Baltagi (xtabond lnc lnrp lnrpn lnrdi dum3-dum29, lag(1) twostep). The newer editions use xtabond2 with xtabond2 lnc L.(lnc) lnrp lnrpn lnrdi dum3 dum8 dum10-dum29, gmm(L.(lnc), collapse) iv(lnrp lnrpn lndrdi dum3 dum8 dum10-29) noleveleq robust nomata twostep. Note how the set of time dummies is different (dum8). $\endgroup$
    – Helix123
    Nov 21 '21 at 10:22
1
$\begingroup$

The key to obtain similar results is to notice this part in stata code dum3-dum29 in command:

# stata
xtset state year
xtabond lnc lnrp lnrpn lnrdi dum3-dum29, lag(1) twostep 

Hence, we have to model time dummies manually (i.e. use the packege fastDummies).

Baltagi in Stata drops not only two first periods of time dummies, but also the last one (I've commented out them in the code below). You may uncomment two lines to get you initial results with automatic twoways effects. As far as we model time manually, I've changed effect option to individual.

library(fastDummies)
Cigar <- dummy_cols(.data = Cigar, select_columns = "year")

gmm_tmp <- pgmm(log(real_c) ~ lag(log(real_c), 1) + log(real_p) + log(real_pimin) + log(real_ndi) 
                # + year_63 + year_64 
                + year_65 + year_66 + year_67 + year_68 + year_69 + year_70 + year_71 + year_72 +
                  year_73 + year_74 + year_75 + year_76 + year_77 + year_78 + year_79 +
                  year_80 + year_81 + year_82 + year_83 + year_84 + year_85 + year_86 +
                  year_87 + year_88 + year_89 + year_90 + year_91 
                # + year_92
                | lag(log(real_c), 2:99)
                , data = Cigar, effect = "individual", model = "twosteps", transformation = "d"
                )

round(coefficients(gmm_tmp)$coef[1:4], 2)
# 0.80               -0.37               -0.08                0.18

Below is a part of summary output to see that only first two coefficient are significant, indeed (so the difference of two last may stem from numeric differences in matrix procedures).

# Coefficients:
#                          Estimate Std.Error z-value Pr(>|z|)    
#   lag(log(C_real), 1)  0.7991766  0.1962817  4.0716 4.670e-05 ***
#   log(P_real)         -0.3696419  0.0921545 -4.0111 6.043e-05 ***
#   log(Pn_real)        -0.0782846  0.1524425 -0.5135  0.607577    
#   log(Y_real)          0.1846966  0.1215665  1.5193  0.128686  

Notice also that transformation = "d" corresponds to xtabond in Stata, while xtabond2 counterpart seems to be transformation = "ld" in R.

Hope that helps.

$\endgroup$
2
  • 1
    $\begingroup$ I think the differences are too large, esp. for the non-sign. coefficients to be explained by merely numerical precision. $\endgroup$
    – Helix123
    Nov 21 '21 at 10:25
  • 1
    $\begingroup$ See my answer for a(n) (inital) take von replication for two-step GMM values as in Baltagi (2013, 2021), based on your answer with the dummy hints! $\endgroup$
    – Helix123
    Nov 21 '21 at 11:25
1
$\begingroup$

Here is a narrow replication of Table 8.1, 8.2 as in Baltagi (2021) (see printed coefs below in comments, generated with xtabond2 lnc L.(lnc) lnrp lnrpn lnrdi dum3 dum8 dum10-dum29, gmm(L.(lnc), collapse) iv(lnrp lnrpn lndrdi dum3 dum8 dum10-29) noleveleq robust nomata twostep with pgmm from R package plm.

Code below does not incorporate the IV instruments, so I think that is where the difference comes from.

library(plm)
data("Cigar", package = "plm")
Cigar$real_c     <- Cigar$sales * Cigar$pop/Cigar$pop16
Cigar$real_p     <- Cigar$price/Cigar$cpi * 100
Cigar$real_pimin <- Cigar$pimin/Cigar$cpi * 100
Cigar$real_ndi   <- Cigar$ndi/Cigar$cpi

# Table 8.1, 8.2 in Baltagi (2021):
# Coefs (z-stat) 0.70 (10.2) −0.396 (6.0) −0.105 (1.3) 0.13 (3.5) 
 
# Stata xtabond2 lnc L.(lnc) lnrp lnrpn lnrdi dum3 dum8 dum10-dum29, gmm(L.(lnc), collapse)
# iv(lnrp lnrpn lndrdi dum3 dum8 dum10-29) noleveleq robust nomata twostep
# No of obs 1288, no of groups = 48, balanced, no of instruments = 53

year.d <- contr.treatment(levels(factor(Cigar$year)))
year.d <- cbind("63" = c(1, rep(0, nrow(year.d)-1)), year.d)
colnames(year.d) <- paste0("year_", colnames(year.d))
year.d <- cbind("year" = rownames(year.d), as.data.frame(year.d))

Cigar <- merge(Cigar, year.d)
pCigar <- pdata.frame(Cigar, index = c("state", "year"))

gmm_twostep <- pgmm(log(real_c) ~ lag(log(real_c)) + log(real_p) + log(real_pimin) + log(real_ndi) 
                # + year_63 + year_64 
                + year_65 + 
                # year_66 + year_67 + year_68 + year_69 + 
                  year_70 + 
                # year_71 + 
                year_72 + year_73 + year_74 + year_75 + year_76 + year_77 + 
                year_78 + year_79 + year_80 + year_81 + year_82 + year_83 + 
                year_84 + year_85 + year_86 + year_87 + year_88 + year_89 + 
                year_90 + year_91 
                # + year_92
                | lag(log(real_c), 2:99)
                , data = pCigar, effect = "individual", model = "twosteps", transformation = "d", collapse = TRUE)
summary(gmm_twostep)
# Oneway (individual) effect Two-steps model Difference GMM
# [...] 
# Balanced Panel: n = 46, T = 30, N = 1380
# 
# Number of Observations Used: 1288
# Residuals:
#        Min.     1st Qu.      Median        Mean     3rd Qu.        Max. 
# -0.27863516 -0.02217940 -0.00145884 -0.00006592  0.02110833  0.27517456 
# 
# Coefficients:
#                    Estimate Std. Error z-value              Pr(>|z|)    
# lag(log(real_c))  0.7127422  0.0671003 10.6220 < 0.00000000000000022 ***
# log(real_p)      -0.3867883  0.0685552 -5.6420  0.000000016808826119 ***
# log(real_pimin)  -0.1067969  0.0792667 -1.3473             0.1778803    
# log(real_ndi)     0.1392827  0.0372024  3.7439             0.0001812 ***
# [...time dummies suppressed...]
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.