Learn R Programming

Qtools (version 1.0)

rq.counts: Quantile Regression for Counts

Description

This function is used to fit a quantile regression model when the response is a count variable.

Usage

rq.counts(formula, tau = 0.5, data, tsf = "bc", symm = TRUE,
	lambda = 0,	weights = NULL, offset = NULL, contrasts = NULL,
	M = 50, zeta = 1e-05, B = 0.999, cn = NULL, alpha = 0.05,
	method = "fn")

Arguments

Value

a list of class rq.counts containing the following componentscallthe matched call.methodthe fitting algorithm for rq.xthe model matrix.ythe model response.tauthe order of the estimated quantile(s).tsftranformation used (see also attributes(tsf)).coefficientsregression quantile (on the log--scale).fitted.valuesfitted values (on the response scale).tTablecoefficients, standard errors, etc.offsetoffset.Mspecified number of dithered samples for standard error estimation.Mnactual number of dithered samples used for standard error estimation that gave an invertible D matrix (Machado and Santos Silva, 2005).InitialParstarting values for coefficients.termsthe terms object used.term.labelsnames of coefficients.rdfthe number of residual degrees of freedom.

Details

A linear quantile regression model is fitted to the log--transformed response. Additional tranformation functions will be implemented. The notation used here follows closely that of Machado and Santos Silva (2005). This function is based on routines from package quantreg (Koenker, 2013). See also lqm.counts from package lqmm (Geraci, 2014) for Laplace gradient estimation.

References

Geraci M and Jones MC. Improved transformation-based quantile regression. Canadian Journal of Statistics 2015;43(1):118-132. Koenker R (2013). quantreg: Quantile Regression. R package version 5.05. URL http://CRAN.R-project.org/package=quantreg. Machado JAF and Santos Silva JMC (2005). Quantiles for counts. Journal of the American Statistical Association, 100(472), 1226--1237.

Examples

Run this code
# Esterase data
data(esterase)

# Fit quantiles 0.25 and 0.75
fit1 <- rq.counts(Count ~ Esterase, tau = 0.25, data = esterase, M = 50)
coef(fit1)
fit2 <- rq.counts(Count ~ Esterase, tau = 0.75, data = esterase, M = 50)
coef(fit2)

# Plot
with(esterase, plot(Count ~ Esterase))
lines(esterase$Esterase, fit1$fitted.values, col = "blue")
lines(esterase$Esterase, fit2$fitted.values, col = "red")
legend(8, 1000, lty = c(1,1), col = c("blue", "red"), legend = c("tau = 0.25","tau = 0.75"))

Run the code above in your browser using DataLab