draw.evaluated_smooth: Plot estimated smooths

Description Usage Arguments Value Author(s) Examples

Description

Plots estimated univariate and bivariate smooths using ggplot2.

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'evaluated_1d_smooth'
draw(object, xlab, ylab, title = NULL,
  subtitle = NULL, caption = NULL, ...)

## S3 method for class 'evaluated_2d_smooth'
draw(object, show = c("estimate", "se"),
  contour = TRUE, xlab, ylab, title = NULL, subtitle = NULL,
  caption = NULL, ...)

Arguments

object

an object, the result of a call to evaluate_smooth().

xlab

character or expression; the label for the x axis. If not supplied, a suitable label will be generated from object.

ylab

character or expression; the label for the y axis. If not supplied, a suitable label will be generated from object.

title

character or expression; the title for the plot. See ggplot2::labs().

subtitle

character or expression; the subtitle for the plot. See ggplot2::labs().

caption

character or expression; the plot caption. See ggplot2::labs().

...

arguments passed to other methods.

show

character; plot the estimated smooth ("estimate") or its standard error ("se").

contour

logical; should contours be draw on the plot using ggplot2::geom_contour().

Value

A ggplot2::ggplot() object.

Author(s)

Gavin L. Simpson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library("mgcv")

set.seed(2)
dat <- gamSim(1, n = 400, dist = "normal", scale = 2)
m1 <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat, method = "REML")

sm <- evaluate_smooth(m1, "s(x2)")
draw(sm)

set.seed(2)
dat <- gamSim(2, n = 4000, dist = "normal", scale = 1)
m2 <- gam(y ~ s(x, z, k = 40), data = dat$data, method = "REML")

sm <- evaluate_smooth(m2, "s(x,z)", n = 100)
draw(sm)

## now the standard error the smooth instead
draw(sm, show = "se")

gavinsimpson/tsgam documentation built on May 16, 2019, 10:11 p.m.