| plot_1d_smooth {stgam} | R Documentation | 
Plots a 1-Dimensional GAM smooth
Description
Plots a 1-Dimensional GAM smooth
Usage
plot_1d_smooth(mod, ncol = NULL, nrow = NULL, fills = "lightblue")
Arguments
| mod | a GAM model with smooths created using the mgcv package | 
| ncol | the number of columns for the compound plot | 
| nrow | the number of rows for the compound plot | 
| fills | the fill colours (single or vector) | 
Value
A compound plot of the GAM 1-dimensioanl smooths (rendered using cowplot::plot_grid).
Examples
library(mgcv)
library(ggplot2)
library(dplyr)
library(cowplot)
# 1. from the `mgcv` `gam` function help
set.seed(2) ## simulate some data...
dat <- gamSim(1,n=400,dist="normal",scale=2)
b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
plot_1d_smooth(b, ncol = 2, fills = c("lightblue", "lightblue3"))
dev.off()
# 2. using a TVC
data(productivity)
data = productivity |> mutate(Intercept = 1)
gam.tvc.mod = gam(privC ~ 0 + Intercept +
                  s(year, bs = 'gp', by = Intercept) +
                  unemp + s(year, bs = "gp", by = unemp) +
                  pubC + s(year, bs = "gp", by = pubC),
                  data = data)
plot_1d_smooth(gam.tvc.mod, fills = "lightblue")
[Package stgam version 0.0.1.1 Index]