View source: R/p_mcnemar.test.R
| p_mcnemar.test | R Documentation |
Generates two-dimensional sample data for McNemar test and
return a p-value. Uses mcnemar.test.
p_mcnemar.test(
n,
prop,
OR = NULL,
prop.disc = NULL,
two.tailed = TRUE,
correct = TRUE,
gen_fun = gen_mcnemar.test,
return_analysis = FALSE,
...
)
gen_mcnemar.test(n, prop, ...)
n |
total sample size |
prop |
two-dimensional matrix of proportions/probabilities |
OR |
instead of supplying the |
prop.disc |
proportion of discordant pairings, |
two.tailed |
logical; should a two-tailed or one-tailed test be used? |
correct |
logical; use continuity correction? Only applicable for 2x2 tables |
gen_fun |
function used to generate the required discrete data.
Object returned must be a |
return_analysis |
logical; return the analysis object for further extraction and customization? |
... |
additional arguments to be passed to |
a single p-value
Phil Chalmers rphilip.chalmers@gmail.com
gen_mcnemar.test
# from ?mcnemar.test
Performance <- matrix(c(794, 86, 150, 570),
nrow = 2,
dimnames = list("1st Survey" = c("Approve", "Disapprove"),
"2nd Survey" = c("Approve", "Disapprove")))
(prop <- prop.table(Performance))
# one sample + test and resulting p-value
p_mcnemar.test(n=sum(Performance), prop=prop)
# return analysis model
p_mcnemar.test(n=sum(Performance), prop=prop, return_analysis=TRUE)
# post-hoc power (not recommended)
Spower(p_mcnemar.test(n=sum(Performance), prop=prop))
# odds ratio + discordant proportions supplied instead
OR <- prop[1,2] / prop[2,1]
disc <- prop[1,2] + prop[2,1]
p_mcnemar.test(n=50, OR=.25, prop.disc=disc, two.tailed=FALSE) |>
Spower(replications=30000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.