Learn R Programming

RVAideMemoire (version 0.9-35)

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

Description

Perform a Pearson's Chi-squared test for comparing response probabilities (i.e. when the response variable is a binary variable), or a Fisher's exact test for count data if more than 20% of expected counts are

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 (Pearson's Chi-squared test only).
  • parametertest degrees of freedom (Pearson's Chi-squared test only).
  • 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.

Examples

Run this code
response <- c(0,0,0,0,0,0,1,0,0,1,0,0,1,0,1,1,1,0,0,1,1,1,1,1,1,0,0,1,1,1)
fact <- gl(3,10,labels=LETTERS[1:3])
chisq.bintest(response~fact)

Run the code above in your browser using DataLab