Calculate quantile regression goodness of fit using residuals and non-conditional residuals
goodfit(resid, resid_nl, tau)
Arguments
resid: numeric vector of residuals from the conditional quantile model
resid_nl: numeric vector of residuals from the non-conditional (null) quantile model
tau: numeric value from zero to one for the estimated quantile
Returns
A numeric value from 0 to 1 indicating goodness of fit
Details
The goodness of fit measure for quantile regression is estimated as 1 minus the ratio between the sum of absolute deviations in the fully parameterized models and the sum of absolute deviations in the null (non-conditional) quantile model. The values are useful for comparisons between quantile models, but they are not comparable to standard coefficients of determination. The latter is based on the variance of squared deviations, whereas goodness of fit values for quantile regression are based on absolute deviations. Goodness of fit values will always be smaller than R2 values.
Examples
library(quantreg)## random variablesx <- runif(100,0,10)y <- x + rnorm(100)## quantile modelmod <- rq(y ~ x, tau =0.5)res <- resid(mod)## non-conditional quantile modelmod_nl <- rq(y ~1, tau =0.5)rsd_nl <- resid(mod_nl)goodfit(res, rsd_nl,0.5)## r2 of mean model for comparisonmod_lm <- lm(y ~ x)summary(mod_lm)$r.squared
References
Koenker, R., Machado, J.A.F. 1999. Goodness of fit and related inference processes for quantile regression. Journal of the American Statistical Association. 94(448):1296-1310.