# \dontshow{
op <- options(pillar.sigfig = 3)
# }
load_mgcv()
df <- data_sim("eg1", n = 400, seed = 42)
m <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df, method = "REML")
# add fitted samples (posterior draws of the expected value of the response)
# note that there are 800 rows in the output: 400 data by `n = 2` samples.
df |>
add_fitted_samples(m, n = 2, seed = 84)
# add posterior draws from smooth s(x2)
df |>
add_smooth_samples(m, n = 2, seed = 2, select= "s(x2)")
# \dontshow{
options(op)
# }
Run the code above in your browser using DataLab