Load Data

The section download data from the paper.

download.file("https://raw.githubusercontent.com/ubcecon/ECON628_2018/master/paul/assignments/02/qsw-dataPrep.R",destfile="qsw-dataPrep.R")
download.file("https://raw.githubusercontent.com/ubcecon/ECON628_2018/master/paul/assignments/02/qsw-table2.R",destfile="qsw-table2.R")
download.file("https://raw.githubusercontent.com/ubcecon/ECON628_2018/master/paul/assignments/02/rlassoPanel.R",destfile = "rlassoPanel.R")
source("qsw-dataPrep.R")

Problem 1

Part (1)

What is the exogeneity assumption in equation (1) of section IV.B? How does the use of controls affect the plausibility of this assumption? \[\begin{equation} bias_{ijt} = \delta_i + \delta_t + \beta_1 Reform_2003_{jt} + \beta_2 + Reform_2003_{jt} \times Commercial_i + X_{jt}' \gamma + \epsilon+{ijt}.\label{Eq1} \end{equation}\]

To estimate the parameters \(\beta_1\) and \(\beta_2\), we need the exogeneity assumption. \(E[\epsilon_{ijt}|Reform_{jt},Commercial_{i}] = 0\).

Part (2)

## Recreate Table 2 of QSW (2018)
if (!file.exists("qsw2018.Rdata")) {
  source("qsw-dataPrep.R",echo=TRUE)
}
load("qsw2018.Rdata")
library(lfe)
## Loading required package: Matrix
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
source("rlassoPanel.R")
qsw$propre <- interaction(qsw$provincecheck, qsw$prefecturecheck)

col1_raw <- felm(pc1s ~ reform_cg2003 
             | newspaper_id + year | 0
             | propre, data=subset(qsw, !is.na(realfdi) & realfdi>0),
             na.action=na.exclude)

col2_raw <- felm(pc1s ~ reform_cg2003 +  log(gdp) + 
                   log(realfdi) + log(industrialshare) + log(population)
             | newspaper_id + year | 0
             | propre, data=subset(qsw, !is.na(realfdi) & realfdi>0),
             na.action=na.exclude)

col3_raw <- felm(pc1s ~ reform_cg2003  + reform_cg2003:commercial
             | newspaper_id + year | 0
             | propre, data=subset(qsw, !is.na(realfdi) & realfdi>0),
             na.action=na.exclude)

col4_raw <- felm(pc1s ~ reform_cg2003 +  log(gdp) + 
                   log(realfdi) + log(industrialshare) + log(population)
                 + reform_cg2003:commercial | newspaper_id + year | 0
             | propre, data=subset(qsw, !is.na(realfdi) & realfdi>0),
             na.action=na.exclude)


qsw$outside <- qsw$tier >  2

col5_raw <- felm(pc1s ~ reform_cg2003 + reform_cg2003:commercial 
                         + reform_cg2003:outside + commercial:outside:reform_cg2003
             | newspaper_id + year | 0
             | propre, data=subset(qsw, !is.na(realfdi) & realfdi>0),
             na.action=na.exclude)

col6_raw <- felm(pc1s ~ reform_cg2003 + reform_cg2003:commercial 
                         + reform_cg2003:outside + commercial:outside:reform_cg2003 +  log(gdp) + 
                   log(realfdi) + log(industrialshare) + log(population)
             | newspaper_id + year | 0
             | propre, data=subset(qsw, !is.na(realfdi) & realfdi>0),
             na.action=na.exclude)
stargazer(col1_raw,col2_raw,col3_raw,col4_raw,type = "text" )
## 
## ============================================================================================
##                                                  Dependent variable:                        
##                          -------------------------------------------------------------------
##                                                         pc1s                                
##                                (1)              (2)              (3)              (4)       
## --------------------------------------------------------------------------------------------
## reform_cg2003                 -0.002           -0.001          0.018**          0.019**     
##                              (0.003)          (0.003)          (0.007)          (0.007)     
##                                                                                             
## log(gdp)                                       0.015                             0.021      
##                                               (0.032)                           (0.032)     
##                                                                                             
## log(realfdi)                                   0.007                             0.007      
##                                               (0.010)                           (0.009)     
##                                                                                             
## log(industrialshare)                           -0.012                            -0.014     
##                                               (0.039)                           (0.039)     
##                                                                                             
## log(population)                                0.020                             0.022      
##                                               (0.040)                           (0.043)     
##                                                                                             
## reform_cg2003:commercial                                      -0.024***        -0.024***    
##                                                                (0.006)          (0.007)     
##                                                                                             
## --------------------------------------------------------------------------------------------
## Observations                   872              872              872              872       
## R2                            0.832            0.833            0.841            0.842      
## Adjusted R2                   0.803            0.803            0.813            0.813      
## Residual Std. Error      0.051 (df = 743) 0.051 (df = 739) 0.050 (df = 742) 0.050 (df = 738)
## ============================================================================================
## Note:                                                            *p<0.1; **p<0.05; ***p<0.01
stargazer(col5_raw,col6_raw,type="text")
## 
## ======================================================================
##                                             Dependent variable:       
##                                      ---------------------------------
##                                                    pc1s               
##                                            (1)              (2)       
## ----------------------------------------------------------------------
## reform_cg2003                            0.034***         0.036***    
##                                          (0.009)          (0.009)     
##                                                                       
## log(gdp)                                                   0.012      
##                                                           (0.035)     
##                                                                       
## log(realfdi)                                               0.009      
##                                                           (0.010)     
##                                                                       
## log(industrialshare)                                       -0.027     
##                                                           (0.040)     
##                                                                       
## log(population)                                            0.016      
##                                                           (0.048)     
##                                                                       
## reform_cg2003:commercial                -0.039***        -0.040***    
##                                          (0.008)          (0.008)     
##                                                                       
## reform_cg2003:outside                    -0.020**         -0.021**    
##                                          (0.010)          (0.011)     
##                                                                       
## reform_cg2003:commercialTRUE:outside     0.019**          0.021**     
##                                          (0.009)          (0.010)     
##                                                                       
## ----------------------------------------------------------------------
## Observations                               872              872       
## R2                                        0.842            0.844      
## Adjusted R2                               0.815            0.815      
## Residual Std. Error                  0.050 (df = 740) 0.050 (df = 736)
## ======================================================================
## Note:                                      *p<0.1; **p<0.05; ***p<0.01

Part(4)

## try a lasso specification
# construct x matrix
m <- felm(pc1s ~ reform_cg2003 + reform_cg2003:commercial +
            poly(log(gdp), log(industrialshare), log(population),
                 log(realfdi), degree=5) +
            year:(log(gdp) + log(industrialshare) + log(population) +
                  log(realfdi)) +
            as.factor(year)
          | newspaper_id | 0 | propre,
          data=subset(qsw,realfdi>0), keepX=TRUE)
## Warning in chol.default(mat, pivot = TRUE, tol = tol): the matrix is either
## rank-deficient or indefinite
d <- m$X[,grep("reform_",colnames(m$X))]
x <- m$X[,!grepl("reform_",colnames(m$X))]
y <- subset(qsw,realfdi>0 & !is.na(pc1s))$pc1s
id <- as.factor(subset(qsw,realfdi>0 & !is.na(pc1s))$newspaper_id)


# partial out x using lasso
eyx <- rlassoPanel(x, y=y, f=id)
ed1x <- rlassoPanel(x,y=d[,1],f=id)
ed2x <- rlassoPanel(x,y=d[,2],f=id)

# regress residuals of dependent variable on residuals of covariate(s)
# of interest
tmp <- data.frame(y=eyx$residuals, reform=ed1x$residuals,
                  reformC=ed2x$residuals, id=id)
col3 <- summary(felm(y ~ reform + reformC | id | 0 | id, data=tmp))