load_mgcv()
op <- options(cli.unicode = FALSE, pillar.sigfig = 3)
dat <- data_sim("eg1", n = 400, seed = 2)
m1 <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat, method = "REML")
sms <- smooth_samples(m1, term = "s(x0)", n = 5, seed = 42)
# \donttest{
sms
# }
## A factor by example (with a spurious covariate x0)
dat <- data_sim("eg4", n = 1000, seed = 2)
## fit model...
m2 <- gam(y ~ fac + s(x2, by = fac) + s(x0), data = dat)
sms <- smooth_samples(m2, n = 5, seed = 42)
draw(sms)
options(op)
Run the code above in your browser using DataLab