prop_z_test | R Documentation |
Uses z distribution to test for statistical equality of two proportions
prop_z_test( x, n, p = NULL, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, correct = FALSE, case_col = 1 )
x |
a vector of length two, providing count of "successes" or "outcomes of interest" for either group or a two-dimensional table (or matrix) with 2 columns, giving the counts of successes and failures, respectively. |
n |
a vector of length two for counts of trials/observations in either group; ignored if x is a matrix or a table. |
p |
a vector of length two representing the expected probability of "success" in either group. The vector's elements must be greater than 0 and less than 1. |
alternative |
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter. Only used for testing the null that a single proportion equals a given value, or that two proportions are equal; ignored otherwise. |
conf.level |
confidence level of the returned confidence interval. Must be a single number between 0 and 1. Only used when testing the null that a single proportion equals a given value, or that two proportions are equal; ignored otherwise. |
correct |
a logical indicating whether Yates' continuity correction should be applied where possible. |
case_col |
if x is a table or matrix, a single integer for the index of the column in which cases appear |
Takes a 2x2 table object where default is that cases appear in the first column and counts of the exposed appear in the second row.
Only groups with finite numbers of successes and failures are used. Counts of successes and failures must be nonnegative and hence not greater than the corresponding numbers of trials which must be positive. All finite counts should be integers.
If p is NULL and there is more than one group, the null tested is that the proportions in each group are the same. If there are two groups, the alternatives are that the probability of success in the first group is less than, not equal to, or greater than the probability of success in the second group, as specified by alternative. A confidence interval for the difference of proportions with confidence level as specified by conf.level and clipped to -1,1 is returned.
htest object
Although DGHI Biostat was responsible for the modification of this code, this code was originally adapted from that published as a part of the R stats package, which contained the following message:
File src/library/stats/R/prop.test.R Part of the R package, https://www.R-project.org
Copyright (C) 1995-2012 The R Core Team
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License is available at https://www.R-project.org/Licenses/ @examples prop_z_test(x = c(200, 300), n = c(400, 400))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.