predict.iMqr {Mqrcm} | R Documentation |
Prediction After M-Quantile Regression Coefficients Modeling
Description
Predictions from an object of class “iMqr
”.
Usage
## S3 method for class 'iMqr'
predict(object, type = c("beta", "CDF", "QF", "sim"), newdata, p, se = TRUE, ...)
Arguments
object |
an object of class “ |
type |
a character string specifying the type of prediction. See ‘Details’. |
newdata |
an optional data frame in which to look for variables with which to predict. If omitted, the data are used. For type = "CDF", it must include the response variable. Ignored if type = "beta". |
p |
a numeric vector indicating the order(s) of the quantile to predict. Only used if type = "beta" or type = "QF". |
se |
logical. If TRUE (the default), standard errors of the prediction will be computed. Only used if type = "beta" or type = "QF". |
... |
for future methods. |
Details
Using iMqr
, M-quantile regression coefficients
\beta(p)
are modeled as parametric functions of p
, the order of the quantile.
This implies that the model parameter is not \beta(p)
itself.
The function predict.iqr
permits computing \beta(p)
and other
quantities of interest, as detailed below.
if type = "beta" (the default),
\beta(p)
is returned at the supplied value(s) of p. If p is missing, a default p = (0.01, ..., 0.99) is used.if type = "CDF", the value of the fitted CDF (cumulative distribution function) and PDF (probability density function) are computed. The CDF value should be interpreted as the order of the M-quantile that corresponds to the observed
y
values, while the PDF is just the first derivative of the CDF.if type = "QF", the fitted values
x'\beta(p)
, corresponding to the conditional M-quantile function, are computed at the supplied values of p.if type = "sim", data are simulated from the fitted model. To simulate the data, the fitted conditional M-quantile function is computed at randomly generated p following a Uniform(0,1) distribution. CAUTION: this generates data assuming that the model describes the quantile function, while in practice it describes M-quantiles.
Value
if type = "beta" a list with one item for each covariate in the model. Each element of the list is a data frame with columns (p, beta, se, low, up) reporting
\beta(p)
, its estimated standard error, and the corresponding 95% confidence interval. If se = FALSE, the last three columns are not computed.if type = "CDF", a two-columns data frame (CDF,PDF).
if type = "QF" and se = FALSE, a data frame with one row for each observation, and one column for each value of p. If se = TRUE, a list of two data frames, fit (predictions) and se.fit (standard errors).
if type = "sim", a vector of simulated data.
Note
Prediction may generate quantile crossing
if the support of the new covariates values supplied in newdata
is different from that of the observed data.
Author(s)
Paolo Frumento paolo.frumento@unipi.it
See Also
iMqr
, for model fitting; summary.iMqr
and plot.iMqr
,
for summarizing and plotting iMqr
objects.
Examples
# using simulated data
n <- 250
x <- runif(n)
y <- rlogis(n, 1 + x, 1 + x)
# true quantile function: Q(p | x) = beta0(p) + beta1(p)*x, with
# beta0(p) = beta1(p) = 1 + log(p/(1 - p))
model <- iMqr(y ~ x, formula.p = ~ I(log(p)) + I(log(1 - p)))
# (fit asymmetric logistic distribution)
# predict beta(0.25), beta(0.5), beta(0.75)
predict(model, type = "beta", p = c(0.25,0.5, 0.75))
# predict the CDF and the PDF at new values of x and y
predict(model, type = "CDF", newdata = data.frame(x = c(.1,.2,.3), y = c(1,2,3)))
# computes the quantile function at new x, for p = (0.25,0.5,0.75)
predict(model, type = "QF", p = c(0.25,0.5,0.75), newdata = data.frame(x = c(.1,.2,.3)))
# simulate data from the fitted model
ysim <- predict(model, type = "sim") # 'newdata' can be supplied
# NOTE: data are generated using the fitted M-quantile function as if
# it was a quantile function. This means that the simulated data will
# have quantiles (and not M-quantiles) described by the fitted model.
# There is no easy way to generate data with a desired M-quantile function.