# attitude dataset
attitude
## ALE for general additive models (GAM)
## GAM is tweaked to work on the small dataset.
gam_attitude <- mgcv::gam(rating ~ complaints + privileges + s(learning) +
raises + s(critical) + advance,
data = attitude)
summary(gam_attitude)
# \donttest{
# Full model bootstrapping
# Only 4 bootstrap iterations for a rapid example; default is 100
# Increase value of boot_it for more realistic results
mb_gam <- model_bootstrap(
attitude,
gam_attitude,
boot_it = 4,
parallel = 2 # CRAN limit (delete this line on your own computer)
)
# If the model is not standard, supply model_call_string with
# 'data = boot_data' in the string (not as a direct argument to [model_bootstrap()])
mb_gam <- model_bootstrap(
attitude,
gam_attitude,
model_call_string = 'mgcv::gam(
rating ~ complaints + privileges + s(learning) +
raises + s(critical) + advance,
data = boot_data
)',
boot_it = 4,
parallel = 2 # CRAN limit (delete this line on your own computer)
)
# Model statistics and coefficients
mb_gam$model_stats
mb_gam$model_coefs
# Plot ALE
mb_gam$ale$plots |>
patchwork::wrap_plots()
# }
Run the code above in your browser using DataLab