Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

lprq

locally polynomial quantile regression


Description

This is a toy function to illustrate how to do locally polynomial quantile regression univariate smoothing.

Usage

lprq(x, y, h, tau = .5, m = 50)

Arguments

x

The conditioning covariate

y

The response variable

h

The bandwidth parameter

tau

The quantile to be estimated

m

The number of points at which the function is to be estimated

Details

The function obviously only does locally linear fitting but can be easily adapted to locally polynomial fitting of higher order. The author doesn't really approve of this sort of smoothing, being more of a spline person, so the code is left is its (almost) most trivial form.

Value

The function compute a locally weighted linear quantile regression fit at each of the m design points, and returns:

xx

The design points at which the evaluation occurs

fv

The estimated function values at these design points

dev

The estimated first derivative values at the design points

Note

One can also consider using B-spline expansions see bs.

Author(s)

R. Koenker

References

Koenker, R. (2004) Quantile Regression

See Also

rqss for a general approach to oonparametric QR fitting.

Examples

require(MASS)
data(mcycle)
attach(mcycle)
plot(times,accel,xlab = "milliseconds", ylab = "acceleration (in g)")
hs <- c(1,2,3,4)
for(i in hs){
        h = hs[i]
        fit <- lprq(times,accel,h=h,tau=.5)
        lines(fit$xx,fit$fv,lty=i)
        }
legend(50,-70,c("h=1","h=2","h=3","h=4"),lty=1:length(hs))

quantreg

Quantile Regression

v5.85
GPL (>= 2)
Authors
Roger Koenker [cre, aut], Stephen Portnoy [ctb] (Contributions to Censored QR code), Pin Tian Ng [ctb] (Contributions to Sparse QR code), Blaise Melly [ctb] (Contributions to preprocessing code), Achim Zeileis [ctb] (Contributions to dynrq code essentially identical to his dynlm code), Philip Grosjean [ctb] (Contributions to nlrq code), Cleve Moler [ctb] (author of several linpack routines), Yousef Saad [ctb] (author of sparskit2), Victor Chernozhukov [ctb] (contributions to extreme value inference code), Ivan Fernandez-Val [ctb] (contributions to extreme value inference code), Brian D Ripley [trl, ctb] (Initial (2001) R port from S (to my everlasting shame -- how could I have been so slow to adopt R!) and for numerous other suggestions and useful advice)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.