Learn R Programming

RVAideMemoire (version 0.9-45-2)

chisq.bintest: Pearson's Chi-squared test for binary variables

Description

Performs a Pearson's Chi-squared test for comparing response probabilities (i.e. when the response variable is a binary variable). The function is in fact a wrapper to the chi-squared test for comparison of proportions on a contingency table. If the p-value of the test is significant, the function performs pairwise comparisons by using Pearson's Chi-squared tests.

Usage

chisq.bintest(formula, data, alpha = 0.05, p.method = "fdr")

Arguments

formula
a formula of the form a ~ b, where a and b give the data values and corresponding groups, respectively. a can be a numeric vector or a factor, with only two possible values (except NA).
data
an optional data frame containing the variables in the formula formula. By default the variables are taken from environment(formula).
alpha
significance level to compute pairwise comparisons.
p.method
method for p-values correction. See help of p.adjust.

Value

  • method.testa character string giving the name of the global test computed.
  • data.namea character string giving the name(s) of the data.
  • alternativea character string describing the alternative hypothesis.
  • estimatethe estimated probabilities.
  • null.valuethe value of the difference in probabilities under the null hypothesis, always 0.
  • statistictest statistics.
  • parametertest degrees of freedom.
  • p.valuep-value of the global test.
  • alphasignificance level.
  • p.adjust.methodmethod for p-values correction.
  • p.value.multcompdata frame of pairwise comparisons result.
  • method.multcompa character string giving the name of the test computed for pairwise comparisons.

Details

If the response is a 0/1 variable, the probability of the '1' group is tested. In any other cases, the response is transformed into a factor and the probability of the second level is tested. Since a chi-squared test is an approximate test, an exact test is preferable when the number of individuals is small (200 is a reasonable minimum). See fisher.bintest in that case.

See Also

G.bintest, fisher.bintest

Examples

Run this code
response <- c(rep(0:1,c(40,60)),rep(0:1,c(55,45)),rep(0:1,c(65,35)))
fact <- gl(3,100,labels=LETTERS[1:3])
chisq.bintest(response~fact)

Run the code above in your browser using DataLab