sta_chisq: Pearson's or McNemar's Chi-squared Test for Count Data

Description Usage Arguments Examples

View source: R/sta_chisq.R

Description

Performs chi-squared contingency table tests and goodness-of-fit tests.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
sta_chisq(
  x = NULL,
  y = NULL,
  paired = FALSE,
  obj = TRUE,
  correct = TRUE,
  p = rep(1/length(x), length(x)),
  rescale.p = FALSE,
  simulate.p.value = FALSE,
  B = 2000
)

Arguments

x

a numeric vector or matrix. x and y can also both be factors.

y

a numeric vector; ignored if x is a matrix. If x is a factor, y should be a factor of the same length.

paired

a logical variable indicating whether to treat the two variances as being equal.

obj

a logical whether the test object of stats::chisq.test() or stats::mcnemar.test should be returned.

correct

a logical indicating whether to apply continuity correction when computing the test statistic for 2 by 2 tables: one half is subtracted from all |O - E| differences; however, the correction will not be bigger than the differences themselves. No correction is done if simulate.p.value = TRUE.

p

a vector of probabilities of the same length of x. An error is given if any entry of p is negative.

rescale.p

a logical scalar; if TRUE then p is rescaled (if necessary) to sum to 1. If rescale.p is FALSE, and p does not sum to 1, an error is given.

simulate.p.value

a logical indicating whether to compute p-values by Monte Carlo simulation.

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
## Not run: 
library(magrittr)
data(big_five, package = "inductive")

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

sta_chisq(kont)

kont %>% 
  sta_chisq(paired = TRUE)


## End(Not run)

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