Title: | 'Stata'-Like Matched Case-Control Analysis |
---|---|
Description: | Calculate multiple statistics with confidence intervals for matched case-control data including risk difference, risk ratio, relative difference, and the odds ratio. Results are equivalent to those from 'Stata', and you can choose how to format your input data. Methods used are those described on page 56 the 'Stata' documentation for "Epitab - Tables for Epidemologists" <https://www.stata.com/manuals/repitab.pdf>. |
Authors: | Simon R Parker [aut, cre, cph] |
Maintainer: | Simon R Parker <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.1 |
Built: | 2024-11-25 15:24:33 UTC |
Source: | CRAN |
Using data from vectors, data from a 2x2 contingency table, or individual
cell counts, mcc()
and mcci()
will calculate McNemar's ;
point estimates and confidence intervals for the difference, ratio, and
relative difference of proportion of pairs with the exposure; and the odds
ratio with a confidence interval.
mcc(cases = NULL, controls = NULL, table = NULL, conf_level = 0.95) mcci(a, b, c, d, conf_level = 0.95)
mcc(cases = NULL, controls = NULL, table = NULL, conf_level = 0.95) mcci(a, b, c, d, conf_level = 0.95)
cases , controls
|
Numeric vectors of the same length, with values of |
|||||||||||||
table |
A 2x2 integerish (see The table should have the following format, where each cell represents a pair of a matched case and control:
|
|||||||||||||
conf_level |
Numeric scalar from |
|||||||||||||
a , b , c , d
|
Single integerish values with cell counts that correspond to a 2x2 table of matched case control data. |
A named list with 5 elements:
data
A 3x3 matrix generated using the data provided, formatted for matched case-control analysis and with row/column totals.
mcnemar_chi2
Results from analysing the matched case-control data
with mcnemar.test()
, without Yates' continuity correction.
mcnemar_exact_p
Result of an exact test of :
, calculated using the binomial distribution.
proportions
A two-element numeric vector with the proportion of of cases and controls with the exposure.
statistics
A 4 row, 3 column numeric matrix with point estimates and confidence intervals for the ratio, difference, and relative difference in the proportion of cases/controls with the exposure, and the odds ratio.
Exact Chi-squared statistic:
McNemar, Q. (1947) Note on the sampling error of the difference between
correlated proportions or percentages Psychometrika 12(2): 153–157.
doi:10.1007/bf02295996
Other steps:
Agresti, A. (2013) Categorical Data Analysis 3rd ed. Hoboken, NJ: Wiley.
pp. 414-417.
data <- matchedcc::mccxmpl mcc(cases = data$case, controls = data$control) # Convert data into 2x2 table data$case_fctr <- factor(data$case, levels = c(1, 0), labels = c("6+ cups", "0 cups")) data$control_fctr <- factor(data$control, levels = c(1, 0), labels = c("6+ cups", "0 cups")) mcc(table = table(data$control_fctr, data$case_fctr)) # Alternatively, provide cell counts to `mcci()` table <- table(data$control_fctr, data$case_fctr) mcci(a = table[1,1], b = table[1,2], c = table[2,1], d = table[2,2])
data <- matchedcc::mccxmpl mcc(cases = data$case, controls = data$control) # Convert data into 2x2 table data$case_fctr <- factor(data$case, levels = c(1, 0), labels = c("6+ cups", "0 cups")) data$control_fctr <- factor(data$control, levels = c(1, 0), labels = c("6+ cups", "0 cups")) mcc(table = table(data$control_fctr, data$case_fctr)) # Alternatively, provide cell counts to `mcci()` table <- table(data$control_fctr, data$case_fctr) mcci(a = table[1,1], b = table[1,2], c = table[2,1], d = table[2,2])
A subset of data from Jick et al. (1973) with data on a matched case-control study on myocardial infarction and drinking 6+ cups of coffee per day. Cases and controls were matched after excluding people who drank 1 to 5 cups of coffee per day.
mccxmpl
mccxmpl
mccxmpl
A data frame with 27 rows and 2 columns:
case
Integer variable of either 1
(exposed) or 0
(not exposed)
control
Integer variable of either 1
(exposed) or 0
(not exposed)
In Stata 18 - run the commands:
webuse mccxmpl, clear expand pop keep case control
Jick, H. et al. (1973). Coffee and myocardial infarction. New England Journal of Medicine 289: 63–67. doi:10.1056/NEJM197307122890203.