This statistic is similar to stat_smooth
but has
different defaults. It interprets the argument passed to formula
differently, accepting y
as explanatory variable and setting
orientation
automatically. The default for method
is
"lm"
and spline-based smoothers like loess
are not supported.
Other defaults are consistent with those in stat_poly_eq()
,
stat_quant_line()
, stat_quant_eq()
, stat_ma_line()
,
stat_ma_eq()
.
geom_poly_line()
treats the x and y aesthetics differently and can
thus have two orientations. The orientation can be deduced from the argument
passed to formula
. Thus, stat_poly_line()
will by default guess
which orientation the layer should have. If no argument is passed to
formula
, the formula defaults to y ~ x
. For consistency with
stat_smooth
orientation can be also specified directly
passing an argument to the orientation
parameter, which can be either
"x"
or "y"
. The value of orientation
gives the axis that
is taken as the explanatory variable or x
in the model formula.
Package 'ggpmisc' does not define new geometries matching the new statistics
as they are not needed and conceptually transformations of data
are
statistics in the grammar of graphics.
A ggplot statistic receives as data
a data frame that is not the one
passed as argument by the user, but instead a data frame with the variables
mapped to aesthetics. stat_poly_eq()
mimics how stat_smooth()
works, except that only polynomials can be fitted. Similarly to these
statistics the model fits respect grouping, so the scales used for x
and y
should both be continuous scales rather than discrete.
With method "lm"
, singularity results in terms being dropped with a
message if more numerous than can be fitted with a singular (exact) fit.
In this case and if the model results in a perfect fit due to low
number of observation, estimates for various parameters are NaN
or
NA
.
With methods other than "lm"
, the model fit functions simply fail
in case of singularity, e.g., singular fits are not implemented in
"rlm"
.
In both cases the minimum number of observations with distinct values in
the explanatory variable can be set through parameter n.min
. The
default n.min = 2L
is the smallest suitable for method "lm"
but too small for method "rlm"
for which n.min = 3L
is
needed. Anyway, model fits with very few observations are of little
interest and using larger values of n.min
than the default is
wise.