prop_test.data.frame: Tests for equality of proportions

Description Usage Arguments Value Examples

Description

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

Usage

1
2
3
4
5
6
7
## S3 method for class 'data.frame'
prop_test(x, pred, out, weight = NULL,
  rev = c("neither", "rows", "columns", "both"), method = c("wald",
  "wilson", "agresti-couli", "jeffreys", "modified wilson", "wilsoncc",
  "modified jeffreys", "clopper-pearson", "arcsine", "logit", "witting",
  "pratt"), alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95, correct = FALSE, exact = FALSE, ...)

Arguments

x

a dataframe with categorical variable pred and binary outcome out.

pred

predictor/exposure, vector.

out

outcome, vector.

weight

an optional vector of count weights.

rev

reverse order of cells. Options are "row", "columns", "both", and "neither" (default).

method

a character string indicating method for calculating confidence interval, default is "wald". Options include, wald, wilson, agresti-couli, jeffreys, modified wilson, wilsoncc modified jeffreys, clopper-pearson, arcsine, logit, witting, and pratt.

alternative

character string specifying the alternative hypothesis. Possible options are "two.sided" (default), "greater", or "less".

conf.level

confidence level for confidence interval, default is 0.95.

correct

a logical indicating whether Yate's continuity correction should be applied.

exact

a logical indicating whether to output exact p-value, ignored if k-sample test.

...

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

Examples

1
2
3
4
5
6
7
vietnam <- data.frame(
   service = c(rep("yes", 2), rep("no", 2)),
   sleep = c(rep(c("yes", "no"), 2)),
   count = c(173, 160, 599, 851)
)

prop_test(vietnam, service, sleep, count)

Example output

Observed proportions:0.58690.4805
---------------------------------------- 
Confidence interval method: wald 
Confidence intervals: 
  Lower bound Upper bound
1   0.5615526   0.6122405
2   0.4268187   0.5341422
---------------------------------------- 
2 sample test for equality of proportions 
Chi-squared: 12.49136 
p-value: 0.00041 

catfun documentation built on June 14, 2019, 5:04 p.m.