Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

stat_plsmo

Add a lowess smoother without counfidence bands.


Description

Automatically selects iter=0 for lowess if y is binary, otherwise uses iter=3.

Usage

stat_plsmo(
  mapping = NULL,
  data = NULL,
  geom = "smooth",
  position = "identity",
  n = 80,
  fullrange = FALSE,
  span = 2/3,
  fun = function(x) x,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  ...
)

Arguments

mapping, data, geom, position, show.legend, inherit.aes

see ggplot2 documentation

n

number of points to evaluate smoother at

fullrange

should the fit span the full range of the plot, or just the data

span

see f argument to lowess

fun

a function to transform smoothed y

na.rm

If FALSE (the default), removes missing values with a warning. If TRUE silently removes missing values.

...

other arguments are passed to smoothing function

Value

a data.frame with additional columns

y

predicted value

See Also

lowess for loess smoother.

Examples

c <- ggplot(mtcars, aes(qsec, wt))
c + stat_plsmo()
c + stat_plsmo() + geom_point()

c + stat_plsmo(span = 0.1) + geom_point()

# Smoothers for subsets
c <- ggplot(mtcars, aes(y=wt, x=mpg)) + facet_grid(. ~ cyl)
c + stat_plsmo() + geom_point()
c + stat_plsmo(fullrange = TRUE) + geom_point()

# Geoms and stats are automatically split by aesthetics that are factors
c <- ggplot(mtcars, aes(y=wt, x=mpg, colour=factor(cyl)))
c + stat_plsmo() + geom_point()
c + stat_plsmo(aes(fill = factor(cyl))) + geom_point()
c + stat_plsmo(fullrange=TRUE) + geom_point()

# Example with logistic regression
data("kyphosis", package="rpart")
qplot(Age, as.numeric(Kyphosis) - 1, data = kyphosis) + stat_plsmo()

Hmisc

Harrell Miscellaneous

v4.5-0
GPL (>= 2)
Authors
Frank E Harrell Jr <fh@fharrell.com>, with contributions from Charles Dupont and many others.
Initial release
2021-02-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.