Extract R^2 from quantile regression / summary()
Asked Answered
M

2

8

I am using the quantreg package to run the following quantile regression in R:

bank <-rq(gekX~laggekVIXclose+laggekliquidityspread+lagdiffthreeMTBILL+
lagdiffslopeyieldcurve+lagdiffcreditspread+laggekSPret, tau=0.99)

and extract the coefficients and the summary statistic via

bank$coefficients
summary(bank)

The results I get, are

Call: rq(formula = gekX ~ laggekVIXclose + laggekliquidityspread + 
lagdiffthreeMTBILL + lagdiffslopeyieldcurve + lagdiffcreditspread + 
laggekSPret, tau = 0.99)

tau: [1] 0.99

Coefficients:
                       Value    Std. Error t value  Pr(>|t|)
(Intercept)            -0.03005  0.01018   -2.95124  0.00319
laggekVIXclose          0.00471  0.00069    6.81515  0.00000
laggekliquidityspread  -0.01295  0.01619   -0.79976  0.42392
lagdiffthreeMTBILL     -0.12273  0.12016   -1.02136  0.30717
lagdiffslopeyieldcurve -0.13100  0.06457   -2.02876  0.04258
lagdiffcreditspread    -0.21198  0.15659   -1.35377  0.17592
laggekSPret            -0.01205  0.46559   -0.02588  0.97936

However, I would like to know the R^2/adjusted R^2 - which the summary()-command seems to deliver for simple OLS regressions, but not in case of quantile regressions.

Does anybody know, how to extract them?

Mangan answered 8/11, 2013 at 14:17 Comment(0)
R
10

In quantile regression, you don't have R-squared or adjusted R-squared. It's only pseudo R squared and is not reported in rq as you would expect when you use summary in lm, but you can compute it as follows after estimation of the model bank.

rho <- function(u,tau=.5)u*(tau - (u < 0))
V <- sum(rho(bank$resid, bank$tau))

This is the answer provided by the author of the package "quantreg" here

Rosiarosicrucian answered 8/11, 2013 at 15:19 Comment(1)
@Rosiarosicrucian This calculates only half of the pseudo-R^2 ingredients.Sty
S
11

The pseudo-R^2 measure suggested by Koenker and Machado's 1999 JASA paper measures goodness of fit by comparing the sum of weighted deviations for the model of interest with the same sum from a model in which only the intercept appears.

Here's an example in R:

library(quantreg)
data(engel)

fit0 <- rq(foodexp~1,tau=0.9,data=engel)
fit1 <- rq(foodexp~income,tau=0.9,data=engel)

rho <- function(u,tau=.5)u*(tau - (u < 0))
R1 <- 1 - fit1$rho/fit0$rho

The code in the other answer only gives you the numerator of that fraction.

Sty answered 16/12, 2014 at 17:10 Comment(2)
Could you please explain the function used for generating "rho"? Why tau=0.5 is used in there?Barabbas
@Barabbas Sorry for the delayed response. The default is to use median (tau=0.5) as the default since that is the default in rq() and is often omitted. There is more info in this CV post.Sty
R
10

In quantile regression, you don't have R-squared or adjusted R-squared. It's only pseudo R squared and is not reported in rq as you would expect when you use summary in lm, but you can compute it as follows after estimation of the model bank.

rho <- function(u,tau=.5)u*(tau - (u < 0))
V <- sum(rho(bank$resid, bank$tau))

This is the answer provided by the author of the package "quantreg" here

Rosiarosicrucian answered 8/11, 2013 at 15:19 Comment(1)
@Rosiarosicrucian This calculates only half of the pseudo-R^2 ingredients.Sty

© 2022 - 2024 — McMap. All rights reserved.