# NOT RUN {
# EXAMPLE 1: For this example, we conduct a consistent quantile regression
# model specification test for a parametric wage quantile regression
# model that is quadratic in age. The work of Murphy and Welch (1990)
# would suggest that this parametric quantile regression model is
# misspecified.
library("quantreg")
data("cps71")
attach(cps71)
model <- rq(logwage~age+I(age^2), tau=0.5, model=TRUE)
plot(age, logwage)
lines(age, fitted(model))
X <- data.frame(age)
# Note - this may take a few minutes depending on the speed of your
# computer...
npqcmstest(model = model, xdat = X, ydat = logwage, tau=0.5)
# Sleep for 5 seconds so that we can examine the output...
Sys.sleep(5)
# Next try Murphy & Welch's (1990) suggested quintic specification.
model <- rq(logwage~age+I(age^2)+I(age^3)+I(age^4)+I(age^5), model=TRUE)
plot(age, logwage)
lines(age, fitted(model))
X <- data.frame(age)
# Note - this may take a few minutes depending on the speed of your
# computer...
npqcmstest(model = model, xdat = X, ydat = logwage, tau=0.5)
detach(cps71)
# }
# NOT RUN {
# }
# NOT RUN {
<!-- % enddontrun -->
# }
Run the code above in your browser using DataLab