--- title: "Which Function Should I Use?" description: "Match the outcome and the study design to the right gtregression function and effect measure." output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Which Function Should I Use?} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- Start from two questions: **what kind of outcome do you have**, and **how were the observations collected**? The tables below point to the function, the `approach` where one is needed, and the effect measure that appears in the table. Every function shares the same arguments for exposures, adjustment variables, formatting and export. ## Binary outcomes An outcome with two values, such as disease or no disease. | Question | Function | `approach` | Reported as | |---|---|---|---| | Odds of the outcome | `uni_reg()`, `multi_reg()` | `"logit"` | Odds ratio | | Odds with sparse data or separation | `uni_reg()`, `multi_reg()` | `"firth"` | Odds ratio (Firth) | | Risk of the outcome, relative | `uni_reg()`, `multi_reg()` | `"logbinomial"` or `"robpoisson"` | Risk ratio | | Risk of the outcome, absolute (two groups) | `risk_difference()` | none | Risk difference, NNTB/NNTH | | Matched case-control sets | `conditional_logit_reg()` | none | Matched odds ratio | | Clustered observations (clinics, schools) | `multilevel_reg()` | `"logit"` | Odds ratio, random intercept | `"robpoisson"` (Poisson with robust standard errors) is a dependable alternative when a log-binomial model fails to converge. ## Counts and rates | Question | Function | `approach` | Reported as | |---|---|---|---| | Event counts | `uni_reg()`, `multi_reg()` | `"poisson"` | Incidence rate ratio | | Over-dispersed counts | `uni_reg()`, `multi_reg()` | `"negbin"` | Incidence rate ratio | ## Continuous outcomes | Question | Function | `approach` | Reported as | |---|---|---|---| | Mean of the outcome | `uni_reg()`, `multi_reg()` | `"linear"` | Beta (difference in means) | | Clustered observations | `multilevel_reg()` | `"linear"` | Beta, random intercept | ## Outcomes with three or more categories | Question | Function | Reported as | |---|---|---| | Ordered categories (mild, moderate, severe) | `ordinal_reg()` | Common odds ratio (proportional odds) | | Unordered categories | `multinomial_reg()` | Odds ratio for each category versus the reference category | ## Time to event | Question | Function | Reported as | |---|---|---| | Describe survival over time | `km_plot()`, `survival_summary()`, `survival_prob()` | Kaplan-Meier estimates | | Compare survival curves | `logrank_test()`, `rmst_table()` | Log-rank p-value, restricted mean survival time | | Hazard of the event | `cox_reg()` | Hazard ratio | | Survival time itself | `surv_reg()` | Time ratio (accelerated failure time) | | One event type in the presence of others | `cuminc_plot()`, `competing_risk_reg()` | Cumulative incidence, subdistribution hazard ratio | Check the proportional-hazards assumption of a Cox model with `check_ph()`. ## Repeating an analysis within groups `stratified_uni_reg()` and `stratified_multi_reg()` fit the same model within each level of a stratifier, for example by sex or study site. ## Beyond a single estimate | Question | Function | |---|---| | Is a variable a confounder or effect modifier? | `identify_confounder()`, `interaction_models()` | | How much of an effect acts through a mediator? | `mediation_analysis()` | | Does the model fit and converge? | `check_convergence()`, `check_collinearity()`, `plot_model_fit()` | | Which of several prespecified models fits best? | `compare_models()`, `select_models()` | ## Next steps - [Start Here](gtregression-intro.html) walks through a complete analysis. - [Function Options](function-options.html) lists every argument and default. - [Merge and Customise Tables](merge-tables.html) combines the results into a manuscript table.