R: Odds Ratio

odds.ratio {questionr} | R Documentation

## Odds Ratio

### Description

S3 method for odds ratio

### Usage

    odds.ratio(x, ...)

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

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

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

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

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

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

    ## S3 method for class 'odds.ratio'
    print(x, signif.stars = TRUE, ...)

### Arguments

`x` | object from whom odds ratio will be computed
`...` | further arguments passed to or from other methods
`level` | the confidence level required
`fac` | a second factor object
`y` | a second numeric object
`signif.stars` | logical; if `TRUE`, p-values are encoded visually as 'significance stars'

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

For 2x2 `table`, `factor` or `matrix`, `odds.ratio` uses `fisher.test` to compute the odds ratio.

### Value

Returns a data.frame of class `odds.ratio` with odds ratios, their confidence interval and p-values.

If `x` and `y` are proportions, `odds.ratio` simply returns the value of the odds ratio, with no confidence interval.

### Author(s)

Joseph Larmarange <joseph@larmarange.net>

### See Also

`glm` in the stats package.

`multinom` in the nnet package.

`fisher.test` in the stats package.

`printCoefmat` in the stats package.

### Examples

    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))
    M <- matrix(c(759, 360, 518, 363), ncol = 2)
    odds.ratio(M)
    odds.ratio(0.26, 0.42)

[Package questionr version 0.6.3 Index]