geom_smooth_ci: Smooths and confidence intervals.

View source: R/plotting.R

geom_smooth_ciR Documentation

Smooths and confidence intervals.

Description

[Superseded]

This function is from the superseded package tidymv. Please, use the tidygam package instead.

It provides a geom for plotting GAM smooths with confidence intervals from the output of predict_gam. It inherits the following aesthetics from a call to ggplot:

  • The term defining the x-axis.

  • The fitted values (the fit column in the tibble returned by predict_gam).

  • The standard error of the fit (the se.fit column in the tibble returned by predict_gam).

Usage

geom_smooth_ci(group = NULL, ci_z = 1.96, ci_alpha = 0.1, data = NULL, ...)

Arguments

group

The optional grouping factor.

ci_z

The z-value for calculating the CIs (the default is 1.96 for 95 percent CI).

ci_alpha

Transparency value of CIs (the default is 0.1).

data

The data to be displayed in this layer. If NULL, it is inherited.

...

Arguments passed to geom_path().

Examples

library(mgcv)
library(ggplot2)
set.seed(10)
data <- gamSim(4)
model <- gam(y ~ fac + s(x2) + s(x2, by = fac), data = data)

# get predictions
p <- predict_gam(model)

# plot smooths and confidence intervals
ggplot(p, aes(x2, fit)) + geom_smooth_ci(fac)


tidymv documentation built on May 31, 2023, 8:14 p.m.