II Econometric Analysis Using R

Also available in Stata and Python versions

### Chapter 12. M-Estimation, Nonlinear Regression, and Quantile Regression

#### Example 12.1

library(wooldridge)
library(stargazer)
library(quantreg)
library(sandwich)

Quantile Regression for Financial Wealth

OLS<-lm(nettfa ~ inc + age + agesq + e401k, data=k401ksubs, subset=fsize==1)
OLSr <- sqrt(diag(vcovHC(OLS, type="HC")))
Q10<-rq(nettfa ~ inc + age + agesq + e401k, data=k401ksubs, subset=fsize==1, tau = .10)
Q25<-rq(nettfa ~ inc + age + agesq + e401k, data=k401ksubs, subset=fsize==1, tau = .25)
LAD<-rq(nettfa ~ inc + age + agesq + e401k, data=k401ksubs, subset=fsize==1, tau = .50)
Q75<-rq(nettfa ~ inc + age + agesq + e401k, data=k401ksubs, subset=fsize==1, tau = .75)
Q90<-rq(nettfa ~ inc + age + agesq + e401k, data=k401ksubs, subset=fsize==1, tau = .90)
stargazer(OLS, Q10,Q25,LAD,Q75,Q90, column.labels = c("OLS", "Q10","Q25","LAD","Q75","Q90"), se=list(OLSr), no.space=TRUE, type="text")
##
## ==========================================================================================
##                                              Dependent variable:
##                     ----------------------------------------------------------------------
##                                                     nettfa
##                               OLS                              quantile
##                                                               regression
##                               OLS              Q10     Q25      LAD       Q75       Q90
##                               (1)              (2)     (3)      (4)       (5)       (6)
## ------------------------------------------------------------------------------------------
## inc                         0.783***         -0.018  0.071*** 0.324*** 0.798***  1.291***
##                             (0.104)          (0.037) (0.013)  (0.033)   (0.057)   (0.111)
## age                          -1.568          -0.066   0.034    -0.244  -1.386*** -3.579***
##                             (1.075)          (0.222) (0.097)  (0.149)   (0.486)   (1.219)
## agesq                       0.028**           0.002   0.0004  0.005**  0.024***  0.061***
##                             (0.014)          (0.003) (0.001)  (0.002)   (0.007)   (0.017)
## e401k                       6.837***          0.949  1.281*** 2.598*** 4.460***  6.001***
##                             (2.171)          (0.633) (0.345)  (0.394)   (0.935)   (2.325)
## Constant                     2.534           -5.228  -4.373**  -3.573    7.539    37.268*
##                             (19.237)         (4.550) (2.089)  (2.637)   (8.351)  (21.980)
## ------------------------------------------------------------------------------------------
## Observations                 2,017            2,017   2,017    2,017     2,017     2,017
## R2                           0.127
## Note:                                                          *p<0.1; **p<0.05; ***p<0.01