goodfit: Quantile regression goodness of fit

View source: R/goodfit.R

goodfitR Documentation

Quantile regression goodness of fit

Description

Calculate quantile regression goodness of fit using residuals and non-conditional residuals

Usage

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

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.

Value

A numeric value from 0 to 1 indicating goodness of fit

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.

See Also

wrtdsrsd for residuals

Examples


library(quantreg)

## random variables
x <- runif(100, 0, 10)
y <- x + rnorm(100)

## quantile model
mod <- rq(y ~ x, tau = 0.5)
res <- resid(mod)

## non-conditional quantile model
mod_nl <- rq(y ~ 1, tau = 0.5)
rsd_nl <- resid(mod_nl)

goodfit(res, rsd_nl, 0.5)

## r2 of mean model for comparison
mod_lm <- lm(y ~ x)

summary(mod_lm)$r.squared

fawda123/WRTDStidal documentation built on Oct. 22, 2023, 11:28 p.m.