odds.ratio: Create an odds ratio estimate from a 2-by-2 table of...

Description Usage Arguments Value Author(s) Examples

View source: R/odds.ratio.r

Description

Create an odds ratio estimate from a 2-by-2 table of frequencies or proportions

Usage

1

Arguments

x

A two-dimensional matrix or table containing frequencies or proportions.

Value

A numeric vector.

Author(s)

Paul W. Egeler, M.S.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Load in Titanic data from datasets package
data(Titanic, package = "datasets")

# Get marginal table of survival by sex
marginal_table <- margin.table(Titanic, c(2,4))
marginal_table

# Compute odds ratio of marginal table
odds.ratio(marginal_table)

# Get partial tables of survival by sex, stratified by class
partial_tables <- margin.table(Titanic, c(2,4,1))
partial_tables

# Compute odds ratio of each partial table
apply(partial_tables, 3, odds.ratio)

pegeler/samplesizeCMH documentation built on May 15, 2018, 9:31 p.m.