Skip to contents

S3 generic for computing proportions from fitted models

Usage

proportion(
  fitted_model,
  numerator_combination = NULL,
  denominator_combination = NULL,
  ...
)

# S3 method for class 'ps'
proportion(
  fitted_model,
  numerator_combination = NULL,
  denominator_combination = NULL,
  ...
)

# S3 method for class 'rw'
proportion(
  fitted_model,
  numerator_combination = NULL,
  denominator_combination = NULL,
  ...
)

Arguments

fitted_model

Fitted model object with class `EpiStrainDynamics.fit` with `multiple` or `subtyped` pathogen structure.

numerator_combination

Named pathogens or subtypes to be included in proportion numerator.

denominator_combination

Named pathogens or subtypes to be included in proportion denominator, or 'all'.

...

Additional arguments passed to metrics calculation

Value

named list of class `EpiStrainDynamics.metric` containing a dataframe of the calculated metric outcome (`$measure`), the fit object (`$fit`), and the constructed model object (`$constructed_model`). The `measure` data frame contains the median of the epidemiological quantity (`y`), the 50 interval of the quantity (`lb_50` & `ub_50`), the 95 (`lb_95` & `ub_95`), the proportion greater than a defined threshold value (`prop`), the pathogen name (`pathogen`), and the time label (`time`).

Examples

if (FALSE) { # \dontrun{
  mod <- construct_model(
    method = p_spline(),
    pathogen_structure = multiple(
      case_timeseries = sarscov2$cases,
      time = sarscov2$date,
      component_pathogen_timeseries = list(
        alpha = sarscov2$alpha,
        delta = sarscov2$delta,
        omicron = sarscov2$omicron,
        other = sarscov2$other))
  )

  fit <- fit_model(mod)
  prop <- proportion(fit)

  # or a unique combination, compared to all pathogens
  prop2 <- proportion(fit,
    numerator_combination = c('alpha', 'delta', 'omicron'),
    denominator_combination = 'all'
  )

  # or a user-specified combination in both numerator and denominator
  prop3 <- proportion(fit,
    numerator_combination = 'alpha',
    denominator_combination = c('alpha', 'delta', 'omicron')
  )
} # }