prop_test | R Documentation |
prop_test
is used to test the null hypothesis that the proportions
(probabilities of success) in several groups are the same, or that they equal
certain values.
prop_test( x, n, p = NULL, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, correct = FALSE )
x |
A number (or vector) of successes (observed counts). |
n |
A number (or vector) of sample sizes or counts of trials. |
p |
The null hypothesis value of the proportion (or difference in proportions) |
alternative |
A character string (in quotes) specifying the alternative
hypothesis. Must be one of " |
conf.level |
The confidence level of the returned confidence interval. Must be a single number between 0 and 1. |
correct |
A logical ( |
Note that this is different from prop.test
, which will
return confidence intervals created through a method we do not discuss in
STATS 250.
A list with class "htest
".
# Computing a confidence interval for one proportion # We have 1054 successes out of 1553 "trials", and will compute a 95% confidence interval prop_test(x = 1054, n = 1553, conf.level = 0.95) # Performing a hypothesis test for one proportion # We have 1054 successes out of 1553 "trials". Do we have evidence to say the # population proportion is greater than 55.3%? prop_test(x = 1054, n = 1553, p = 0.553, alternative = "greater") # Computing a confidence interval for a difference in two proportions # We have 22 successes out of 32 in Group A, and 97 successes out of 168 in # Group B. Let's make a 99% confidence interval for the difference in these # two proportions. prop_test(x = c(22, 97), n = c(32, 168), conf.level = 0.99) # Performing a hypothesis test for a difference in two proportions # We have 22 successes out of 32 in Group A, and 97 successes out of 168 in # Group B. Do we have evidence to say that the proportion of successes in # Group A is less than the proportion of successes in Group B? prop_test(x = c(22, 97), n = c(32, 168), alternative = "less")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.