Today

Review: Unobserved Effects Model

Estimators: Pooled OLS

Inference in Pooled OLS

Estimators: First Difference

\[\Delta Y_{i,t}= \Delta X_{i,t}^{\prime}\beta + \Delta u_{i,t}\]

Standard Errors

First Difference Assumptions

Results

Fixed Effects Transform

Assumptions to use OLS

Fixed Effects Assumptions

Estimators: Least Squares Dummy Variable

Incidental Parameters

FE vs. FD. vs LSDV

Example: Union status and wages (Code 1)

#Load Libraries
library(plm)
library(lmtest)
library(stargazer)
#Load Data
library(foreign)
wagepan<-read.dta(
"http://fmwww.bc.edu/ec-p/data/wooldridge/wagepan.dta")
#Turn into panel data set
wagepan.p<-pdata.frame(wagepan, index=c("nr","year"))

Example: Union status and wages (Code 2)

# Run Pooled OLS
olsreg<-(plm(lwage ~ union + I(exper^2)+married +
    educ + black + exper +
    d81+d82+d83+d84+d85+d86+d87,
             data=wagepan.p, model="pooling"))
# Run First Differences
fdreg<-(plm(lwage ~ 0+ union +
    I(exper^2)+ married +
      educ + black +  exper +
      d81+d82+d83+d84+d85+d86+d87,
             data=wagepan.p, model="fd"))

Example: Union status and wages (Code 3)

#Run Fixed Effects
fereg<-plm(lwage ~ union + I(exper^2)+ married +
  d81+d82+d83+d84+d85+d86+d87, data=wagepan.p, 
  model="within",index=c("nr","year"))
#Run Least Squares Dummy Variables
lsdvreg<-plm(lwage ~ union + I(exper^2)+ married +
  d81+d82+d83+d84+d85+d86+d87+factor(nr),
  data=wagepan.p, model="pooling")

Example: Union status and wages

Results (Code 1)

#Get Coefficients and clustered standard errors
olscoef<-coeftest(olsreg,
      vcov=vcovHC(olsreg,cluster = "group"))
fdcoef<-coeftest(fdreg,
      vcov=vcovHC(fdreg,cluster = "group"))
fecoef<-coeftest(fereg,
      vcov=vcovHC(fereg,cluster = "group"))
lsdvcoef<-coeftest(lsdvreg,
    vcov=vcovHC(lsdvreg,cluster = "group"))

Results (Code 2)

#Build Table
stargazer(olscoef,fdcoef,fecoef,lsdvcoef,size="tiny",
    type="text",header=FALSE,no.space=TRUE,
    #title="Panel Data Estimators: Results",
    column.sep.width=c("1pt"),
    omit=c("d81","d82","d83","d84",
    "d85","d86","d87","factor*","Constant"),
    column.labels=c("pOLS","FD","FE","LSDV"),
    #keep=c("union","married","exper^2"),
    omit.table.layout="n#l")

Results of different methods (All SEs clustered)

## 
## =================================================
##                                                  
##             pOLS       FD        FE       LSDV   
## -------------------------------------------------
## union     0.183***   0.041*   0.080***  0.080*** 
##            (0.027)   (0.022)   (0.023)   (0.023) 
## I(exper2) -0.002**  -0.006*** -0.005*** -0.005***
##            (0.001)   (0.001)   (0.001)   (0.001) 
## married   0.108***    0.038    0.047**   0.047** 
##            (0.026)   (0.024)   (0.021)   (0.021) 
## educ      0.091***                               
##            (0.011)                               
## black     -0.142***                              
##            (0.050)                               
## exper     0.067***                               
##            (0.019)                               
## =================================================
## =================================================

Random Effects Model

Random Effects Estimator

\[\lambda=1-(\frac{\sigma_u^2}{\sigma_u^2+T \sigma_a^2})^{1/2}\]

\[Y_{i,t}=X_{i,t}^{\prime}\beta+a_i+u_{i,t}\]

\[Y_{i,t}-\lambda\bar{Y}_i= (X_{i,t}^{\prime}-\lambda\bar{X}_{i}^{\prime})\beta + v_{i,t}-\lambda\bar{v}_{i}\]

Random Effects Estimator

Random Effects Assumptions

Results

Fixed vs Random Effects

Unions and wages: (Code 1)

#Compare RE and FD to FE estimates of unions on wages
#Run Random Effects
rereg<-plm(lwage ~ union + I(exper^2)+ married +
             + educ + black + exper +
  d81+d82+d83+d84+d85+d86+d87, data=wagepan, 
  model="random",index=c("nr","year"))
#Run Pooled OLS
polsreg<-plm(lwage ~ union + I(exper^2)+ married +
               + educ + black + exper +
  d81+d82+d83+d84+d85+d86+d87, data=wagepan, 
  model="pooling",index=c("nr","year"))

Unions and wages: (Code 2)

#Run First Differences
fdreg<-plm(lwage ~0+ union + I(exper^2)+ married +
  d81+d82+d83+d84+d85+d86+d87, data=wagepan, 
  model="fd",index=c("nr","year"))
#Construct Coefficients and Clustered SEs
fecoefClust<-coeftest(fereg,
      vcov=vcovHC(fereg,cluster = "group"))
recoefClust<-coeftest(rereg,
      vcov=vcovHC(rereg,cluster = "group"))
fdcoefClust<-coeftest(fdreg,
      vcov=vcovHC(fdreg,cluster = "group"))
polscoefClust<-coeftest(polsreg,
    vcov=vcovHC(polsreg,cluster = "group"))

Unions and wages: (Code 3)

#Build Table
stargazer(fdcoefClust,fecoefClust,
          recoefClust,polscoefClust,
    type="text",header=FALSE,no.space=TRUE,
    column.sep.width=c("1pt"),
    omit=c("d81","d82","d83","d84",
      "d85","d86","d87","Constant"),
    column.labels=c("FD","FE","RE","pOLS"),
    omit.table.layout="n#l")

Unions and wages: FD, FE, RE, Pooled OLS (Clustered)

## 
## =================================================
##                                                  
##              FD        FE        RE       pOLS   
## -------------------------------------------------
## union      0.041*   0.080***  0.106***  0.183*** 
##            (0.022)   (0.023)   (0.021)   (0.027) 
## I(exper2) -0.006*** -0.005*** -0.005*** -0.002** 
##            (0.001)   (0.001)   (0.001)   (0.001) 
## married     0.038    0.047**  0.064***  0.108*** 
##            (0.024)   (0.021)   (0.019)   (0.026) 
## educ                          0.091***  0.091*** 
##                                (0.011)   (0.011) 
## black                         -0.143*** -0.142***
##                                (0.050)   (0.050) 
## exper                         0.106***  0.067*** 
##                                (0.016)   (0.019) 
## =================================================
## =================================================

Comparisons (Code)

#Run Hausman test to compare Fixed vs Random
phtest(fereg,rereg)

Comparisons

## 
##  Hausman Test
## 
## data:  lwage ~ union + I(exper^2) + married + d81 + d82 + d83 + d84 +  ...
## chisq = 26.644, df = 10, p-value = 0.002964
## alternative hypothesis: one model is inconsistent

Next Time