prop_test
tests for a sample proportion difference from a population
proportion with a chi-square test of goodness of fit. The default is that the
goodness of fit is consistent with a population proportion Pi of 0.50. The
function also calculates the descriptive statistics, various standardized
effect sizes (e.g., Cramer's V), and can provide the 1x2 contingency tables.
prop_test
is simply a wrapper for prop.test
plus
some extra calculations.
prop_test(
x,
pi = 0.5,
yates = TRUE,
ci.level = 0.95,
rtn.table = TRUE,
check = TRUE
)
list of numeric vectors containing statistical information about the
proportion difference from pi: 1) nhst = chi-square test of goodness of fit stat
info in a numeric vector, 2) desc = descriptive statistics stat info in a
numeric vector, 3) std = various standardized effect sizes in a numeric vector,
4) count = numeric vector of length 3 with table of counts with an additional
element for the total (if rtn.table
= TRUE), 5) percent = numeric vector
of length 3 with table of overall percentages with an element for the total
(if rtn.table
= TRUE)
1) nhst = chi-square test of goodness of fit stat info in a numeric vector
proportion difference estimate (i.e., sample proportion - pi)
NA (to remind the user there is no standard error for the test)
chi-square value
degrees of freedom (will always be 1)
two-sided p-value
2) desc = descriptive statistics stat info in a numeric vector
sample proportion
popularion proportion provided by the user (or 0.50 by default)
standard deviation
sample size
lower bound of the confidence interval of the sample proportion itself
upper bound of the confidence interval of the sample proportion itself
3) std = various standardized effect sizes in a numeric vector
Cramer's V estimate
Cohen's h estimate
4) count = numeric vector of length 3 with table of counts with an additional
element for the total (if rtn.table
= TRUE). The names are 1. "0", 2.
"1", 3. "total"
5) percent = numeric vector of length 3 with table of overall percentages with
an element for the total (if rtn.table
= TRUE). The names are 1. "0", 2.
"1", 3. "total"
numeric vector that only has values of 0 or 1 (or missing values), otherwise known as a dummy variable.
numeric vector of length 1 specifying the population proportion value to compare the sample proportion against.
logical vector of length 1 specifying whether the Yate's
continuity correction should be applied for small samples. See
chisq.test
for details.
numeric vector of length 1 specifying the confidence level.
ci.level
must range from 0 to 1.
logical vector of lengh 1 specifying whether the return object should include the 1x2 contingency table of counts with totals and the 1x2 overall percentages table. If TRUE, then the last two elements of the return object are "count" containing a vector of counts and "percent" containing a vector of overall percentages.
logical vector of length 1 specifying whether the input
arguments should be checked for errors. For example, if x
is a dummy
variable that only takes on value of 0 or 1 (or missing values). This is a
tradeoff between computational efficiency (FALSE) and more useful error
messages (TRUE).
prop.test
the workhorse for prop_test
,
props_test
for multiple dummy variables,
prop_diff
for chi-square test of independence,
# chi-square test of goodness of fit
table(mtcars$"am")
prop_test(mtcars$"am")
prop_test(ifelse(mtcars$"am" == 1, yes = 0, no = 1))
# different than intercept only logistic regression
summary(glm(am ~ 1, data = mtcars, family = binomial(link = "logit")))
# error from non-dummy variable
if (FALSE) {
prop_test(ifelse(mtcars$"am" == 1, yes = "1", no = "0"))
prop_test(ifelse(mtcars$"am" == 1, yes = 2, no = 1))
}
Run the code above in your browser using DataLab