Performs a Fisher's exact test for comparing response probabilities (i.e. when the response variable is a binary variable). The function is in fact a wrapper to the Fisher's exact test for count data. If the p-value of the test is significant, the function performs pairwise comparisons by using Fisher's exact tests.
fisher.bintest(formula, data, alpha = 0.05, p.method = "fdr")
a character string giving the name of the global test computed.
a character string giving the name(s) of the data.
a character string describing the alternative hypothesis.
the estimated probabilities.
the value of the difference in probabilities under the null hypothesis, always 0.
p-value of the global test.
significance level.
method for p-values correction.
data frame of pairwise comparisons result.
a character string giving the name of the test computed for pairwise comparisons.
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).
an optional data frame containing the variables in the formula formula
. By default the variables are taken from environment(formula)
.
significance level to compute pairwise comparisons.
method for p-values correction. See help of p.adjust
.
Maxime HERVE <maxime.herve@univ-rennes1.fr>
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 chi-squared and G tests are approximate tests, exact tests are preferable when the number of individuals is small (200 is a reasonable minimum).
chisq.bintest
, G.bintest
response <- c(0,0,0,0,0,0,1,0,0,0,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])
fisher.bintest(response~fact)
Run the code above in your browser using DataLab