Learn R Programming

vcd (version 1.1-1)

oddsratio: (Log) Odds Ratios

Description

Computes (log) odds ratios and their asymptotic standard errors for (possibly) stratified data.

Usage

oddsratio(x, stratum = NULL, log = TRUE)
## S3 method for class 'oddsratio':
plot(x, conf_level = 0.95, type = "o",
  xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, whiskers = 0.1,
  baseline = TRUE, transpose = FALSE, \dots)

Arguments

x
a 2 by 2 by ...table.
stratum
vector of strata dimensions.
log
if FALSE, ordinary odds ratios are computed.
conf_level
if not NULL or FALSE, conf_level-% confidence intervals are plotted for each data point.
type
plot type.
xlab
label for the x-axis. Defaults to "Strata" if transpose is FALSE.
ylab
label for the y-axis. Defaults to "Strata" if transpose is TRUE.
xlim
x-axis limits. Ignored if transpose is FALSE.
ylim
y-axis limits. Ignored if transpose is TRUE.
baseline
if TRUE, a red dashed line is plotted at a value of 1 (in case of odds) or 0 (in case of log-odds).
transpose
if TRUE, the plot is transposed.
whiskers
width of the confidence interval whiskers.
...
other graphics parameters (see par).

Value

  • An object of class "logoddsratio", which is simply a vector of (log) odds ratios with dimensionality depending on stratum, along with the following attributes:
  • ASEa numeric vector with the asymptotic standard errors.
  • loglogical indicating whether log odds ratios or common odds ratios are computed.

References

M. Friendly (2000), Visualizing Categorical Data. SAS Institute, Cary, NC.

See Also

confint

Examples

Run this code
## load Coal Miners data
data("CoalMiners")

## compute log odds ratios
lor <- oddsratio(CoalMiners)
lor

## summary with z tests
summary(lor)

## confidence intervals
confint(lor)

## visualization
plot(lor,
     xlab = "Age Group",
     main = "Breathelessness and Wheeze in Coal Miners")

## add quadratic model
g <- seq(25, 60, by = 5)
m <- lm(lor ~ g + I(g^2))
lines(fitted(m), col = "red")

Run the code above in your browser using DataLab