Type: | Package |
Title: | 'Stata'-Like Matched Case-Control Analysis |
Version: | 0.1.1 |
Date: | 2024-11-19 |
Maintainer: | Simon R Parker <simon.parker.24@ucl.ac.uk> |
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. |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
URL: | https://github.com/simpar1471/matchedcc/, https://simpar1471.github.io/matchedcc/ |
BugReports: | https://github.com/simpar1471/matchedcc/issues |
Depends: | R (≥ 4.1.0) |
Imports: | checkmate, stats, cli, binom |
Suggests: | testthat (≥ 3.0.0), readr, vctrs, stringr, purrr, knitr, rmarkdown, RStata |
LazyData: | true |
Config/Needs/website: | rmarkdown |
NeedsCompilation: | no |
Packaged: | 2024-11-20 17:22:43 UTC; tadeo |
Author: | Simon R Parker |
Repository: | CRAN |
Date/Publication: | 2024-11-21 17:10:02 UTC |
Stata-like analysis of unstratified matched-case control data
Description
Using data from vectors, data from a 2x2 contingency table, or individual
cell counts, mcc()
and mcci()
will calculate McNemar's \chi^{2}
;
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.
Usage
mcc(cases = NULL, controls = NULL, table = NULL, conf_level = 0.95)
mcci(a, b, c, d, conf_level = 0.95)
Arguments
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. |
Value
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
{H}_{0}
:OR = 1
, 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.
References
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.
Examples
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])
Example data for matched case-control analysis
Description
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.
Usage
mccxmpl
Format
mccxmpl
A data frame with 27 rows and 2 columns:
case
Integer variable of either
1
(exposed) or0
(not exposed)control
Integer variable of either
1
(exposed) or0
(not exposed)
Source
In Stata 18 - run the commands:
webuse mccxmpl, clear expand pop keep case control
References
Jick, H. et al. (1973). Coffee and myocardial infarction. New England Journal of Medicine 289: 63–67. doi:10.1056/NEJM197307122890203.