Skip to contents

Usage

continuousrelationship(
  data,
  outcome,
  predictor,
  covariates = NULL,
  modelType = "spline",
  nKnots = "4",
  knotPositions = "quantile",
  plotType = "doseresponse",
  referenceValue,
  showCI = TRUE,
  showRug = TRUE,
  showGuidance = TRUE,
  compareWithLinear = TRUE,
  showCategorizedPitfall = FALSE,
  testLinearity = TRUE,
  showModelFit = TRUE,
  showModel = FALSE
)

Arguments

data

The dataset containing clinical variables

outcome

The outcome/dependent variable (can be continuous or binary)

predictor

The continuous predictor variable to analyze

covariates

Variables to adjust for in the analysis

modelType

Statistical approach for modeling the relationship. Splines are recommended for most clinical applications.

nKnots

Number of knots for spline models. More knots = more flexibility

knotPositions

How to position knots across the predictor range

plotType

Type of visualization to create

referenceValue

Reference value for the predictor (e.g., BMI=25). If not specified, uses median value.

showCI

Display 95\

showRugShow rug plot of actual data points

showGuidanceDisplay educational guidance based on BMJ best practices to help interpret results and avoid common mistakes

compareWithLinearShow comparison with simple linear model to demonstrate the importance of flexible modeling

showCategorizedPitfallEducational: Show what happens when continuous variables are inappropriately categorized (with warning)

testLinearityPerform statistical test for non-linear relationship

showModelFitDisplay AIC, BIC, and other fit statistics

showModelDisplay the model formula as HTML in the results

A results object containing:

results$guidancea html
results$warningMessagea html
results$modelFormulaa html
results$linearityTesta table
results$modelFita table
results$doseResponsePlotan image
results$partialEffectPlotan image
results$comparisonPlotan image
results$categorizedPlotan image
results$interpretationGuidea preformatted
Tables can be converted to data frames with asDF or as.data.frame. For example:results$linearityTest$asDFas.data.frame(results$linearityTest) Analyzes relationships between continuous variables in clinical research using evidence-based approaches from BMJ best practices. Avoids common pitfalls like arbitrary categorization and linear assumptions. # Example: Analyzing BMI vs mortality risk continuousrelationship( data = clinical_data, outcome = "mortality", predictor = "bmi", modelType = "spline", nKnots = 4, showGuidance = TRUE )