File: lprq.R

package info (click to toggle)
r-cran-quantreg 5.38-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,080 kB
  • sloc: fortran: 7,125; makefile: 2
file content (16 lines) | stat: -rw-r--r-- 467 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
lprq <- function(x, y, h, tau = .5, m = 50)
{
	## A toy routine to do locally polynomial quantile regression
        xx <- seq(min(x),max(x),length=m)
        fv <- xx
        dv <- xx
        for(i in 1:length(xx)) {
                z <- x - xx[i]
                wx <- dnorm(z/h)
                r <- rq(y~z, weights=wx, tau=tau, ci=FALSE)
                fv[i] <- r$coef[1.]
                dv[i] <- r$coef[2.]
        }
        list(xx = xx, fv = fv, dv = dv)
}