Create partial predictive plots for a set of fitted models.
Source:R/partial-prediction-helpers.R
partial-prediction-sum.RdThese helper functions exist to make it easier to explore and understand the impact of each of the covariates used in the conmat GAM model.
Usage
partial_effects_sum(model, ages, ...)
# S3 method for class 'contact_model'
partial_effects_sum(model, ages, ...)Value
data frame with 3 columns plus n rows based on expand.grid
combination of ages. The column gam_total_term is the sum over
the coefficients for that age bracket.
Details
Partial predictive plots give a visual representation of the effect of each covariate on the model, or (equivalently) the effect of each setting on the total contact matrix. Positive values indicate more contacts in that region of the matrix compared to the null case, while negative values indicate less.
Scales are not comparable across settings, as each setting has it's own intercept term, which is not accounted for in partial effects.
Examples
# Summed up partial effects (y-hat) for a single setting
partials_summed_home <- partial_effects_sum(
polymod_setting_models$home,
ages = 1:99
)
autoplot(partials_summed_home)
# summed up partial effects (y-hat) for all settings
partials_summed_setting <- partial_effects_sum(
polymod_setting_models,
ages = 1:99
)
autoplot(partials_summed_setting)