1\name{anova.rq} 2\alias{anova.rq} 3\alias{anova.rqs} 4\alias{anova.rqlist} 5\alias{print.anova.rq} 6\alias{rq.test.rank} 7\alias{rq.test.anowar} 8\title{ Anova function for quantile regression fits } 9\description{ 10 Compute test statistics for two or more quantile regression fits. 11} 12\usage{ 13\method{anova}{rq}(object, ..., test = "Wald", joint = TRUE, score = 14 "tau", se = "nid", iid = TRUE, R = 200, trim = NULL) 15\method{anova}{rqs}(object, ..., se = "nid", iid = TRUE, joint = TRUE) 16\method{anova}{rqlist}(object, ..., test = "Wald", joint = TRUE, 17 score = "tau", se = "nid", iid = TRUE, R = 200, trim = NULL) 18rq.test.rank(x0, x1, y, v = NULL, score = "wilcoxon", weights = NULL, tau=.5, 19 iid = TRUE, delta0 = rep(0,NCOL(x1)), omega = 1, trim = NULL, pvalue = "F") 20rq.test.anowar(x0,x1,y,tau,R) 21\method{print}{anova.rq}(x, ...) 22} 23\arguments{ 24 \item{object, ...}{objects of class `rq', originating from a call to `rq'. 25 or a single object of class rqs, originating from a call to 'rq' with 26 multiple taus specified.} 27 \item{test}{ A character string specifying the test statistic to use. 28 Can be either `Wald' or `rank'.} 29 \item{joint}{A logical flag indicating whether tests of equality of slopes 30 should be done as joint tests on all slope parameters, or whether 31 (when joint = FALSE) separate tests on each of the slope parameters 32 should be reported. This option applies only to the tests of 33 equality of slopes in the case that estimated models correspond 34 to distinct taus.} 35 \item{score}{ A character string specifying the score function to use, 36 only needed or applicable for the `rank' form of the test.} 37 38 \item{trim}{optional trimming proportion parameter(s) -- only applicable for the 39 Wilcoxon score function -- when one value is provided there is symmetric 40 trimming of the score integral to the interval \code{(trim, 1-trim)}, when 41 there are two values provided, then the trimming restricts the integration 42 to \code{(trim[1], trim[2])}.} 43 \item{x}{ objects of class `summary.rq', originating from a call to `summary'. } 44 \item{x0}{design matrix for the null component of the rank and anowar tests. } 45 \item{x1}{design matrix for the alternative component of the rank and anowar tests. } 46 \item{y}{response vector for the alternative component of the rank and anowar tests. } 47 \item{v}{optional rq process fit} 48 \item{se}{method for computing standard errors, either "nid" or "ker", note 49 that "boot" cannot be used for testing homogeneity of slopes.} 50 \item{tau}{quantile of interest for quantile specific forms of testing.} 51 \item{iid}{logical flag for quantile specific forms of testing, if TRUE the 52 test presumes that the conditional densities take identical values, 53 if it is FALSE then local densities are estimated and used, see Koenker(2005) 54 p. 90.} 55 \item{delta0}{vector of hypothetical parameter values under test, typically zeros 56 but can be specified to be nonzero in cases where simulations are being used 57 to evaluate the validity of the non-central chisquare theory of the test.} 58 \item{omega}{value to be used for the score and F dependent constant appearing 59 in the non-centrality parameter, this is only needed/useful when delta0 60 is specified to be non-zero. In the usual Wilcoxon (untrimmed) case this 61 value is the integral the squared density.} 62 \item{pvalue}{type of p-value to be used, by default a pseudo F-statistic is 63 produced and the corresponding F p-value is computed, otherwise the 64 more conventional chisquared p-values are reported.} 65 \item{weights}{optional weight vector to be used for fitting.} 66 \item{R}{ The number of resampling replications for the anowar form of the test, 67 used to estimate the reference distribution for the test statistic.} 68} 69\details{ 70There are two (as yet) distinct forms of the test. In the first the 71fitted objects all have the same specified quantile (tau) and the intent 72is to test the hypothesis that smaller models are adequate relative to 73the largest specified model. In the second form of the test the linear predictor 74of the fits are all the same, but the specified quantiles (taus) are different. 75 76In the former case there are three options for 77the argument `test', by default a Wald test is computed as in 78Bassett and Koenker (1982). If \code{test = 'anowar'} is specified 79then the test is based on the procedure suggested in Chen, Ying, Zhang 80and Zhao (2008); the test is based on the difference in the QR objective 81functions at the restricted and unrestricted models with a reference 82distribution computed by simulation. The p-value of this form of the 83test is produced by fitting a density to the simulation values forming 84the reference distribution using the \code{logspline} function from 85the \pkg{logspline} package. The acronym anowar stands for analysis 86of weighted absolute residuals. If \code{test='rank'} is specified, then a rank 87test statistic is computed as described in Gutenbrunner, Jureckova, 88Koenker and Portnoy (1993). In the latter case one can also specify 89a form for the score function of the rank test, by default the Wilcoxon 90score is used, the other options are score=`sign' for median (sign) scores, 91or score=`normal' for normal (van der Waerden) scores. A fourth option 92is score=`tau' which is a generalization of median scores to an arbitrary 93quantile, in this case the quantile is assumed to be the one associated 94with the fitting of the specified objects. The computing of 95the rank form of the test is carried out in the \code{\link{rq.test.rank}} 96function, see \code{\link{ranks}} for further details on the score function 97options. The Wald form of the test is local in sense that the null hypothesis 98asserts only that a subset of the covariates are ``insignificant'' at 99the specified quantile of interest. The rank form of the test can also be 100used to test the global hypothesis that a subset is ``insignificant'' 101over an entire range of quantiles. The use of the score function 102score = "tau" restricts the rank test to the local hypothesis of 103the Wald test. 104 105In the latter case the hypothesis of interest is that the slope coefficients of 106the models are identical. The test statistic is a variant of the Wald 107test described in Koenker and Bassett (1982). 108 109By default, both forms of the tests return an F-like statistic in the sense that the 110an asymptotically Chi-squared statistic is divided by its degrees of 111freedom and the reported p-value is computed for an F statistic based on 112the numerator degrees of freedom equal to the rank of the null hypothesis and 113the denominator degrees of freedom is taken to be the sample size 114minus the number of parameters of the maintained model. 115} 116\value{ 117 An object of class `"anova"' inheriting from class `"data.frame"'. 118} 119\references{ 120[1] Bassett, G. and R. Koenker (1982). Tests of Linear Hypotheses 121and L1 Estimation, 122\emph{Econometrica}, \bold{50}, 1577--83. 123 124[2] Koenker, R. W. and Bassett, G. W. (1982). Robust Tests for 125Heteroscedasticity based on Regression Quantiles, 126\emph{Econometrica}, \bold{50}, 43--61. 127 128[3] Gutenbrunner, C., Jureckova, J., Koenker, R, and S. Portnoy (1993). 129Tests of Linear Hypotheses based on Regression Rank Scores, 130\emph{J. of Nonparametric Statistics}, \bold{2}, 307--331. 131 132[4] Chen, K. Z. Ying, H. Zhang, and L Zhao, (2008) Analysis of least absolute 133deviations, Biometrika, 95, 107-122. 134 135[5] Koenker, R. W. (2005). Quantile Regression, Cambridge U. Press. 136} 137\author{ Roger Koenker } 138 139\section{WARNING }{ 140An attempt to verify that the models are nested in the first form 141of the test is made, but this relies on checking set inclusion of 142the list of variable names and is subject to obvious ambiguities 143when variable names are generic. 144The comparison between two or more models will only be valid if 145they are fitted to the same dataset. This may be a problem if 146there are missing values and R's default of `na.action = na.omit' is used. 147The rank version of the nested model tests involves computing the entire 148regression quantile process using parametric linear programming and thus 149can be rather slow and memory intensive on problems with more than 150several thousand observations.} 151\seealso{The model fitting function \code{\link{rq}}, 152and the functions for testing hypothesis on the entire quantile 153regression process \code{\link{KhmaladzeTest}}. For further details 154on the rank tests see \code{\link{ranks}}.} 155\examples{ 156data(barro) 157fit0 <- rq(y.net ~ lgdp2 + fse2 + gedy2 , data = barro) 158fit1 <- rq(y.net ~ lgdp2 + fse2 + gedy2 + Iy2 + gcony2, data = barro) 159fit2 <- rq(y.net ~ lgdp2 + fse2 + gedy2 + Iy2 + gcony2, data = barro,tau=.75) 160fit3 <- rq(y.net ~ lgdp2 + fse2 + gedy2 + Iy2 + gcony2, data = barro,tau=.25) 161anova(fit1,fit0) 162anova(fit1,fit2,fit3) 163anova(fit1,fit2,fit3,joint=FALSE) 164# Alternatively fitting can be done in one call: 165fit <- rq(y.net ~ lgdp2 + fse2 + gedy2 + Iy2 + gcony2, 166 method = "fn", tau = 1:4/5, data = barro) 167} 168\keyword{ htest } 169\keyword{ regression} 170\keyword{ robust} 171