sta_fisher: Fisher's Exact Test for Count Data

Description Usage Arguments Examples

View source: R/sta_fisher.R

Description

Performs Fisher's exact test for testing the null of independence of rows and columns in a contingency table with fixed marginals.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
sta_fisher(
  x,
  y = NULL,
  obj = TRUE,
  workspace = 2e+05,
  hybrid = FALSE,
  hybridPars = c(expect = 5, percent = 80, Emin = 1),
  control = list(),
  or = 1,
  alternative = "two.sided",
  conf.int = TRUE,
  conf.level = 0.95,
  simulate.p.value = FALSE,
  B = 2000
)

Arguments

x

either a two-dimensional contingency table in matrix form, or a factor object.

y

a factor object; ignored if x is a matrix.

obj

a logical whether the test object of stats::fisher.test() should be returned.

workspace

an integer specifying the size of the workspace used in the network algorithm. In units of 4 bytes. Only used for non-simulated p-values larger than 2 by 2 tables. Since R version 3.5.0, this also increases the internal stack size which allows larger problems to be solved, however sometimes needing hours. In such cases, simulate.p.values=TRUE may be more reasonable.

hybrid

a logical. Only used for larger than 2 by 2 tables, in which cases it indicates whether the exact probabilities (default) or a hybrid approximation thereof should be computed.

hybridPars

a numeric vector of length 3, by default describing “Cochran's conditions” for the validity of the chisquare approximation, see ‘Details’.

control

a list with named components for low level algorithm control. At present the only one used is "mult", a positive integer >= 2 with default 30 used only for larger than 2 by 2 tables. This says how many times as much space should be allocated to paths as to keys: see file ‘fexact.c’ in the sources of this package.

or

the hypothesized odds ratio. Only used in the 2 by 2 case.

alternative

indicates the alternative hypothesis and must be one of "two.sided", "greater" or "less". You can specify just the initial letter. Only used in the 2 by 2 case.

conf.int

logical indicating if a confidence interval for the odds ratio in a 2 by 2 table should be computed (and returned).

conf.level

confidence level for the returned confidence interval. Only used in the 2 by 2 case and if conf.int = TRUE.

simulate.p.value

a logical indicating whether to compute p-values by Monte Carlo simulation, in larger than 2 by 2 tables.

B

an integer specifying the number of replicates used in the Monte Carlo test.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
library(magrittr)
data(big_five, package = "inductive")

kont <- table(big_five$Gender, big_five$Extraversion > 4)

kont %>% 
  sta_fisher()

fisher <- kont %>% 
  sta_fisher()

fisher$result
fisher$obj

## End(Not run)

j3ypi/inductive documentation built on Feb. 7, 2020, 12:37 p.m.