Learn R Programming

pubh (version 3.0.0)

odds_trend: 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.

Usage

odds_trend(data, x, y, method = "wald", ...)

Value

A data frame.

Arguments

data

A data frame.

x

A variable in the data frame.

y

A variable in the data frame.

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".

See Also

oddsratio.

Examples

Run this code
## 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"
)

breast |>
  odds_trend(x = Weight, y = Biopsy)

breast |>
  odds_trend(x = Weight, y = Biopsy) |>
  effect_plot(x = OR, y = Exposure)

Run the code above in your browser using DataLab