The standard OLS (Ordinary Least Squares) model explains the relationship between independent variables and the conditional mean of the dependent variable. In contrast, quantile regression models this relationship for different quantiles of the dependent variable.
In this exercise set we will use the
quantreg package (package description: here) to implement quantile regression in R.
Answers to the exercises are available here.
quantreg package and the
barro dataset (Barro and Lee, 1994). This has data on GDP growth rates for various countries.
Next, summarize the data.
The dependent variable is
y.net (Annual change per capita GDP). The remaining variables will be used to explain
y.net. It is easier to combine variables using
cbind before applying regression techniques. Combine variables so that we can write
Y ~ X.
y.net on the independent variables using OLS. We will use this result as benchmark for comparison.
rq function, estimate the model at the median
y.net. Compare results from exercise-3.
Estimate the model for the first and third quartiles and compare results.
Using a single command estimate the model for 10 equally spaced deciles of
quantreg package also offers shrinkage estimators to determine which variables play the most important role in predicting
y.net. Estimate the model with LASSO based quantile regression at the median level with lambda=0.5.
Quantile plots are most useful for interpreting results. To do that we need to define the sequence of percentiles. Use the
seq function to define the sequence of percentiles from 5% to 95% with a jump of 5%.
Use the result from exercise-8 to plot the graphs. Note that the red line is the OLS estimate bounded by the dotted lines which represent confidence intervals.
Using results from exercise-5, test whether coefficients are significantly different for the first and third quartile based regressions.