Learn R Programming

RVAideMemoire (version 0.9-11)

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=NULL, 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.
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 the p.adjust() function.

Value

  • data.namea character string giving the name(s) of the data.
  • alphasignificance level.
  • testa short character string giving the test computed.
  • 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.
  • methoda long character string giving the test computed.
  • p.adjust.methodmethod for p-values correction.
  • multcompdata frame of pairwise comparisons result.
  • multcomp.methoda character string giving 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