Skip to contents

Usage

firthregression(
  data,
  analysisType = "logistic",
  time,
  outcome,
  outcomeLevel,
  predictors,
  suitabilityCheck = TRUE,
  ciLevel = 0.95,
  ciMethod = "profile",
  separationCheck = TRUE,
  compareStandard = TRUE,
  showModelFit = TRUE,
  forestPlot = TRUE,
  separationPlot = FALSE,
  showSummary = FALSE,
  showExplanations = FALSE
)

Arguments

data

The data as a data frame.

analysisType

Type of regression model. Logistic uses logistf package for binary outcomes with Jeffreys-prior bias reduction. Cox uses coxphf package for survival outcomes with Firth-type penalized partial likelihood.

time

Time to event variable (numeric). Required only for Cox regression. For right-censored data, this is the time from study entry to event or censoring.

outcome

Outcome variable. For logistic regression, a binary variable. For Cox regression, the event indicator (0 = censored, 1 = event).

outcomeLevel

Level of the outcome variable to be treated as the event of interest.

predictors

Variables to include in the model. Can include continuous, ordinal, and nominal variables.

suitabilityCheck

Assess if data is suitable for the selected Firth regression model.

ciLevel

Confidence level for confidence intervals. Default is 0.95 for 95\

ciMethodMethod for computing confidence intervals. Profile likelihood CIs are recommended as they are more accurate, especially with small samples and near separation. Wald CIs are faster but can be unreliable in these situations.

separationCheckCheck for complete and quasi-complete separation in the data. Separation causes standard maximum likelihood to fail with infinite coefficient estimates.

compareStandardFit the standard (unpenalized) model alongside Firth's penalized model to show bias reduction. Useful for assessing how much the penalty changes the estimates.

showModelFitDisplay model fit statistics including log-likelihood and AIC.

forestPlotForest plot showing odds ratios (logistic) or hazard ratios (Cox) with confidence intervals on a log scale.

separationPlotDiagnostic visualization showing data distributions by outcome for each predictor. Helps identify separation patterns.

showSummaryNatural-language summary of results.

showExplanationsExplanatory text about Firth's method and when to use it.

A results object containing:

results$instructionsa html
results$noticesa html
results$suitabilityReporta html
results$coefficientsa table
results$modelFita table
results$separationDiagnosticsa table
results$comparisonTablea table
results$forestPlotImagean image
results$separationPlotImagean image
results$summaryTexta html
results$explanationTexta html
Tables can be converted to data frames with asDF or as.data.frame. For example:results$coefficients$asDFas.data.frame(results$coefficients) Firth's penalized likelihood regression for both logistic (binary outcome) and Cox proportional hazards (survival) models. Addresses small-sample bias, complete/quasi-complete separation, and rare events by adding a Jeffreys-prior penalty to the likelihood. Provides profile likelihood confidence intervals, penalized likelihood ratio tests, and separation diagnostics. Particularly valuable in clinical settings with low event counts, unbalanced predictors, or when standard maximum likelihood estimates become infinite due to separation.