-
Notifications
You must be signed in to change notification settings - Fork 17
/
odds.ratio.Rd
88 lines (70 loc) · 2.48 KB
/
odds.ratio.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/odds.ratio.R
\name{odds.ratio}
\alias{odds.ratio}
\alias{odds.ratio.glm}
\alias{odds.ratio.multinom}
\alias{odds.ratio.factor}
\alias{odds.ratio.table}
\alias{odds.ratio.matrix}
\alias{odds.ratio.numeric}
\alias{print.odds.ratio}
\title{Odds Ratio}
\usage{
odds.ratio(x, ...)
\method{odds.ratio}{glm}(x, level = 0.95, ...)
\method{odds.ratio}{multinom}(x, level = 0.95, ...)
\method{odds.ratio}{factor}(x, fac, level = 0.95, ...)
\method{odds.ratio}{table}(x, level = 0.95, ...)
\method{odds.ratio}{matrix}(x, level = 0.95, ...)
\method{odds.ratio}{numeric}(x, y, level = 0.95, ...)
\method{print}{odds.ratio}(x, signif.stars = TRUE, ...)
}
\arguments{
\item{x}{object from whom odds ratio will be computed}
\item{...}{further arguments passed to or from other methods}
\item{level}{the confidence level required}
\item{fac}{a second factor object}
\item{y}{a second numeric object}
\item{signif.stars}{logical; if \code{TRUE}, p-values are encoded visually as 'significance stars'}
}
\value{
Returns a data.frame of class \code{odds.ratio} with odds ratios,
their confidence interval and p-values.
If \code{x} and \code{y} are proportions, \code{odds.ratio} simply
returns the value of the odds ratio, with no confidence interval.
}
\description{
S3 method for odds ratio
}
\details{
For models calculated with \code{glm}, \code{x} should have
been calculated with \code{family=binomial}.
p-value are the same as \code{summary(x)$coefficients[,4]}.
Odds ratio could also be obtained with \code{exp(coef(x))} and
confidence intervals with \code{exp(confint(x))}.
For models calculated with \code{multinom} (nnet),
p-value are calculated according to
\url{https://stats.idre.ucla.edu/r/dae/multinomial-logistic-regression/}.
For 2x2 \code{table}, \code{factor} or \code{matrix}, \code{odds.ratio}
uses \code{\link[stats]{fisher.test}} to compute the odds ratio.
}
\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)
}
\seealso{
\code{\link{glm}} in the \link{stats} package.
\code{\link[nnet]{multinom}} in the \link[nnet]{nnet} package.
\code{\link[stats]{fisher.test}} in the \link{stats} package.
\code{\link[stats]{printCoefmat}} in the \link{stats} package.
}
\author{
Joseph Larmarange <joseph@larmarange.net>
}