calculate_coverage: Calculate coverage across predictive draws

Description Usage Arguments Value

Description

Calculate how often observed data falls within X intervals of the posterior predictive draws. The observed data should come in the form of separate numerator and denominator columns, while the estimates should be a single field estimating a rate (i.e. already normalized by denominator)

Usage

1
2
3
4
5
6
7
8
9
calculate_coverage(
  in_data,
  num_field,
  denom_field,
  draw_fields,
  coverage_levels = c(0.5, 0.8, 0.95),
  group_fields = NULL,
  pois_sim = TRUE
)

Arguments

in_data

Input data.table

num_field

Numerator field for the observed data

denom_field

Denominator field for the observed data

draw_fields

Character vector of fields containing predictive draws, in rate space (e.g. mortality rates)

coverage_levels

[optional, default c(.5, .8, .95)] Uncertainty intervals to calculate from the posterior predictive draws

group_fields

[optional, default NULL] If the predictive validity metrics should be grouped, list the fields to group them by here. If NULL (the default), the predictive validity metrics will be calculated across the entire dataset

pois_sim

[optional, default TRUE] Should the coverage be estimated using realizations Poisson distribution centered at population * rate (as opposed to the central value, population * p)?

Value

Data.table containing the following fields: - 'covg<X>': Empirical coverage for the X - Any grouping columns specified in the function arguments


njhenry/covidemr documentation built on Feb. 2, 2022, 2:31 a.m.