Factored out code used in both stat_quant_line(), stat_quant_band() and stat_quant_eq().
quant_helper_fun(
data,
formula = y ~ x,
quantiles = c(0.25, 0.5, 0.75),
fit.by.quantile = FALSE,
method,
method.name,
method.args = list(),
n.min = 3L,
fit.seed = NA,
weight = 1,
na.rm = FALSE,
orientation = "x"
)A list, with members fm1, fm2, ... one for each fitted model and fun.args1, fun.args2, ... with arguments passed in each call to the model fit function.
A layer specific dataset, only needed if you want to override the plot defaults.
a formula object. Using aesthetic names x and y
instead of original variable names.
numeric vector Values in 0..1 indicating the quantiles.
logical If TRUE return a separate fitted model object for each quantile as needed for predictions with confidence bands.
function or character If character, "rq", "rqss" or the name of
a model fit function are accepted, possibly followed by the fit function's
method argument separated by a colon (e.g. "rq:br"). If a
function different to rq(), it must accept arguments named
formula, data, weights, tau and method
and return a model fit object of class rq, rqs or
rqss.
named list with additional arguments passed to
rq(), rqss() or to another function passed as argument to
method.
integer Minimum number of distinct values in the explanatory variable (on the rhs of formula) for fitting to the attempted.
RNG seed argument passed to
set.seed(). Defaults to NA, indicating
that set.seed() should not be called.
a logical indicating whether NA values should be stripped before the computation proceeds.
character Either "x" or "y" controlling the default for
formula. The letter indicates the aesthetic considered the
explanatory variable in the model fit.
This function does the model fitting and returns a fitted model object. It decodes the method, sorts the quantiles and does the fit.
ggpmisc:::quant_helper_fun(data.frame(x = mpg$displ, y = mpg$hwy), method = "br")
Run the code above in your browser using DataLab