npqr {quantreg.nonpar} | R Documentation |
Nonparametric Series Quantile Regression
Description
Implements the nonparametric quantile regression methods developed by Belloni, Chernozhukov, and Fernandez-Val (2011) to partially linear quantile models, Y=g(w,u)+v'\gamma(u)
, u|v,w~U[0,1]
. Provides point estimates of the conditional quantile function and its derivatives based on series approximations to the nonparametric part of the model, g(w,u)
, approximated by Z(w)'\beta(u)
. Provides pointwise and uniform confidence intervals using analytic and resampling methods.
Usage
npqr(formula, data, basis = NULL, var, taus = c(0.25, 0.5, 0.75),
print.taus = NULL, B = 200, nderivs = 1, average = T,
load = NULL, alpha = 0.05, process = "pivotal", rearrange = F,
rearrange.vars="quantile", uniform = F, se = "unconditional",
printOutput = T, method = "fn")
Arguments
formula |
a formula object, with the response Y on the left of a ~ operator, and the covariate terms, separated by + operators on the right, not including the regressor whose effect is to be estimated nonparametrically. Operators such as '*', ':', 'log()', and 'I()' are allowable. However, factor variables should be constructed prior to entry in the formula: the 'factor()' operator is not allowable. |
data |
a data.frame in which to interpret the variables named in the |
basis |
a nonparametric basis object (created with the package |
var |
a column name within |
taus |
a vector of quantiles of interest. |
print.taus |
a vector of quantiles (which must be a subset of |
B |
the number of simulations (for the pivotal and gaussian methods) or bootstrap repetitions (for the weighted bootstrap and gradient bootstrap methods) to be performed. |
nderivs |
if |
average |
if |
load |
optional manual input of loading vector (or matrix of loading vectors) that will be used as data points at which inference will be performed and over which hypothesis tests will be conducted. Each vector of |
alpha |
a real number between 0 and 1: the desired significance level (e.g., 0.05). |
process |
either "pivotal", "gaussian", "wbootstrap", "gbootstrap", or "none": specifies the process used to estimate confidence intervals and p-values of hypothesis tests (or, if |
rearrange |
a boolean specifiying whether estimates will be monotonized prior to performing inference (requires that |
rearrange.vars |
if |
uniform |
a boolean specifying whether inference will be done uniformly across observations and quantiles or in a pointwise manner. |
se |
either "conditional" or "unconditional". Specifies whether standard errors, for pivotal and gaussian methods, will be conditional on the sample or not. |
printOutput |
a boolean specifying whether or not output will be printed. |
method |
method to be implemented in quantile regressions: passed to function |
Details
The loading vector may be specified in one of two ways: it may be input manually with load
. If load
is not specified, the loading vector will be calculated automatically using average
and nderivs
as parameters.
Note that derivatives calculated automatically will always be with respect to the nonparametric variable of interest, var
. This means that, for example, if var=logprice
, where logprice
is the natural logarithm of price, then the derivative will be taken with respect to logprice
, not with respect to price
. Specification of var
will not admit mathematical functions such as log
. Specification of formula
will admit some functions (e.g., log
, multiplication of covariates, interaction of covariates). However, formula will not admit some formula operators; in particular, factor variables must be saved as new variables prior to entry into formula. See the vignette for more information.
Value
returns a list of results
CI |
an array containing the two-sided confidence interval for each pair of loading vectors and |
CI.oneSided |
an array containing the one-sided confidence bounds for each pair of loading vectors and |
point.est |
a matrix containing the point estimates of interest (e.g., the average derivative of the conditional quantile function) for each pair of loading vectors and |
std.error |
a matrix containing estimated standard errors for the point estimates for each pair of loading vectors and |
pvalues |
a vector containing the p-values for hypothesis tests of three null hypotheses. First, that theta(tau,w) <= 0 for all (tau,w) pairs, where theta is the quantity of interest (e.g., the derivative of the function at each quantile and at each observation). Second, that theta(tau,w) >= 0 for all (tau,w) pairs. Third, that theta(tau,w) = 0 for all (tau,w) pairs. |
taus |
This is the input vector of quantile indexes. |
coefficients |
a list of length equal to the number of |
var.unique |
a vector containing all values of the covariate of interest with no repeated values. |
load |
the loading vector or matrix of loading vectors used as data points at which inference was performed and over which hypothesis tests were conducted. If |
Author(s)
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
References
Belloni, A., Chernozhukov, V., and I. Fernandez-Val (2011), "Conditional quantile processes based on series or many regressors," arXiv: 1105:6154.
Koenker, R. (2011), "Additive models for quantile regression: Model selection and confidence bandaids," Brazilian Journal of Probability and Statistics 25(3), pp. 239-262.
Koenker, R. and G. Bassett (1978): "Regression Quantiles," Econometrica 46, pp. 33-50.
Ramsay, J.O., Wickham, H., Graves, S., and G. Hooker (2013), "fda: Functional Data Analysis," R package version 2.3.6, http://CRAN.R-project.org/package=fda
See Also
Examples
data(india)
## Subset the data for speed
india.subset<-india[1:1000,]
formula=cheight~mbmi+breastfeeding+mage+medu+edupartner
basis.bsp <- create.bspline.basis(breaks=quantile(india$cage,c(0:10)/10))
n=length(india$cage)
B=500
alpha=.95
taus=c(1:24)/25
print.taus=c(1:4)/5
## Inference on average growth rate
piv.bsp <- npqr(formula=formula, data=india.subset, basis=basis.bsp,
var="cage", taus=taus, print.taus=print.taus, B=B, nderivs=1,
average=1, alpha=alpha, process="pivotal", rearrange=FALSE,
uniform=TRUE, se="unconditional", printOutput=TRUE, method="fn")
yrange<-range(piv.bsp$CI)
xrange<-c(0,1)
plot(xrange,yrange,type="n",xlab="",ylab="Average Growth (cm/month)")
lines(piv.bsp$taus,piv.bsp$point.est)
lines(piv.bsp$taus,piv.bsp$CI[1,,1],col="blue")
lines(piv.bsp$taus,piv.bsp$CI[1,,2],col="blue")
title("Average Growth Rate")
## Estimation on average growth acceleration with no inference
piv.bsp.secondderiv <- npqr(formula=formula, data=india.subset,
basis=basis.bsp, var="cage", taus=taus, print.taus=print.taus,
B=B, nderivs=2, average=0, alpha=alpha, process="none",
se="conditional", rearrange=FALSE, printOutput=FALSE, method="fn")
xsurf<-as.vector(piv.bsp.secondderiv$taus)
ysurf<-as.vector(piv.bsp.secondderiv$var.unique)
zsurf<-t(piv.bsp.secondderiv$point.est)
persp(xsurf, ysurf, zsurf, xlab="Quantile", ylab="Age (months)",
zlab="Growth Acceleration", ticktype="detailed", phi=30,
theta=120, d=5, col="green", shade=0.75, main="Growth Acceleration")