This is just the initial variables setup
# Define independent variables
independent_vars <- c("Suboan02", "Disent02", "opport", "FDI.flows.Inward",
"Voice..Accountability", "CPI.score",
"Dealing.with.construction.permits..DB16.20.methodology....Score",
"Getting.credit..DB15.20.methodology....Score",
"Paying.taxes..DB17.20.methodology....Score",
"Protecting.minority.investors..DB15.20.methodology....Score",
"Starting.a.business....Score")
# Define dependent variable groups'
# (
# DV1 = c("TEA02opp"),
# DV2 = c("Babybu02", "Anybus02"),
# DV3 = c("Estbbu02", "BO_02exa"),
# DV4 = c("TEA02ido", "TEAjobex"),
# DV5 = c("Tea02s3p"),
# DV6 = c("Tea02s4p", "TEA02nec")
# )
DVs <- c(
"TEA_Opp",
"Babybu",
"Anybus",
"Estbbu",
"BO_Exa",
"TEA_Ido",
"TEA_Job_Ex",
"Tea_s3p",
"Tea_s4p",
"TEA_Nec"
)
Filtering to exclude countries with missing data - Here we choose the final dataset
# List of countries to drop - Countries missing FDI Inflow and Voice and Accountability
countries_to_drop <- c("Hong Kong", "Puerto Rico", "India") # Replace with your list of countries
# Filter the data to exclude rows where 'Country' is in the list
filtered_data <- subset(data, !Country %in% countries_to_drop)
At this point we have several NA values, but I am using all the Independent Variables
pdata <- pdata.frame(data, index = c("Country", "Year"))
# Specify the dynamic panel model
# Dependent variable: TEA02opp
# Independent variables: Suboan02, Disent02, opport, FDI flows Inward, etc.
model <- pgmm(
TEA_Opp ~ lag(TEA_Opp, 1) + Suboan + Disent + Opport +
FDI_Inward + Voice_Account + CPI +
Constr_Score + Credit_Score + Tax_Score +
Invest_Protect_Score + Start_Biz_Score |
lag(TEA_Opp, 2:3), # Instruments for lagged dependent variable
data = pdata,
effect = "individual",
model = "twosteps"
)
# Summarize the results
summary(model)
## Oneway (individual) effect Two-steps model Difference GMM
##
## Call:
## pgmm(formula = TEA_Opp ~ lag(TEA_Opp, 1) + Suboan + Disent +
## Opport + FDI_Inward + Voice_Account + CPI + Constr_Score +
## Credit_Score + Tax_Score + Invest_Protect_Score + Start_Biz_Score |
## lag(TEA_Opp, 2:3), data = pdata, effect = "individual", model = "twosteps")
##
## Balanced Panel: n = 66, T = 5, N = 330
##
## Number of Observations Used: 57
## Residuals:
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -21.0150 0.0000 0.0000 0.7988 0.0000 59.4251
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## lag(TEA_Opp, 1) 1.181404 0.792982 1.4898 0.1363
## Suboan 0.500266 0.408802 1.2237 0.2211
## Disent -0.544335 0.336508 -1.6176 0.1057
## Opport 0.144640 0.108740 1.3301 0.1835
## FDI_Inward 0.431693 0.628573 0.6868 0.4922
## Voice_Account -2.834361 5.581425 -0.5078 0.6116
## CPI 0.753570 0.948706 0.7943 0.4270
## Constr_Score -0.091441 0.201435 -0.4539 0.6499
## Credit_Score -0.224568 0.239565 -0.9374 0.3486
## Tax_Score 0.235082 0.346339 0.6788 0.4973
## Invest_Protect_Score -0.120141 0.409445 -0.2934 0.7692
## Start_Biz_Score 0.426767 0.593238 0.7194 0.4719
##
## Sargan test: chisq(4) = 4.170426 (p-value = 0.38343)
## Autocorrelation test (1): normal = 1.206957 (p-value = 0.22745)
## Autocorrelation test (2): normal = -0.2915864 (p-value = 0.7706)
## Wald test for coefficients: chisq(12) = 67.55347 (p-value = 9.1624e-10)
Same analysis, but considering different Dependent variables.
Everything is in one sigle table, if you want to check R² the code is in the same cell, but I am leaving comment so it not polute the output.
#Create a list to store models
models <- list()
# Loop through the dependent variables (DVs)
for (dv in DVs) {
formula_str <- sprintf(
"%s ~ lag(%s, 1) + Suboan + Disent + Opport + FDI_Inward + Voice_Account + CPI + Constr_Score + Credit_Score + Tax_Score + Invest_Protect_Score + Start_Biz_Score | lag(%s, 2:3)",
dv, dv, dv
)
model <- pgmm(
as.formula(formula_str),
data = pdata,
effect = "individual",
model = "twosteps"
)
models[[dv]] <- model
}
# Use stargazer to create a concise table
stargazer(models, type = "text", title = "PGMM Model Results", align = TRUE)
##
## PGMM Model Results
## ================================================================================================================
## Dependent variable:
## -------------------------------------------------------------------------------------------
## formula_str
## (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
## ----------------------------------------------------------------------------------------------------------------
## lag(TEA_Opp, 1) 1.181
## (0.793)
##
## lag(Babybu, 1) 1.447***
## (0.404)
##
## lag(Anybus, 1) 1.563*
## (0.800)
##
## lag(Estbbu, 1) 1.965**
## (0.783)
##
## lag(BO_Exa, 1) 1.848***
## (0.327)
##
## lag(TEA_Ido, 1) 0.668
## (0.483)
##
## lag(TEA_Job_Ex, 1) 1.642***
## (0.216)
##
## lag(Tea_s3p, 1) 1.709***
## (0.112)
##
## lag(Tea_s4p, 1) 1.678***
## (0.206)
##
## lag(TEA_Nec, 1) 0.532
## (0.428)
##
## Suboan 0.500 0.267 1.165 0.023 0.267 3.768** -0.942 -2.406*** 1.761 -0.293***
## (0.409) (0.290) (0.933) (0.365) (0.359) (1.548) (1.075) (0.808) (1.318) (0.092)
##
## Disent -0.544 0.178 0.406 0.130 0.175 -9.044*** 2.003 2.619** -3.308 0.966***
## (0.337) (0.269) (1.037) (0.157) (0.181) (2.756) (2.395) (1.267) (2.502) (0.286)
##
## Opport 0.145 0.134*** 0.188 0.063 0.167 -1.090*** 0.803*** -0.167 -0.049 0.187***
## (0.109) (0.041) (0.185) (0.142) (0.131) (0.306) (0.227) (0.142) (0.273) (0.039)
##
## FDI_Inward 0.432 0.488 1.682 0.967** 1.485** -2.040 4.360 5.114** -4.057 0.066
## (0.629) (0.452) (1.045) (0.490) (0.607) (1.256) (3.322) (2.154) (2.547) (0.187)
##
## Voice_Account -2.834 -2.506 -4.245 -2.103 -6.542* 24.781 22.026 -24.273 16.295 -2.245
## (5.581) (2.332) (6.257) (2.733) (3.676) (30.728) (29.968) (16.663) (30.590) (3.224)
##
## CPI 0.754 0.058 0.330 0.194 0.811 0.522 1.018 -0.009 0.175 -0.449
## (0.949) (0.476) (1.005) (0.303) (0.553) (1.629) (1.148) (0.946) (1.336) (0.279)
##
## Constr_Score -0.091 -0.127 -0.257 -0.116 -0.155 1.499*** -0.648 0.177 0.668 -0.077
## (0.201) (0.093) (0.164) (0.091) (0.186) (0.477) (0.599) (0.305) (0.560) (0.101)
##
## Credit_Score -0.225 -0.108 -0.299 -0.240** -0.397** 0.729 0.679 -0.164 -0.419 -0.096
## (0.240) (0.116) (0.257) (0.113) (0.178) (0.843) (1.100) (0.426) (0.574) (0.117)
##
## Tax_Score 0.235 -0.187 0.180 0.328*** 0.010 -1.449** -0.016 -0.044 -1.972 0.038
## (0.346) (0.146) (0.282) (0.112) (0.281) (0.637) (0.607) (0.409) (1.257) (0.107)
##
## Invest_Protect_Score -0.120 -0.202 -0.179 0.056 -0.196 3.030*** -2.846*** -0.392 -0.375 -0.583
## (0.409) (0.214) (0.532) (0.184) (0.228) (1.135) (0.780) (0.610) (0.981) (0.382)
##
## Start_Biz_Score 0.427 0.280 0.535 0.238* 0.466 -1.856 2.639** 0.070 0.258 0.196
## (0.593) (0.286) (0.386) (0.144) (0.337) (1.339) (1.256) (0.617) (0.565) (0.272)
##
## ----------------------------------------------------------------------------------------------------------------
## Observations 66 66 66 66 66 66 66 66 66 66
## ================================================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
# # Define labels for each DV
# labels <- c(
# "TEAOpp",
# "Babybu",
# "Anybus",
# "Estbbu",
# "BOExa",
# "TEAIdo",
# "TEAJobEx",
# "Teas3p",
# "Teas4p",
# "TEANec"
# )
#
# for (dv in DVs) {
# model <- pgmm(
# as.formula(paste0(
# dv, " ~ lag(", dv, ", 1) + Suboan + Disent + Opport + ",
# "FDI_Inward + Voice_Account + CPI + Constr_Score + ",
# "Credit_Score + Tax_Score + Invest_Protect_Score + Start_Biz_Score | ",
# "lag(", dv, ", 2:3)"
# )),
# data = pdata,
# effect = "individual",
# model = "twosteps"
# )
#
# # Print the summary of the model
# cat("\nSummary of model for:", dv, "\n")
# print(summary(model))
# print(coeftest(model,vcov=vcovHC, type="HC3"))
#
# }