Given a gam model this convenience function returns a plot of its univariate smooth terms. If terms is not specified, all univariate smooths are plotted; otherwise only the requested ones (see get_terms for how terms are matched). Different smooths are faceted. Smooths that are indexed by a factor – a factor by-variable or a factor-smooth interaction (bs = "fs"/"sz") – are drawn in a single facet with one coloured/filled curve per factor level.

gg_smooth(x, ...)

# Default S3 method
gg_smooth(x, fit, ...)

Arguments

x

A data frame or object of class ped.

...

Further arguments passed to get_terms (e.g. terms).

fit

A model object.

Value

A ggplot object.

See also

get_terms

Examples

g1 <- mgcv::gam(Sepal.Length ~ s(Sepal.Width) + s(Petal.Length), data=iris)
gg_smooth(iris, g1, terms=c("Sepal.Width", "Petal.Length"))

# all univariate smooths (terms omitted)
gg_smooth(iris, g1)

# factor-by smooth: one coloured curve per Species
g2 <- mgcv::gam(Sepal.Length ~ s(Sepal.Width, by = Species), data = iris)
gg_smooth(iris, g2, terms = "Sepal.Width")