II Econometric Analysis Using R
solomonegash.com

Also available in Stata and Python versions

Chapter 17. Corner Solution Responses

Example 17.1

Load libraries

library(wooldridge)
library(haven)
library(stargazer)
library(plm)
library(censReg)
library(truncreg)
library(sampleSelection)

Annual Hours Equation for Married Women

sOLS <- lm(hours ~ nwifeinc + educ + exper + expersq + age + kidslt6 + kidsge6, data = mroz) 
sTobit <- censReg(hours ~ nwifeinc + educ + exper + expersq + age + kidslt6 + kidsge6, data = mroz) 
stargazer(sOLS, sTobit, title="Table 17.1 OLS and Tobit Estimation of Annual Hours Worked", no.space=TRUE, type="text")
## 
## Table 17.1 OLS and Tobit Estimation of Annual Hours Worked
## =======================================================
##                             Dependent variable:        
##                     -----------------------------------
##                                    hours               
##                               OLS            censored  
##                                             regression 
##                               (1)               (2)    
## -------------------------------------------------------
## nwifeinc                    -3.447           -8.814**  
##                             (2.544)           (4.459)  
## educ                       28.761**          80.646*** 
##                            (12.955)          (21.583)  
## exper                      65.673***        131.564*** 
##                             (9.963)          (17.279)  
## expersq                    -0.700**          -1.864*** 
##                             (0.325)           (0.538)  
## age                       -30.512***        -54.405*** 
##                             (4.364)           (7.419)  
## kidslt6                   -442.090***       -894.022***
##                            (58.847)          (111.878) 
## kidsge6                     -32.779           -16.218  
##                            (23.176)          (38.641)  
## logSigma                                     7.023***  
##                                               (0.037)  
## Constant                 1,330.482***        965.305** 
##                            (270.785)         (446.436) 
## -------------------------------------------------------
## Observations                  753               753    
## R2                           0.266                     
## Adjusted R2                  0.259                     
## Log Likelihood                              -3,819.095 
## Akaike Inf. Crit.                            7,656.189 
## Bayesian Inf. Crit.                          7,697.806 
## Residual Std. Error   750.179 (df = 745)               
## F Statistic         38.495*** (df = 7; 745)            
## =======================================================
## Note:                       *p<0.1; **p<0.05; ***p<0.01
summary(margEff(sTobit))
##          Marg. Eff. Std. Error t value  Pr(>|t|)    
## nwifeinc   -5.32644    2.69073 -1.9796 0.0481217 *  
## educ       48.73409   12.96341  3.7594 0.0001837 ***
## exper      79.50423   10.30497  7.7151 3.886e-14 ***
## expersq    -1.12651    0.32326 -3.4848 0.0005213 ***
## age       -32.87692    4.45770 -7.3753 4.383e-13 ***
## kidslt6  -540.25683   66.62393 -8.1091 2.220e-15 ***
## kidsge6    -9.80053   23.36134 -0.4195 0.6749580    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
scale_factor <- 5.19/8.81
scale_factor
## [1] 0.5891033

Example 17.3

Testing Exogeneity of Other Income in the Hours Equation

v2 <- resid(IV <- lm(nwifeinc ~  huseduc + educ + exper + expersq + age + kidslt6 + kidsge6, data = mroz))
summary(censReg(hours ~ nwifeinc + educ + exper + expersq + age + kidslt6 + kidsge6 + v2, data = mroz))
## 
## Call:
## censReg(formula = hours ~ nwifeinc + educ + exper + expersq + 
##     age + kidslt6 + kidsge6 + v2, data = mroz)
## 
## Observations:
##          Total  Left-censored     Uncensored Right-censored 
##            753            325            428              0 
## 
## Coefficients:
##               Estimate Std. error t value  Pr(> t)    
## (Intercept)  722.10317  475.68932   1.518 0.129011    
## nwifeinc     -31.48215   16.03761  -1.963 0.049644 *  
## educ         116.78139   32.75981   3.565 0.000364 ***
## exper        124.34877   17.87504   6.957 3.49e-12 ***
## expersq       -1.89720    0.53716  -3.532 0.000413 ***
## age          -46.89244    8.95768  -5.235 1.65e-07 ***
## kidslt6     -867.91310  112.90250  -7.687 1.50e-14 ***
## kidsge6       -6.32605   39.16565  -0.162 0.871684    
## v2            24.41832   16.58454   1.472 0.140925    
## logSigma       7.02094    0.03705 189.485  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Newton-Raphson maximisation, 7 iterations
## Return code 1: gradient close to zero
## Log-likelihood: -3818.012 on 10 Df

HOME | Back to top

Example 17.4

Annual Hours Equation for Married Women

summary(Participation <- glm(inlf ~ nwifeinc + educ + exper + expersq + age + kidslt6 + kidsge6, data = mroz, family=binomial(link="probit")))
## 
## Call:
## glm(formula = inlf ~ nwifeinc + educ + exper + expersq + age + 
##     kidslt6 + kidsge6, family = binomial(link = "probit"), data = mroz)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.2156  -0.9151   0.4315   0.8653   2.4553  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  0.2700736  0.5080782   0.532  0.59503    
## nwifeinc    -0.0120236  0.0049392  -2.434  0.01492 *  
## educ         0.1309040  0.0253987   5.154 2.55e-07 ***
## exper        0.1233472  0.0187587   6.575 4.85e-11 ***
## expersq     -0.0018871  0.0005999  -3.145  0.00166 ** 
## age         -0.0528524  0.0084624  -6.246 4.22e-10 ***
## kidslt6     -0.8683247  0.1183773  -7.335 2.21e-13 ***
## kidsge6      0.0360056  0.0440303   0.818  0.41350    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 1029.7  on 752  degrees of freedom
## Residual deviance:  802.6  on 745  degrees of freedom
## AIC: 818.6
## 
## Number of Fisher Scoring iterations: 4
summary(NormalH <- truncreg(hours ~ nwifeinc + educ + exper + expersq + age + kidslt6 + kidsge6, data = mroz, point=0, direction = "left"))
## 
## Call:
## truncreg(formula = hours ~ nwifeinc + educ + exper + expersq + 
##     age + kidslt6 + kidsge6, data = mroz, point = 0, direction = "left")
## 
## BFGS maximization method
## 57 iterations, 0h:0m:0s 
## g'(-H)^-1g =  60.4 
##  
## 
## 
## Coefficients :
##              Estimate Std. Error t-value  Pr(>|t|)    
## (Intercept) 1318.8208   884.1668  1.4916   0.13580    
## nwifeinc     -25.8081    10.3958 -2.4825   0.01305 *  
## educ          84.3128    41.2027  2.0463   0.04073 *  
## exper        402.7480    55.7661  7.2221 5.118e-13 ***
## expersq       -6.0773     1.2317 -4.9341 8.052e-07 ***
## age         -148.9702    22.2083 -6.7079 1.975e-11 ***
## kidslt6     -590.1136   236.2784 -2.4975   0.01251 *  
## kidsge6      -70.7249    74.4038 -0.9506   0.34183    
## sigma       1203.1805    80.9263 14.8676 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log-Likelihood: -5611.6 on 9 Df
# summary(LogNormalH <- truncreg(log(hours) ~ nwifeinc + educ + exper + expersq + age + kidslt6 + kidsge6, data = mroz, point=0, direction = "left"))

summary(Heckman <-selection(inlf ~ nwifeinc + educ + exper + expersq + age + kidslt6 + kidsge6, log(hours) ~ nwifeinc + educ + exper + expersq + age + kidslt6 + kidsge6, data=mroz, method="2step"))
## --------------------------------------------
## Tobit 2 model (sample selection model)
## 2-step Heckman / heckit estimation
## 753 observations (325 censored and 428 observed)
## 19 free parameters (df = 735)
## Probit selection equation:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.270077   0.508593   0.531  0.59556    
## nwifeinc    -0.012024   0.004840  -2.484  0.01320 *  
## educ         0.130905   0.025254   5.183 2.82e-07 ***
## exper        0.123348   0.018716   6.590 8.37e-11 ***
## expersq     -0.001887   0.000600  -3.145  0.00173 ** 
## age         -0.052853   0.008477  -6.235 7.63e-10 ***
## kidslt6     -0.868328   0.118522  -7.326 6.24e-13 ***
## kidsge6      0.036005   0.043477   0.828  0.40786    
## Outcome equation:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  8.683e+00  6.711e-01  12.939   <2e-16 ***
## nwifeinc     5.234e-03  6.572e-03   0.796   0.4261    
## educ        -1.118e-01  4.854e-02  -2.304   0.0215 *  
## exper       -1.182e-03  4.721e-02  -0.025   0.9800    
## expersq     -4.647e-05  9.210e-04  -0.050   0.9598    
## age          6.047e-03  1.892e-02   0.320   0.7494    
## kidslt6     -7.092e-02  3.199e-01  -0.222   0.8246    
## kidsge6     -9.052e-02  4.548e-02  -1.990   0.0469 *  
## Multiple R-Squared:0.1719,   Adjusted R-Squared:0.1561
##    Error terms:
##               Estimate Std. Error t value Pr(>|t|)  
## invMillsRatio  -1.1224     0.6230  -1.801    0.072 .
## sigma           1.1739         NA      NA       NA  
## rho            -0.9561         NA      NA       NA  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## --------------------------------------------

HOME | Back to top

Example 17.5

Panel Data Estimation of Annual Hours Equation for Women

#library(haven)
df <- read_dta("Wooldridge_2E/psid80_92.dta")
dfP <- pdata.frame(df, index = c("id", "year"))
Linear_FE <- plm(hours ~ nwifeinc + ch0_2 + ch3_5 + ch6_17 + marr + factor(year), data=dfP, model="within")

RE_Tobit <- censReg(hours ~ nwifeinc + ch0_2 + ch3_5 + ch6_17 + marr + factor(year), data=dfP, left = 0, method="BHHH")

CRE_Tobit <- censReg(hours ~ nwifeinc + ch0_2 + ch3_5 + ch6_17 + marr + factor(year) + nwifeincb + ch0_2b + ch3_5b + ch6_17b + marrb, data=dfP, left = 0, method="BHHH")

stargazer(Linear_FE, RE_Tobit, CRE_Tobit, title="Table 17.3 Panel Data Models for Annual Women's Labor Supply, 1980-1992", no.space=TRUE, type="text")
## 
## Table 17.3 Panel Data Models for Annual Women's Labor Supply, 1980-1992
## ========================================================================
##                                     Dependent variable:                 
##                     ----------------------------------------------------
##                                            hours                        
##                               panel                    censored         
##                               linear                  regression        
##                                (1)                 (2)          (3)     
## ------------------------------------------------------------------------
## nwifeinc                    -0.775***           -1.892***    -1.577***  
##                              (0.199)             (0.143)      (0.227)   
## ch0_2                      -342.377***         -440.759***  -471.742*** 
##                              (17.023)            (14.171)     (15.516)  
## ch3_5                      -254.128***         -299.439***  -328.120*** 
##                              (14.670)            (10.802)     (11.502)  
## ch6_17                      -42.958***          -20.217***   -45.540*** 
##                              (8.152)             (4.959)      (6.174)   
## marr                       -634.805***         -575.380***  -771.706*** 
##                             (116.420)            (19.091)     (68.596)  
## factor(year)81                -4.820              -7.240       -5.718   
##                              (23.787)            (51.395)     (50.648)  
## factor(year)82               -14.888             -39.979      -36.302   
##                              (23.795)            (39.848)     (39.593)  
## factor(year)83                6.613               -9.888       -7.560   
##                              (23.814)            (42.324)     (41.869)  
## factor(year)84              93.791***           101.147**    101.565**  
##                              (23.847)            (41.238)     (40.903)  
## factor(year)85              88.737***            91.105**     95.283**  
##                              (23.900)            (42.506)     (42.043)  
## factor(year)86              82.662***            85.978**     83.203**  
##                              (23.932)            (41.260)     (40.811)  
## factor(year)87              64.285***             51.638       56.972   
##                              (24.022)            (44.761)     (44.232)  
## factor(year)88              63.792***             60.385       50.785   
##                              (24.131)            (45.873)     (45.586)  
## factor(year)89              72.985***            75.422*      78.550*   
##                              (24.220)            (44.009)     (43.974)  
## factor(year)90              71.250***            81.835*      72.446*   
##                              (24.297)            (43.929)     (43.107)  
## factor(year)91              64.680***            76.771*      69.739*   
##                              (24.399)            (41.540)     (41.151)  
## factor(year)92                16.012              18.735       8.011    
##                              (24.516)            (36.776)     (36.746)  
## nwifeincb                                                    -5.890***  
##                                                               (0.418)   
## ch0_2b                                                      -292.789*** 
##                                                               (87.255)  
## ch3_5b                                                       552.908*** 
##                                                               (83.706)  
## ch6_17b                                                      51.703***  
##                                                               (13.410)  
## marrb                                                        477.199*** 
##                                                               (73.540)  
## logSigmaMu                                       6.561***     6.504***  
##                                                  (0.009)      (0.009)   
## logSigmaNu                                       6.449***     6.440***  
##                                                  (0.003)      (0.003)   
## Constant                                       1,426.356*** 1,431.644***
##                                                  (30.553)     (31.740)  
## ------------------------------------------------------------------------
## Observations                  11,674              11,674       11,674   
## R2                            0.072                                     
## Adjusted R2                   -0.007                                    
## Log Likelihood                                 -70,851.510  -70,820.850 
## Akaike Inf. Crit.                              141,743.000  141,691.700 
## Bayesian Inf. Crit.                            141,890.300  141,875.800 
## F Statistic         48.993*** (df = 17; 10759)                          
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01

HOME | Back to top