qregcdf: Nonparametric quantiles based on conditional CDF functions

Description Usage Arguments Details Value References See Also Examples

View source: R/qregcdf.R

Description

Estimates conditional quantile functions based on nonparametric conditional CDF functions

Usage

1
2
3
 
qregcdf(form,taumat=c(.10,.25,.50,.75,.90),hx=0,hy=0,nx=20,ny=100,
  targetx=0,targety=0,graph.target=FALSE,graph.yhat=FALSE, data=NULL)

Arguments

form

Model formula

taumat

Vector of quantiles. Default: taumat=c(.10, .25, .50, .75, .90)

hx

Bandwidth for x in K((X_i-x)/hx). Default: hx = 1.06*min(sd(x), (quantile(x,.75)-quantile(x,.25))/1.349)*(n^-.2)

hy

Bandwidth for y in Φ((y-Y_i)/hy) Default: hy = 1.06*min(sd(y), (quantile(y,.75)-quantile(y,.25))/1.349)*(n^(-.2))

nx

Number of target points for x if using an evenly spaced grid. Default is nx = 20. If nx>0, then targetx <- seq(min(x),max(x),length=nx)

ny

Number of target points for y if using an evenly spaced grid. Default is ny = 200. If ny>0, then targety <- seq(min(y),max(y),length=ny)

targetx

Vector of user-provided target values for x. An alternative to using nx to specify a uniformly spaced grid. Default: not specified.

targety

Vector of user-provided target values for y. An alternative to using nxy to specify a uniformly spaced grid. Default: not specified.

graph.target

If graph.target=T, graph of results is produced based on target values. Default: graph.target=F.

graph.yhat

If graph.yhat=T, graph of results is produced based on interpolations to actual values of x and y. Default: graph.yhat=F.

data

A data frame containing the data. Default: use data in the current working directory

Details

Following Li and Racine (2007), equation 6.3, a smoothed version of the conditional CDF of y given a value of x can be written:

F(y|x) = (1/n) { ∑_i Φ ((y-y_i)/hy)hx^{-1}K((X_i-x)/hx)}/{hx^{-1}∑_i K((X_i-x)/hx)}

The estimation procedure begins by evaluating this expression at each point in the grid determined by the values of target.x and target.y

The result is an nx x ny matrix of values for F(y|x). Let fxj represent the ny-vector of values of F(y|xj), and let fk indicate the entry of F(y|xj) associated with yk, k = 1,...,ny. Finally, let tau represent an entry of taumat. Then the value of yhat.target associated with quantile tau and xj is the largest value of fk such that fk < tau < fk+1. The resulting nx x length(taumat) matrix is available after estimation as yhat.target. The smooth12 is used to interpolate each column of yhat.target to span the full vector of original values of x. The result is the n x length(taumat) matrix yhat.

Note: The default bandwidth may prove too small if there are regions where x is sparse. It may be necessary to experiment with larger bandwidths for hx and hy. The function qreglwr is more flexible, allowing nearest neighbor approaches as well as fixed bandwidths.

Value

yhat

Matrix of quantile predictions. Dimension is n x length(taumat)

yhat.target

Matrix of quantile predictions at target values of x. Dimension is length(targetx) x length(taumat).

targetx

Vector of target values for x.

targety

Vector of target values for y.

taumat

Vector of target quantile values.

hx

Bandwidth for x.

hy

Bandwidth for y.

References

Li, Oi and Jeffrey Scott Racine. Nonparametric Econometrics: Theory and Practice. Princeton, NJ: Princeton University Press, 2007. Chapter 6.

See Also

condens

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(dupage99)
dupage99$ratio <- dupage99$av/dupage99$price
o <- order(dupage99$price)
dupage99 <- dupage99[o,]
attach(dupage99)
price <- price/1000

fit <- qregcdf(ratio~price)
ymin = min(fit$yhat)
ymax = max(fit$yhat)
plot(price, fit$yhat[,1],type="l",xlab="Sales Price (1000s)",ylab="Assessment Ratio",
  ylim=c(ymin,ymax),main="Nonparametric Conditional CDF Quantile Regression")
for (j in seq(2,5)) {
  lines(price,fit$yhat[,j])
}
fit$hx
fit$hy

McSpatial documentation built on May 2, 2019, 9:32 a.m.