partial-prediction: Create partial predictions and partial prediction plots.

partial-predictionR Documentation

Create partial predictions and partial prediction plots.

Description

Partial predictions allow you to explore and understand the impact of each of the covariates used in the conmat GAM model. See 'Details' for more information.

Usage

partial_effects(model, ages, ...)

## S3 method for class 'contact_model'
partial_effects(model, ages, ...)

## S3 method for class 'setting_contact_model'
partial_effects(model, ages, ...)

## S3 method for class 'setting_contact_model'
partial_effects_sum(model, ages, ...)

Arguments

model

A fitted contact model, with class contact_model (from fit_single_model(), or a simple element from list output of fit_setting_contacts()), e.g. polymod_setting_models$home. Or, class setting_contact_model - a list of fitted contact models (from fit_setting_contacts())), e.g. polymod_setting_models.

ages

vector of integer ages.

...

extra arguments. Currently not used.

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. Essentially, they represent the change in outcome variable on the model scale with a unit change in input variable.

Scales are not comparable across settings, as each setting has it's own intercept term which is not accounted for in partial effects.

Value

data frame with 20 columns plus n rows based on expand.grid combination of ages. Contains transformed coefficients from ages.

Examples

partials_home <- partial_effects(
  polymod_setting_models$home,
  ages = 1:99
  )
autoplot(partials_home)
# partial effects for all settings
partials_setting <- partial_effects(
  polymod_setting_models,
  ages = 1:99
  )
autoplot(partials_setting)

njtierney/conmat documentation built on April 17, 2025, 10:27 p.m.