Description Usage Arguments Examples
Takes a GAM and outputs a list, containing data for each smoothed variable's contribution.
1 | gam.contribution(gam.object)
|
gam.object |
GAM object. A GAM saved to a variable. |
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.