oddsratio: oddsratio

Description Usage Arguments Value Examples

View source: R/oddsratio.R

Description

The oddsratio function simply computes a point estimate and confidence interval for an odds ratio.

Usage

1
oddsratio(x, y = NULL, conf.level = .95, digits=2)

Arguments

x

x can be either a table (then y can be NULL) or a factor.

y

If x is a factor, y also has to be a factor; x and y are then used to create the crosstable.

conf.level

The confidence level of the confidence interval.

digits

Number of digits to round output to

Value

The oddsratio function returns an object with the input and output.

input

List with input arguments

or

Point estimate for odds ratio

or.ci

Confidence interval for odds ratio

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
### Generate two factor vectors
treatment <- factor(c(rep(0, 33), rep(1, 45), rep(0, 63), rep(1, 21)),
                    levels=c(0,1), labels=c("no", "yes"));
survival <- factor(c(rep(0, 78), rep(1, 84)),
                   levels=c(0, 1), labels=c("no", "yes"));

### Compute and display odds ratio
oddsratio(treatment, survival);

### Or present a table
oddsratio(table(treatment, survival));

Example output

sh: 1: cannot create /dev/null: Permission denied
Odds ratio point estimate: 0.24
95% confidence interval:   [0.13, 0.48]
Odds ratio point estimate: 0.24
95% confidence interval:   [0.13, 0.48]

userfriendlyscience documentation built on May 2, 2019, 1:09 p.m.