upsilon.gof.test: Upsilon Goodness-of-Fit Test for Count Data

View source: R/upsilon.gof.test.R

upsilon.gof.testR Documentation

Upsilon Goodness-of-Fit Test for Count Data

Description

(FOR INTERNAL USE ONLY) Performs the Upsilon Goodness-of-Fit test to determine if a sample of observed counts fits a specified probability distribution. The Upsilon statistic uses a specific normalization (dividing by the average expected count) which differs from the standard Pearson's Chi-squared test.

Usage

upsilon.gof.test(
  x,
  p = rep(1/length(x), length(x)),
  rescale.p = TRUE,
  log.p = FALSE
)

Arguments

x

A numeric vector representing observed counts. Must be non-negative.

p

A numeric vector of probabilities of the same length as x. Defaults to a uniform distribution (1/length(x)).

rescale.p

Logical. If TRUE (default), p is rescaled to sum to 1. If FALSE, p must sum to 1, otherwise an error is raised.

log.p

a logical. If TRUE, the p-value is calculated in closed form to natural logarithm of p-value to improve numerical precision when p-value approaches zero. Defaults to FALSE.

Value

A list with class "htest" containing:

statistic

The Upsilon test statistic.

parameter

The degrees of freedom (k - 1).

p.value

The p-value of the test.

estimate

The effect size.

method

A character string indicating the method used.

data.name

A character string giving the name(s) of the data.

observed

The observed counts.

expected

The expected counts.

residuals

The Pearson residuals.

p.normalized

The probability vector used (after rescaling if applicable).

Examples

library("Upsilon")

# Test against uniform distribution
counts <- c(10, 20, 30)
upsilon.gof.test(counts)

Upsilon documentation built on March 7, 2026, 5:07 p.m.