Package 'matchedcc'

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

Help Index


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 χ2\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 0 (unexposed) and 1 (exposed). The default for these variables is NULL, and an error will be thrown if you attempt to provide these parameters as well as table. If provided, these variables are used to construct a 2x2 matrix in the same format as table.

table

A 2x2 integerish (see checkmate::check_integerish()) matrix with matched case-control data. The default value of table is NULL, and an error will be thrown if you provide table as well as cases and controls.

The table should have the following format, where each cell represents a pair of a matched case and control:

Cases Controls
Exposed Unexposed
Exposed a b
Unexposed c d
conf_level

Numeric scalar from 0.1 to 0.9999. Controls level at which to calculate confidence intervals. Default = 0.95 (95% confidence intervals).

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 H0{H}_{0}: OR=1OR = 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) or 0 (not exposed)

control

Integer variable of either 1 (exposed) or 0 (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.