p_mcnemar.test: p-value from McNemar test simulation

View source: R/p_mcnemar.test.R

p_mcnemar.testR Documentation

p-value from McNemar test simulation

Description

Generates two-dimensional sample data for McNemar test and return a p-value. Uses mcnemar.test.

Usage

p_mcnemar.test(
  n,
  prop,
  two.tailed = TRUE,
  correct = TRUE,
  gen_fun = gen_mcnemar.test,
  ...
)

gen_mcnemar.test(n, prop, ...)

Arguments

n

total sample size

prop

two-dimensional matrix of proportions/probabilities

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 matrix with k rows and k columns of counts. Default uses gen_mcnemar.test. User defined version of this function must include the argument ...

...

additional arguments to be passed to gen_fun. Not used unless a customized gen_fun is defined

Value

a single p-value

Author(s)

Phil Chalmers rphilip.chalmers@gmail.com

See Also

gen_mcnemar.test

Examples


# 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)



# post-hoc power (not recommended)
Spower(p_mcnemar.test(n=sum(Performance), prop=prop))




Spower documentation built on April 4, 2025, 5:11 a.m.