1\name{boot.rq}
2\alias{boot.rq}
3\alias{boot.rq.xy}
4\alias{boot.rq.wxy}
5\alias{boot.rq.pwy}
6\alias{boot.rq.spwy}
7\alias{boot.rq.mcmb}
8\title{ Bootstrapping Quantile Regression}
9\description{
10These functions can be used to construct standard errors, confidence
11intervals and tests of hypotheses regarding quantile regression models.
12}
13\usage{
14boot.rq(x, y, tau = 0.5, R = 200, bsmethod = "xy", mofn = length(y),
15	coef = NULL, blbn = NULL, cluster = NULL, U = NULL,  ...)
16}
17\arguments{
18  \item{x}{ The regression design matrix}
19  \item{y}{ The regression response vector}
20  \item{tau}{ The quantile of interest}
21  \item{R}{ The number of bootstrap replications}
22  \item{bsmethod}{ The method to be employed.  There are (as yet) five
23	options:  method = "xy" uses the xy-pair method, and
24	method = "pwy" uses the method of Parzen, Wei and Ying (1994)
25	method = "mcmb" uses the Markov chain marginal bootstrap
26	of He and Hu (2002) and Kocherginsky, He and Mu (2003).
27	The fourth method = "wxy" uses the generalized bootstrap
28	of Bose and Chatterjee (2003) with unit exponential weights,
29	see also Chamberlain and Imbens (2003).  The fifth method
30	"wild" uses the wild bootstrap method proposed by Feng, He and Hu (2011). }
31  \item{mofn}{ optional argument for the bootstrap method "xy" that
32	permits subsampling (m out of n) bootstrap.  Obviously mofn
33	should be substantially larger than the column dimension of x,
34	and should be less than the sample size.}
35  \item{coef}{coefficients from initial fitted object}
36  \item{blbn}{orginal sample size for the BLB model}
37  \item{cluster}{If non-NULL this argument should specify cluster id
38      numbers for each observation, in which case the clustered version of
39      the bootstrap based on the proposal of Hagemann (2017). If present
40      \code{bsmethod} is set to set to "cluster". If this option is used
41      and the fitting method for the original call was "sfn" then the
42      bootstrapping will be carried out with the "sfn" as well.  This
43      is usually substantially quicker than the older version which
44      employed the "br" variant of the simplex method.  Use of "sfn"
45      also applies to the "pwy" method when the original fitting
46      was done with "sfn".  Finally, if \code{na.action = "omit"} and
47      \code{length(object$na.action) > 0} then these elements are also
48      removed from the \code{cluster} variable.  Consequently, the
49      length of the \code{cluster} variable should always be the same
50      as the length of the original response variable before any
51      \code{na.action} takes place.  }
52  \item{U}{If non-NULL this argument should specify an array of indices
53      or gradient evaluations to be used by the corresponding bootstrap
54      method as specified by \code{bsmethod}.  This is NOT intended as
55      a user specified input, instead it is specified in \code{summary.rqs}
56      to ensure that bootstrap samples for multiple taus use the same
57      realizations of the random sampling.}
58  \item{...}{ Optional arguments to control bootstrapping}
59}
60\details{
61Their are several refinements that are still unimplemented.  Percentile
62methods should be incorporated, and extensions of the methods to be used
63in anova.rq should be made.  And more flexibility about what algorithm is
64used would also be good.
65}
66\value{
67A list consisting of two elements:
68  A matrix \code{B} of dimension R by p is returned with the R resampled
69	estimates of the vector of quantile regression parameters. When
70	mofn < n for the "xy" method this matrix has been deflated by
71	the factor sqrt(m/n).
72  A matrix \code{U} of sampled indices (for \code{bsmethod in c("xy", "wxy")})
73	or gradient evaluations (for \code{bsmethod in c("pwy", "cluster")})
74	used to generate the bootstrapped realization, and potentially reused
75	for other \code{taus} when invoked from \code{summary.rqs}.
76}
77\references{
78[1] Koenker, R. W. (1994). Confidence Intervals for regression quantiles, in
79P. Mandl and M. Huskova (eds.), \emph{Asymptotic Statistics}, 349--359,
80Springer-Verlag, New York.
81
82[2] Kocherginsky, M., He, X. and Mu, Y. (2005).
83Practical Confidence Intervals for Regression Quantiles,
84Journal of Computational and Graphical Statistics, 14, 41-55.
85
86[3] Hagemann, A. (2017) Cluster Robust Bootstrap inference in
87quantile regression models, Journal of the American Statistical Association ,
88112, 446--456.
89
90[4] He, X. and Hu, F. (2002). Markov Chain Marginal Bootstrap.
91Journal of the American Statistical Association , Vol. 97, no. 459,
92783-795.
93
94[5] Parzen, M. I., L. Wei,  and Z. Ying  (1994): A resampling
95method based on pivotal estimating functions,'' Biometrika, 81, 341--350.
96
97[6] Bose, A. and S. Chatterjee, (2003) Generalized bootstrap for estimators
98of minimizers of convex functions, \emph{J. Stat. Planning and Inf}, 117, 225-239.
99
100[7]  Chamberlain G.  and Imbens G.W.  (2003) Nonparametric Applications of
101Bayesian Inference, Journal of Business & Economic Statistics, 21, pp. 12-18.
102
103[8]  Feng, Xingdong, Xuming He, and Jianhua Hu (2011) Wild Bootstrap for
104Quantile Regression, Biometrika, 98, 995--999.
105}
106
107\author{ Roger Koenker (and Xuming He and M. Kocherginsky for the mcmb code)}
108\seealso{  \code{\link{summary.rq}}}
109\examples{
110y <- rnorm(50)
111x <- matrix(rnorm(100),50)
112fit <- rq(y~x,tau = .4)
113summary(fit,se = "boot", bsmethod= "xy")
114summary(fit,se = "boot", bsmethod= "pwy")
115#summary(fit,se = "boot", bsmethod= "mcmb")
116}
117\keyword{ regression}
118