14 Advanced Panel Data Methods
Also covered using Python and Stata
14.1 Example 14.1. Effect of Job Training on Firm Scrap Rates
## fcode year
## 1 410032 1987
## 2 410032 1988
## 3 410032 1989
## 4 410440 1987
## 5 410440 1988
## 6 410440 1989
jtrainP_fe1 <- plm(lscrap ~ d88 + d89 + grant + grant_1, data = jtrainP, model = "within")
stargazer(jtrainP_fe1, no.space=TRUE, type="text")
##
## ========================================
## Dependent variable:
## ---------------------------
## lscrap
## ----------------------------------------
## d88 -0.080
## (0.109)
## d89 -0.247*
## (0.133)
## grant -0.252*
## (0.151)
## grant_1 -0.422**
## (0.210)
## ----------------------------------------
## Observations 162
## R2 0.201
## Adjusted R2 -0.237
## F Statistic 6.543*** (df = 4; 104)
## ========================================
## Note: *p<0.1; **p<0.05; ***p<0.01
## grant_1
## -0.3439967
jtrainP_fe2 <- plm(lscrap ~ d88 + d89 + grant, data = jtrainP, model = "within")
stargazer(jtrainP_fe2, no.space=TRUE, type="text")
##
## ========================================
## Dependent variable:
## ---------------------------
## lscrap
## ----------------------------------------
## d88 -0.140
## (0.107)
## d89 -0.427***
## (0.100)
## grant -0.082
## (0.126)
## ----------------------------------------
## Observations 162
## R2 0.170
## Adjusted R2 -0.272
## F Statistic 7.176*** (df = 3; 105)
## ========================================
## Note: *p<0.1; **p<0.05; ***p<0.01
14.2 Example 14.2.Has the Return to Education Changed over Time?
wagepanP <- pdata.frame(wagepan, index = c("nr", "year"))
wagepanP_fe1 <- plm(lwage ~ educ*year + union + married, data=wagepanP, model = "within")
stargazer(wagepanP_fe1, single.row = TRUE, no.space=TRUE, type="text")
##
## =========================================
## Dependent variable:
## ---------------------------
## lwage
## -----------------------------------------
## year1981 -0.022 (0.146)
## year1982 -0.006 (0.146)
## year1983 0.010 (0.146)
## year1984 0.084 (0.146)
## year1985 0.050 (0.146)
## year1986 0.066 (0.146)
## year1987 0.090 (0.146)
## union 0.083*** (0.019)
## married 0.055*** (0.018)
## educ:year1981 0.012 (0.012)
## educ:year1982 0.015 (0.012)
## educ:year1983 0.017 (0.012)
## educ:year1984 0.017 (0.012)
## educ:year1985 0.024* (0.012)
## educ:year1986 0.027** (0.012)
## educ:year1987 0.030** (0.012)
## -----------------------------------------
## Observations 4,360
## R2 0.171
## Adjusted R2 0.049
## F Statistic 48.907*** (df = 16; 3799)
## =========================================
## Note: *p<0.1; **p<0.05; ***p<0.01
14.3 Example 14.3.Effect of Job Training on Firm Scrap Rates
jtrainP <- pdata.frame(jtrain, index = c("fcode", "year"))
jtrainP_fe3 <- plm(lscrap ~ d88 + d89 + grant + grant_1 + lsales + lemploy, data = jtrainP, model = "within")
summary(jtrainP_fe3)
## Oneway (individual) effect Within Model
##
## Call:
## plm(formula = lscrap ~ d88 + d89 + grant + grant_1 + lsales +
## lemploy, data = jtrainP, model = "within")
##
## Unbalanced Panel: n = 51, T = 1-3, N = 148
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -1.858663 -0.133752 -0.021483 0.148632 1.580473
##
## Coefficients:
## Estimate Std. Error t-value Pr(>|t|)
## d88 -0.0039609 0.1195487 -0.0331 0.97364
## d89 -0.1321930 0.1536863 -0.8601 0.39197
## grant -0.2967542 0.1570861 -1.8891 0.06206 .
## grant_1 -0.5355783 0.2242060 -2.3888 0.01897 *
## lsales -0.0868577 0.2596985 -0.3345 0.73881
## lemploy -0.0763679 0.3502902 -0.2180 0.82791
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 27.934
## Residual Sum of Squares: 21.982
## R-Squared: 0.21306
## Adj. R-Squared: -0.27121
## F-statistic: 4.10625 on 6 and 91 DF, p-value: 0.0010818
14.4 Example 14.4. A Wage Equation Using Panel Data
wagepanP <- pdata.frame(wagepan, index = c("nr", "year"))
POLS <- lm(lwage ~ educ + black + hisp + exper + expersq + married + union + factor(year), data=wagepanP)
RE <- plm(lwage ~ educ + black + hisp + exper + expersq + married + union + factor(year), data=wagepanP, model = "random")
FE <- plm(lwage ~ educ + black + hisp + exper + expersq + married + union + factor(year), data=wagepanP, model = "within")
stargazer(POLS, RE, FE, keep.stat=c("n","rsq", "adj.rsq"), no.space=TRUE, type="text")
##
## ==============================================
## Dependent variable:
## -----------------------------
## lwage
## OLS panel
## linear
## (1) (2) (3)
## ----------------------------------------------
## educ 0.091*** 0.092***
## (0.005) (0.011)
## black -0.139*** -0.139***
## (0.024) (0.048)
## hisp 0.016 0.022
## (0.021) (0.043)
## exper 0.067*** 0.106*** 0.132***
## (0.014) (0.015) (0.010)
## expersq -0.002*** -0.005*** -0.005***
## (0.001) (0.001) (0.001)
## married 0.108*** 0.064*** 0.047**
## (0.016) (0.017) (0.018)
## union 0.182*** 0.106*** 0.080***
## (0.017) (0.018) (0.019)
## factor(year)1981 0.058* 0.040 0.019
## (0.030) (0.025) (0.020)
## factor(year)1982 0.063* 0.031 -0.011
## (0.033) (0.032) (0.020)
## factor(year)1983 0.062* 0.020 -0.042**
## (0.037) (0.042) (0.020)
## factor(year)1984 0.090** 0.043 -0.038*
## (0.040) (0.051) (0.020)
## factor(year)1985 0.109** 0.058 -0.043**
## (0.043) (0.061) (0.020)
## factor(year)1986 0.142*** 0.092 -0.027
## (0.046) (0.071) (0.020)
## factor(year)1987 0.174*** 0.135*
## (0.049) (0.081)
## Constant 0.092 0.024
## (0.078) (0.151)
## ----------------------------------------------
## Observations 4,360 4,360 4,360
## R2 0.189 0.181 0.181
## Adjusted R2 0.187 0.178 0.061
## ==============================================
## Note: *p<0.1; **p<0.05; ***p<0.01