if(!requireNamespace("quantreg")) {
if(interactive() || is.na(Sys.getenv("_R_CHECK_PACKAGE_NAME_", NA))) {
stop("not all packages required for the example are installed")
} else q() }
## data and packages
library("quantreg")
data("CPS1988")
CPS1988$region <- relevel(CPS1988$region, ref = "south")
## Model equations: Mincer-type, quartic, Buchinsky-type
mincer <- log(wage) ~ ethnicity + education + experience + I(experience^2)
quart <- log(wage) ~ ethnicity + education + experience + I(experience^2) +
I(experience^3) + I(experience^4)
buchinsky <- log(wage) ~ ethnicity * (education + experience + parttime) +
region*smsa + I(experience^2) + I(education^2) + I(education*experience)
## OLS and LAD fits (for LAD see Bierens and Ginter, Tables 1-3.A.)
mincer_ols <- lm(mincer, data = CPS1988)
quart_ols <- lm(quart, data = CPS1988)
buchinsky_ols <- lm(buchinsky, data = CPS1988)
# \donttest{
quart_lad <- rq(quart, data = CPS1988)
mincer_lad <- rq(mincer, data = CPS1988)
buchinsky_lad <- rq(buchinsky, data = CPS1988)
# }
Run the code above in your browser using DataLab