Learn R Programming

TH (version 1.0.0)

tq2a: Chi-Square Goodness-of-Fit Test

Description

Compares observed frequencies with a specified categorical distribution.

Usage

tq2a(
  dadosX = NULL,
  p = NULL,
  FO = NULL,
  FE = 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 containing the observed categories. Use NULL when frequencies are supplied.

p

Vector of positive expected weights or proportions. Used only when FE is not supplied.

FO

Vector of observed frequencies.

FE

Vector of expected frequencies.

alfa

Significance level.

Ha

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

r

Number of restrictions due to parameters estimated from the data when calculating expected frequencies.

plot

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

Author

Willian Silva Barros

Details

Input modes are mutually exclusive: use raw categories with p, FO with p, or FO with FE. Named p and FE vectors are aligned to named observed categories. The standard omnibus chi-square goodness-of-fit test has an upper-tail rejection region.

Main assumptions:

  • mutually exclusive categories;

  • independent observations;

  • adequately large expected frequencies;

See Also

tq2i(), tq2h()

Examples

Run this code
categories <- c(rep("A", 50), rep("B", 30), rep("C", 20))
tq2a(categories, p = c(1, 1, 1), alfa = 0.05, Ha = 2, r = 0, plot = FALSE)

Run the code above in your browser using DataLab