Learn R Programming

ggpmisc (version 0.7.0)

fit_models_internal: Apply model fit methods to data

Description

Fit models using different methods translating some arguments to make possible use of consistent arguments across calls to stats.

Usage

fit_models_internal(
  data,
  method,
  method.name,
  method.args,
  n.min,
  formula,
  fit.seed,
  orientation,
  level = 0.95,
  accept.rq = TRUE
)

Value

A list with three named members: fm the fitted model object and method.args, the arguments passed to the model fit function as a nested named list, fit.seed the seed used and method.name, the name of the model fit function passed as arguemnt, which can differ from the class of fm.

Arguments

data

A layer specific dataset - only needed if you want to override the plot defaults.

method

function or character If character, "lm", "rlm", "rq" and the name of a function to be matched, possibly followed by the fit function's method argument separated by a colon (e.g. "rq:br"). Functions implementing methods must accept arguments to parameters formula, data, weights and method. A residuals() method must exist for the returned model fit object class.

method.args

named list with additional arguments.

n.min

integer Minimum number of distinct values in the explanatory variable (on the rhs of formula) for fitting to the attempted.

formula

a "formula" object. Using aesthetic names instead of original variable names.

fit.seed

RNG seed argument passed to set.seed(). Defaults to NA, which means that set.seed() will not be called.

orientation

character Either "x" or "y" controlling the default for formula.

accept.rq

logical Accept quantile regression fits with 'quantreg' or warn when encountered.