prop_test {quest} | R Documentation |
Test for Sample Proportion Against Pi (chi-square test of goodness of fit)
Description
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.
Usage
prop_test(
x,
pi = 0.5,
yates = TRUE,
ci.level = 0.95,
rtn.table = TRUE,
check = TRUE
)
Arguments
x |
numeric vector that only has values of 0 or 1 (or missing values), otherwise known as a dummy variable. |
pi |
numeric vector of length 1 specifying the population proportion value to compare the sample proportion against. |
yates |
logical vector of length 1 specifying whether the Yate's
continuity correction should be applied for small samples. See
|
ci.level |
numeric vector of length 1 specifying the confidence level.
|
rtn.table |
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. |
check |
logical vector of length 1 specifying whether the input
arguments should be checked for errors. For example, if |
Value
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
- est
proportion difference estimate (i.e., sample proportion - pi)
- se
NA (to remind the user there is no standard error for the test)
- X2
chi-square value
- df
degrees of freedom (will always be 1)
- p
two-sided p-value
2) desc = descriptive statistics stat info in a numeric vector
- prop
sample proportion
- pi
popularion proportion provided by the user (or 0.50 by default)
- sd
standard deviation
- n
sample size
- lwr
lower bound of the confidence interval of the sample proportion itself
- upr
upper bound of the confidence interval of the sample proportion itself
3) std = various standardized effect sizes in a numeric vector
- cramer
Cramer's V estimate
- h
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"
See Also
prop.test
the workhorse for prop_test
,
props_test
for multiple dummy variables,
prop_diff
for chi-square test of independence,
Examples
# 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
## Not run:
prop_test(ifelse(mtcars$"am" == 1, yes = "1", no = "0"))
prop_test(ifelse(mtcars$"am" == 1, yes = 2, no = 1))
## End(Not run)