questionr (version 0.4.3)

odds.ratio: Odds Ratio

Description

S3 method for odds ratio

Usage

odds.ratio(x, ...)

## S3 method for class 'glm': odds.ratio(x, level = 0.95, digits = 3, ...)

## S3 method for class 'multinom': odds.ratio(x, level = 0.95, digits = 3, ...)

## S3 method for class 'factor': odds.ratio(x, y, level = 0.95, ...)

## S3 method for class 'table': odds.ratio(x, level = 0.95, ...)

Arguments

x
object from whom odds ratio will be computed
...
further arguments passed to or from other methods
level
the confidence level required
digits
number of decimal to display
y
a second factor object

Value

  • For glm or multinom objects, returns odds ratios, their confidence interval and tests if they differ from 1.

    For 2x2 table or factor objects, odds.ratio is a wrapper for fisher.test.

Details

For models calculated with glm, x should have been calculated with family=binomial. p-value are the same as summary(x)$coefficients[,4]. Odds ratio could also be obtained with exp(coef(x)) and confidence intervals with exp(confint(x)).

For models calculated with multinom (nnet), p-value are calculated according to http://www.ats.ucla.edu/stat/r/dae/mlogit.htm.

See Also

glm in the stats package.

multinom in the nnet package.

fisher.test in the stats package.

Examples

Run this code
data(hdv2003)
reg <- glm(cinema ~ sexe + age, data=hdv2003, family=binomial)
odds.ratio(reg)
odds.ratio(hdv2003$sport, hdv2003$cuisine)
odds.ratio(table(hdv2003$sport, hdv2003$cuisine))

Run the code above in your browser using DataCamp Workspace