Skip to contents

Calculates diagnostic likelihood ratios for categorical diagnostic results and binary outcomes. A likelihood ratio is the probability of a result among outcome-positive participants divided by its probability among outcome-negative participants; this is a diagnostic accuracy measure, not a nested-model test.

Usage

DiagnosticLikelihoodRatioTable(
  data,
  outcome_vars,
  predictor_vars,
  positive_level = NULL,
  predictor_positive_level = NULL,
  stratify_by = NULL,
  confidence_level = 0.95,
  continuity_correction = NULL,
  Relabel = TRUE
)

Arguments

data

A data frame.

outcome_vars

Character vector of binary outcome variable names.

predictor_vars

Character vector of categorical or binary diagnostic predictor names.

positive_level

Optional outcome-positive level specification: NULL, one level for all outcomes, or a named vector keyed by outcome variable.

predictor_positive_level

Optional positive-result specification for binary predictors: NULL, one level for all predictors, or a named vector.

stratify_by

Optional character vector of variables defining strata.

confidence_level

Confidence level for log-scale LR confidence intervals.

continuity_correction

Optional positive value added to all four calculation cells only if a zero cell occurs. NULL preserves zero and infinite estimates.

Relabel

Logical; use attached variable labels when available.

Value

A list containing Results, BinarySummary, compact and expanded gt tables (FormattedTable, LargeTable, BinaryFormattedTable, and BinaryLargeTable), and Metadata.

Details

Binary predictors produce sensitivity, specificity, LR+, and LR-. Predictors with more than two levels return one likelihood ratio for each result level. Numeric predictors with more than two observed values must be categorized first.

See also

PlotDiagnosticLRHeatmap() for matrix views and PlotDiagnosticLRForest() for estimate-and-interval views.

Examples

data(SampleData)
data(SampleVariableTypes)
df_Labelled <- RevalueData(SampleData, SampleVariableTypes)$RevaluedData
df_Labelled$DiagnosisBinary <- factor(df_Labelled$Diagnosis,
  levels = c("Control", "Impaired"))
lr <- DiagnosticLikelihoodRatioTable(df_Labelled, "DiagnosisBinary",
  c("sex", "Genotype"))
#> DiagnosisBinary: 'Impaired' treated as outcome-positive.
lr$FormattedTable
Diagnostic likelihood ratios
Stratum Outcome Diagnostic result N Case % Control % Likelihood ratio (95% CI)
All participants DiagnosisBinary Sex: Female 333 51.6 64.9 0.796 (0.639, 0.991)
All participants DiagnosisBinary Sex: Male 333 48.4 35.1 1.38 (1.05, 1.81)
All participants DiagnosisBinary Genotype: E2E2 333 0.0 0.8 0
All participants DiagnosisBinary Genotype: E2E3 333 7.7 12.4 0.621 (0.283, 1.36)
All participants DiagnosisBinary Genotype: E2E4 333 1.1 2.9 0.38 (0.0474, 3.05)
All participants DiagnosisBinary Genotype: E3E3 333 37.4 55.0 0.68 (0.509, 0.908)
All participants DiagnosisBinary Genotype: E3E4 333 45.1 26.9 1.68 (1.23, 2.28)
All participants DiagnosisBinary Genotype: E4E4 333 8.8 2.1 4.25 (1.43, 12.7)
PlotDiagnosticLRHeatmap(lr) #> $DiagnosticLR #> #> $DiagnosticMatrices #> #> $DiagnosticLRData #> # A tibble: 8 × 30 #> Outcome OutcomeLabel OutcomePositiveLevel Predictor PredictorLabel #> <chr> <chr> <chr> <chr> <chr> #> 1 DiagnosisBinary DiagnosisBinary Impaired sex Sex #> 2 DiagnosisBinary DiagnosisBinary Impaired sex Sex #> 3 DiagnosisBinary DiagnosisBinary Impaired Genotype Genotype #> 4 DiagnosisBinary DiagnosisBinary Impaired Genotype Genotype #> 5 DiagnosisBinary DiagnosisBinary Impaired Genotype Genotype #> 6 DiagnosisBinary DiagnosisBinary Impaired Genotype Genotype #> 7 DiagnosisBinary DiagnosisBinary Impaired Genotype Genotype #> 8 DiagnosisBinary DiagnosisBinary Impaired Genotype Genotype #> # ℹ 25 more variables: PredictorLevels <int>, ResultLevel <chr>, Stratum <chr>, #> # N <int>, NCase <int>, NControl <int>, CaseWithResult <int>, #> # ControlWithResult <int>, CaseWithoutResult <int>, #> # ControlWithoutResult <int>, CaseProbability <dbl>, #> # ControlProbability <dbl>, LikelihoodRatio <dbl>, LRLowerCI <dbl>, #> # LRUpperCI <dbl>, Log2LR <dbl>, ZeroCell <lgl>, Corrected <lgl>, #> # RowId <chr>, RowLabel <chr>, .OriginalOrder <int>, CIExcludesOne <lgl>, … #> #> $DiagnosticMatrixData #> # A tibble: 16 × 14 #> Stratum Predictor PredictorLabel Outcome OutcomeLabel ResultLevel #> <chr> <chr> <chr> <chr> <chr> <chr> #> 1 All participants sex Sex Diagnosis… DiagnosisBi… Female #> 2 All participants sex Sex Diagnosis… DiagnosisBi… Male #> 3 All participants Genotype Genotype Diagnosis… DiagnosisBi… E2E2 #> 4 All participants Genotype Genotype Diagnosis… DiagnosisBi… E2E3 #> 5 All participants Genotype Genotype Diagnosis… DiagnosisBi… E2E4 #> 6 All participants Genotype Genotype Diagnosis… DiagnosisBi… E3E3 #> 7 All participants Genotype Genotype Diagnosis… DiagnosisBi… E3E4 #> 8 All participants Genotype Genotype Diagnosis… DiagnosisBi… E4E4 #> 9 All participants sex Sex Diagnosis… DiagnosisBi… Female #> 10 All participants sex Sex Diagnosis… DiagnosisBi… Male #> 11 All participants Genotype Genotype Diagnosis… DiagnosisBi… E2E2 #> 12 All participants Genotype Genotype Diagnosis… DiagnosisBi… E2E3 #> 13 All participants Genotype Genotype Diagnosis… DiagnosisBi… E2E4 #> 14 All participants Genotype Genotype Diagnosis… DiagnosisBi… E3E3 #> 15 All participants Genotype Genotype Diagnosis… DiagnosisBi… E3E4 #> 16 All participants Genotype Genotype Diagnosis… DiagnosisBi… E4E4 #> # ℹ 8 more variables: OutcomeCondition <chr>, Count <int>, Denominator <int>, #> # Probability <dbl>, CellLabel <chr>, MatrixRow <chr>, MatrixRowLabel <chr>, #> # HoverText <chr> #>