Function for Odds Ratio Table and Plot.
Usage
oddsratio(
data,
explanatory,
outcome,
outcomeLevel,
diagnosticPredictor = NULL,
predictorLevel,
usePenalized = FALSE,
showNomogram = FALSE,
showExplanations = FALSE
)Arguments
- data
The data as a data frame.
- explanatory
The explanatory variables to be used in the analysis.
- outcome
The outcome variable to be used in the analysis.
- outcomeLevel
Specify which outcome level represents the positive case for likelihood ratio calculations. If not specified, the function will use the second level alphabetically.
- diagnosticPredictor
Specify the predictor to drive likelihood ratios; must be binary. Defaults to the first explanatory variable.
- predictorLevel
Specify which level of the diagnostic predictor represents the positive case.
- usePenalized
Use Firth penalized likelihood logistic regression. This is recommended when there is separation (zero cells), small sample sizes, or low events-per-variable.
- showNomogram
Display an interactive nomogram for converting pre-test to post-test probabilities using likelihood ratios calculated from the data.
- showExplanations
Display educational explanations for each analysis type to help interpret odds ratios, risk ratios, diagnostic test performance, ROC analysis, and likelihood ratios.
Value
A results object containing:
results$todo | a html | ||||
results$text | a html | ||||
results$text2 | a html | ||||
results$plot | an image | ||||
results$oddsRatioExplanation | a html | ||||
results$riskMeasuresExplanation | a html | ||||
results$diagnosticTestExplanation | a html | ||||
results$plot_nomogram | an image | ||||
results$diagnosticMetrics | a html | ||||
results$nomogram | a html | ||||
results$nomogramAnalysisExplanation | a html |
Examples
# Basic odds ratio analysis with binary outcome
library(ClinicoPath)
data('histopathology')
# Example 1: Simple odds ratio analysis
result1 <- oddsratio(
data = histopathology,
explanatory = c("New Test", "Rater 1"),
outcome = "Golden Standart",
outcomeLevel = "1"
)
#> Error in oddsratio(data = histopathology, explanatory = c("New Test", "Rater 1"), outcome = "Golden Standart", outcomeLevel = "1"): argument "predictorLevel" is missing, with no default
# Example 2: Comprehensive analysis with nomogram
result2 <- oddsratio(
data = histopathology,
explanatory = c("New Test", "Rater 1", "Rater 2"),
outcome = "Golden Standart",
outcomeLevel = "1",
showNomogram = TRUE,
showSummaries = TRUE,
showExplanations = TRUE
)
#> Error in oddsratio(data = histopathology, explanatory = c("New Test", "Rater 1", "Rater 2"), outcome = "Golden Standart", outcomeLevel = "1", showNomogram = TRUE, showSummaries = TRUE, showExplanations = TRUE): unused argument (showSummaries = TRUE)
# Example 3: Analysis with continuous and categorical predictors
# Assuming additional variables in dataset
result3 <- oddsratio(
data = clinical_data,
explanatory = c("age", "gender", "treatment"),
outcome = "mortality",
outcomeLevel = "Dead",
showSummaries = TRUE
)
#> Error in oddsratio(data = clinical_data, explanatory = c("age", "gender", "treatment"), outcome = "mortality", outcomeLevel = "Dead", showSummaries = TRUE): unused argument (showSummaries = TRUE)