gam.contribution: Outputs the contribution of each smoothed independent...

Description Usage Arguments Examples

View source: R/gam.contribution.R

Description

Takes a GAM and outputs a list, containing data for each smoothed variable's contribution.

Usage

1
gam.contribution(gam.object)

Arguments

gam.object

GAM object. A GAM saved to a variable.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(data.table)
library(mgcv)
library(ggplot2)

mtcars <- data.table(mtcars)

set.seed(123)
mtcars[, curve := (1 / (1 + exp(-(mpg - mean(mpg))))) + rnorm(n = .N, mean = 0, sd = 0.1)]

ggplot(mtcars, aes(x = curve, y = mpg)) +
  geom_point()

m1 <- lm(formula = mpg ~ wt + hp + gear + curve, data = mtcars)

m2 <- gam(formula = mpg ~ s(wt) + s(hp) + gear, data = mtcars)

m3 <- gam(formula = mpg ~ s(wt) + s(hp) + gear + s(curve, k = 3), data = mtcars)

summary(m3)

anova(m1, m2, m3, test = "Chi")

nladwa::gam.contribution.ggplot(m2)
nladwa::gam.contribution.ggplot(m3)

Braja93/braja documentation built on June 1, 2017, 5:19 p.m.