Learn R Programming

TH (version 1.0.0)

tq2i: Chi-Square Test of Independence

Description

Assesses association between two categorical variables.

Usage

tq2i(
  dadosX = NULL,
  dadosY = NULL,
  FO = NULL,
  alfa = 0.05,
  Ha = 2,
  r = 0,
  plot = TRUE
)

Value

Invisibly returns an object of classes th_test and htest containing the statistic, degrees of freedom, p-value, critical value, decision, observed frequencies, and expected frequencies. When plot = TRUE, an educational graph is produced as a side effect.

Arguments

dadosX

Vector for the first categorical variable. Use NULL when a frequency table is supplied.

dadosY

Vector for the second categorical variable. Use NULL when a frequency table is supplied.

FO

Matrix of observed frequencies.

alfa

Significance level.

Ha

Right-tailed alternative. Use 2 or "greater"; other values are rejected.

r

Retained for backward compatibility. It must be zero; Pearson degrees of freedom are used without adjustment.

plot

Logical. If TRUE (default), draw the educational graph; if FALSE, return the result without plotting.

Author

Willian Silva Barros

Details

The function accepts two categorical variables recorded at the observation level or an observed contingency table. The standard omnibus chi-square test of independence has an upper-tail rejection region.

Main assumptions:

  • independent observations;

  • mutually exclusive categories;

  • adequately large expected frequencies;

See Also

tq2a(), tq2h()

Examples

Run this code
FO <- matrix(c(30, 10, 5, 10, 25, 20), nrow = 2, byrow = TRUE)
tq2i(NULL, NULL, FO = FO, alfa = 0.05, Ha = 2, r = 0, plot = FALSE)

Run the code above in your browser using DataLab