odds_trend: Function to calculate OR using Wald CI, and plot trend.

View source: R/epi_functions.R

odds_trendR Documentation

Function to calculate OR using Wald CI, and plot trend.

Description

odds_trend calculates the odds ratio with confidence intervals (Wald) for different levels (three or more) of the exposure variable, constructs the corresponding plot and calculates if the trend is significant or not.

Usage

odds_trend(formula, data, angle = 45, hjust = 1, method = "wald", ...)

Arguments

formula

A formula with shape: outcome ~ exposure.

data

A data frame where the variables in the formula can be found.

angle

Angle of for the x labels (default = 45).

hjust

Horizontal adjustment for x labels (default = 1).

method

Method for calculating confidence interval around odds ratio.

...

Passes optional arguments to oddsratio.

Details

odds_trend is a wrap function that calls oddsratio from package epitools.

Additional methods for confidence intervals include: "midp", "fisher", and "small".

Value

A list with components df a data frame with the results and fig corresponding plot.

See Also

oddsratio.

Examples

## A cross-sectional study looked at the association between obesity and a biopsy resulting
## from mammography screening.

Freq <- c(3441, 34, 39137, 519, 20509, 280, 12149, 196, 11882, 199)
Biopsy <- gl(2, 1, 10, labels = c("No", "Yes"))
Weight <- gl(5, 2, 10, labels = c(
  "Underweight", "Normal", "Over (11-24%)",
  "Over (25-39%)", "Over (> 39%)"
))
breast <- data.frame(Freq, Biopsy, Weight)
breast

breast <- expand_df(breast)
require(sjlabelled, quietly = TRUE)

breast <- var_labels(breast,
  Weight = "Weight group"
)

odds_trend(Biopsy ~ Weight, data = breast)$df
odds_trend(Biopsy ~ Weight, data = breast)$fig

pubh documentation built on Nov. 14, 2023, 1:08 a.m.