ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_quant_band()
# If you need the fitting to be done along the y-axis set the orientation
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_quant_band(orientation = "y")
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_quant_band(formula = y ~ x)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_quant_band(formula = x ~ y)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_quant_band(formula = y ~ poly(x, 3))
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_quant_band(formula = x ~ poly(y, 3))
# Instead of rq() we can use rqss() to fit an additive model:
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_quant_band(method = "rqss",
formula = y ~ qss(x))
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_quant_band(method = "rqss",
formula = x ~ qss(y, constraint = "D"))
# Regressions are automatically fit to each group (defined by categorical
# aesthetics or the group aesthetic) and for each facet.
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point() +
stat_quant_band(formula = y ~ x)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_quant_band(formula = y ~ poly(x, 2)) +
facet_wrap(~drv)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
stat_quant_band(linetype = "dashed", color = "darkred", fill = "red")
ggplot(mpg, aes(displ, hwy)) +
stat_quant_band(color = NA, alpha = 1) +
geom_point()
ggplot(mpg, aes(displ, hwy)) +
stat_quant_band(quantiles = c(0, 0.1, 0.2)) +
geom_point()
# Inspecting the returned data using geom_debug()
gginnards.installed <- requireNamespace("gginnards", quietly = TRUE)
if (gginnards.installed)
library(gginnards)
if (gginnards.installed)
ggplot(mpg, aes(displ, hwy)) +
stat_quant_band(geom = "debug")
if (gginnards.installed)
ggplot(mpg, aes(displ, hwy)) +
stat_quant_band(geom = "debug", fm.values = TRUE)
Run the code above in your browser using DataLab