ggGam: Draw a ggplot with an object of class gam

Description Usage Arguments Examples

View source: R/ggGam.R

Description

Draw a ggplot with an object of class gam

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
ggGam(
  model,
  select = NULL,
  point = TRUE,
  se = TRUE,
  by = NULL,
  scales = "free_x",
  type = NULL,
  byauto = FALSE,
  facet = FALSE,
  fillcolor = "red",
  pointalpha = 0.3,
  fillalpha = 0.3
)

Arguments

model

An object of class gam

select

numeric Choices of dependent variables to plot

point

logical Whether or not draw point

se

logical Whether or not draw confidence interval

by

NULL or character optional name of factor variable

scales

Should scales be fixed ("fixed"), free ("free"), or free in one dimension ("free_x", "free_y")?

type

character type argument to be passed to predict.gam

byauto

logical Whether or not choose variabels to facet automatically

facet

logical Whether or not make facetted plot

fillcolor

Character Name of fillcolor

pointalpha, fillalpha

Numeric alpha value

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
25
26
27
28
29
30
31
32
require(mgcv)
model <- gam(mpg ~ s(wt), data = mtcars, method = "REML")
plot(model,shift=coef(model)[1],pages=1,all.terms=TRUE,shade=TRUE,seWithMean=TRUE,residuals=TRUE)
ggGam(model)
mtcars$am=factor(mtcars$am,labels=c("automatic","manual"))
model <- gam(mpg ~ s(wt)+am, data = mtcars, method = "REML")
plot(model,shift=coef(model)[1],pages=1,all.terms=TRUE,shade=TRUE,seWithMean=TRUE,residuals=TRUE)
ggGam(model)
ggGam(model,by=am)
ggGam(model,by=am,facet=TRUE)
model <- gam(mpg ~ s(wt,by=am)+ am, data = mtcars, method = "REML")
plot(model,shift=coef(model)[1],pages=1,all.terms=TRUE,shade=TRUE,seWithMean=TRUE,residuals=TRUE)
ggGam(model)
ggGam(model,by=am)
ggGam(model,by=am,facet=TRUE)
ggGam(model,by=am,point=FALSE)
ggGamCat(model)
data(mpg,package="gamair")
model <- gam(hw.mpg ~ s(weight, fuel, bs = "fs"),data = mpg,method = "REML")
ggGam(model)
ggGam(model,by=fuel)
ggGam(model,by=fuel,facet=TRUE)
model2 <- gam(hw.mpg ~ s(weight) + s(length) + s(price) + fuel + drive + style,
   data=mpg, method="REML")
plot(model2,shift=coef(model)[1],pages=1,all.terms=TRUE,shade=TRUE,seWithMean=TRUE,residuals=TRUE)
ggGam(model2,se=TRUE)
ggGam(model2,se=TRUE,by=fuel)
ggGam(model2,se=TRUE,by=fuel,select=1)
ggGam(model2,se=FALSE,by=style)
ggGam(model2,se=FALSE,by=drive,point=FALSE)
model6 <- gam(hw.mpg ~ s(weight, by=fuel), data=mpg, method="REML")
ggGam(model6)

cardiomoon/ggGam documentation built on May 2, 2020, 9:58 a.m.