tidy_smooths: Tidy Data Frame of Smooth Terms

Description Usage Arguments Value Examples

View source: R/tidy_smooths.R

Description

Returns a tidy data frame containing the mean and confidence intervals for fitted smooths from a model of class "gam" from package "mgcv".

Usage

1
tidy_smooths(object, dimension = 1, level = 0.95, parm = NULL)

Arguments

object

a fitted model object of class "gam".

dimension

the dimension of the smooths that are desired for extraction.

level

the confidence level required.

parm

a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered (not yet implemented).

...

not implemented

Value

A tidy data frame containing parameter names, estimates and confidence intervals for non-parametric terms

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
set.seed(101)
library(dplyr)
library(mgcv)
library(mgcv.helper)
dat <- data.frame(x = runif(n=100),
                  y = runif(n=100)) %>%
  dplyr::mutate(z = rnorm(n=100,
                   mean = 1 - 2*x - sin(2*pi*y),
                   sd = 0.1))

fit1 <- gam(data=dat, z ~ y + s(x))

tidy_smooths(fit1, dimension=1)

samclifford/mgcv.helper documentation built on Oct. 10, 2019, 6:05 p.m.