predict.rq {quantreg} | R Documentation |
Prediction based on fitted quantile regression model
## S3 method for class 'rq' predict(object, newdata, type = "none", interval = c("none", "confidence"), level = .95, na.action = na.pass, ...) ## S3 method for class 'rqs' predict(object, newdata, type = "Qhat", stepfun = FALSE, na.action = na.pass, ...) ## S3 method for class 'rq.process' predict(object, newdata, type = "Qhat", stepfun = FALSE, na.action = na.pass, ...)
object |
object of class rq or rqs or rq.process produced by |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
interval |
type of interval desired: default is 'none', when set to 'confidence' the function returns a matrix predictions with point predictions for each of the 'newdata' points as well as lower and upper confidence limits. |
level |
converage probability for the 'confidence' intervals. |
type |
For |
stepfun |
If 'TRUE' return stepfunctions otherwise return matrix of predictions.
these functions can be estimates of either the conditional quantile or distribution
functions depending upon the |
na.action |
function determining what should be done with missing values in 'newdata'. The default is to predict 'NA'. |
... |
Further arguments passed to or from other methods. |
Produces predicted values, obtained by evaluating the quantile regression function in the frame 'newdata' (which defaults to 'model.frame(object)'. These predictions purport to estimate the conditional quantile function of the response variable of the fitted model evaluated at the covariate values specified in "newdata" and the quantile(s) specified by the "tau" argument. Several methods are provided to compute confidence intervals for these predictions.
A vector or matrix of predictions, depending upon the setting of
'interval'. In the case that there are multiple taus in object
when object is of class 'rqs' setting 'stepfun = TRUE' will produce a
stepfun
object or a list of stepfun
objects.
The function rearrange
can be used to monotonize these
step-functions, if desired.
R. Koenker
Zhou, Kenneth Q. and Portnoy, Stephen L. (1998) Statistical inference on heteroscedastic models based on regression quantiles Journal of Nonparametric Statistics, 9, 239-260
data(airquality) airq <- airquality[143:145,] f <- rq(Ozone ~ ., data=airquality) predict(f,newdata=airq) f <- rq(Ozone ~ ., data=airquality, tau=1:19/20) fp <- predict(f, newdata=airq, stepfun = TRUE) fpr <- rearrange(fp) plot(fp[[2]],main = "Conditional Ozone Quantile Prediction") lines(fpr[[2]], col="red") legend(.2,20,c("raw","cooked"),lty = c(1,1),col=c("black","red")) fp <- predict(f, newdata=airq, type = "Fhat", stepfun = TRUE) fpr <- rearrange(fp) plot(fp[[2]],main = "Conditional Ozone Distribution Prediction") lines(fpr[[2]], col="red") legend(20,.4,c("raw","cooked"),lty = c(1,1),col=c("black","red"))