Learn R Programming

catfun (version 0.1.4)

prop_test: Tests for equality of proportions

Description

Conduct 1-sample tests of proportions and tests for equality of k proportions.

Usage

prop_test(x, ...)

Arguments

x

a vector of counts, a one-dimensional table with two entries, or a two-dimensional table with 2 columns. Used to select method.

...

further arguments passed to or from other methods.

Value

a list with class "prop_test" containing the following components:

x

number of successes

n

number of trials

p

null proportion

statistic

the value of Pearson's chi-squared test statistic

p_value

p-value corresponding to chi-squared test statistic

df

degrees of freedom

method

the method used to calculate the confidence interval

method_ci

confidence interval calculated using specified method

exact_ci

exact confidence interval

exact_p

p-value from exact test

Details

Calculations are done using the methods described in `stats::binom.test()` and `stats::prop.test()`

See Also

[stats::binom.test()], [stats::prop.test()]

Examples

Run this code
# NOT RUN {
prop_test(7, 50, method = "wald", p = 0.2)
prop_test(7, 50, method = "wald", p = 0.2, exact = TRUE)
prop_test(c(23, 24), c(50, 55))

vietnam <- data.frame(
   service = c(rep("yes", 2), rep("no", 2)),
   sleep = c(rep(c("yes", "no"), 2)),
   count = c(173, 160, 599, 851)
)

sleep <- xtabs(count ~ service + sleep, data = vietnam)
prop_test(sleep)

prop_test(vietnam, service, sleep, count)

# }

Run the code above in your browser using DataLab