mcc | R Documentation |
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.
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 {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.
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.
\Sexpr[results=rd]{tools:::Rd_expr_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])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.