check_grain: Determine the grain of each resistance outcome in timber and...

View source: R/check_grain.R

check_grainR Documentation

Determine the grain of each resistance outcome in timber and validate the grains' fields

Description

The check_grain() function checks that a resistance outcome format is specified, determines its grain and calls functions to validate the grains' fields. See details for more information.

Usage

check_grain(timber)

Arguments

timber

A tibble of timber.

Details

The odds ratio (and its confidence intervals) are the universal measure of CEDAR and sawmill. A resistance outcome may be specified using the odds ratio directly, or by using a two-by-two table of counts or prevalences. sawmill supports four resistance outcome formats:

  • Contingency table

  • Prevalence table

  • Odds ratio

  • Risk ratio

Resistance Outcome Formats

There are two types of two-by-two tables supported by sawmill: contingency tables (containing count data), and prevalence tables (containing prevalence (

Contingency Table

AMR+ AMR- Total
Exposed A B M1
Referent C D M2

Prevalence Table

AMR+ AMR- Total
Exposed P% R% M1
Referent Q% S% M2

There are two types of measures of association supported by sawmill: odds ratios and risk ratios.

Odds Ratio

Lower CI Odds Ratio Upper CI
odds_lo odds odds_up

Risk Ratio

Lower CI Risk Ratio Upper CI
rratio_lo rratio rratio_up

Supported Grains

A 'grain' is a set of fields from which we can derive an odds ratio and its confidence intervals. For tabular data, supported grains are a set of fields from which we can first compute a complete table of counts (A, B, C, D), then compute an odds ratio and its confidence intervals.

There are currently seven supported grains:

  • con_table_pos_neg: A, B, C, D

  • con_table_pos_tot: A, C, M1, M2

  • con_table_neg_tot: A, C, M1, M2

  • prev_table_pos_tot: P, Q, M1, M2

  • prev_table_neg_tot: R, S, M1, M2

  • odds_ratio: odds_ratio_lo, odds_ratio, odds_ratio_up

  • risk_ratio: risk_ratio_lo, risk_ratio, risk_ratio_up

Unsupported Grains

An 'unsupported grain' is a set of fields from which we cannot derive an odds ratio and it's confidence intervals. These include grains where any requisite fields are NA.

The following grains are explicitly unsupported:

  • prev_table_pos_neg: P, Q, R, S

sawmill fields

TODO: Link to documentation on sawmill fields.

Value

A tibble of timber with sawmill status fields and additional field grain. Where checks fail, grain is NA.


iAM-AMR/sawmill documentation built on June 30, 2024, 2:25 a.m.