mhor {mStats} | R Documentation |
Calculating Odds Ratios
Description
mhor()
calculates odds ratios, Mantel Haenszel pooled estimates and
95% CI.
Usage
mhor(
data,
exp,
case,
strata = NULL,
exp_value = NULL,
case_value = NULL,
digits = 4
)
Arguments
data |
data.frame |
exp |
exposure or independent variables |
case |
case or dependent variables (outcomes) |
strata |
if specified, MH OR is calculated. |
exp_value |
value for exposure as reference |
case_value |
value for outcome as reference |
digits |
specify rounding of numbers. See |
Details
Rows and Columns can be rearranged by specifying
exp_value
and case_value
. This is used
when the exposed and case values are not at the right place in 2x2 tables.
Reference row value can be specified in exp_value
.
Attributable fractions, Attr. Frac. Exp
and Attr. Frac. Pop
among exposed and population are calculated when OR is greater than or
equal to 1.
If OR is less than 1, preventable fractions, Prev. Frac. Exp
and Attr. Frac. Pop
are calculated.
It produces a table with Odds Ratio, 95% CI as well as
p-value. If strata
is specified, Mantel-Haenzsel
Pooled
estimates of Odds Ratio
is generated along with Chi-squared test for
homogeneity.
Odds Ratio, OR
OR = (D1 x H0) / (D0 x H1)
Error Factor, EF using Woolf's formula
95\% CI = OR / EF or OR x EF
EF = exp(1.96 x SE(log(OR)))
SE(log(OR)) = \sqrt{1/D1 + 1/H1 + 1/D0 + 1/H0}
Calculating p-value from Wald's z test
z = log OR / SE (log OR)
Mantel-Haenszel's OR
ORMH = Q / R
Q = \sum{(D1i x H0i) / ni}
R = \sum{(D0i x H1i) / ni}
Calculating CI for MH-OR
95\% CI = OR / EF or OR x EF
SE(ORMH) = \sqrt{V / (Q x R)}
V = \sum{(Di x Hi x n0i x n1i) / ( (ni)^2 x (ni - 1))}
Chi-square test for MHOR, df = 1
X^2 (MH), Chi-square value = U^2 / V
U = O - E
O = \sum{D1i}
E = \sum{Di x n1i / ni}
Chi-square test for Heterogeneity
X^2 = \sum{(D1i x H0i - ORMH x D0i x H1i)^2 / ORMH x Vi x ni^2}
Value
data.frame
Author(s)
Email: dr.myominnoo@gmail.com
Website: https://myominnoo.github.io/
References
Betty R. Kirkwood, Jonathan A.C. Sterne (2006, ISBN:978–0–86542–871–3)
B. Burt Gerstman (2013, ISBN:978-1-4443-3608-5)
Douglas G Altman (2005, ISBN:0 7279 1375 1)
Examples
### Example from Essential Medical Statistics
# Page 178, Chapter 18: Controlling for confounding: Stratification
lepto <- expandtbl(
male = c(36, 14, 50, 50), female = c(24, 126, 10, 90),
exp_name = "area", exp_lvl = c("Rural", "Urban"),
case_name = "ab", case_lvl = c("Yes", "No"),
strata_name = "gender"
)
## label variables and data
lepto <- label(lepto, "Prevalence survey of leptospirosis in West Indies")
lepto <- label(lepto, area="Type of area", ab = "Leptospirosis Antibodies",
gender="Gener: Male or Female")
## Calculate OR
mhor(lepto, area, ab)
## Calculate MHOR
mhor(lepto, area, ab, gender)