ADgof {Dogoftest}R Documentation

Anderson-Darling Goodness-of-Fit Test for a Specified Distribution

Description

Performs the Anderson-Darling (AD) goodness-of-fit test for a given univariate distribution. The function computes the AD statistic and returns an approximate p-value based on adjusted formulas.

Usage

ADgof(
  x,
  dist = c("norm", "exp", "unif", "lnorm", "weibull", "gamma", "t", "chisq"),
  ...,
  eps = 1e-15
)

Arguments

x

A numeric vector of sample observations.

dist

A character string specifying the null distribution. Options are "norm", "exp", "unif", "lnorm", "weibull", "gamma", "t", and "chisq".

...

Additional named parameters passed to the corresponding distribution functions (e.g., mean, sd, rate, df, etc.).

eps

A small positive constant to avoid log(0) during computation (default: 1e-15).

Details

This implementation supports several common distributions. Parameters of the null distribution must be supplied via .... The p-value is calculated using the approximations suggested by Stephens (1986) and other refinements. For small samples or custom distributions, a bootstrap version may be preferred.

Value

A list of class "htest" with components:

statistic

The value of the Anderson-Darling test statistic.

p.value

The approximate p-value computed using adjustment formulas.

method

A description of the test performed.

data.name

The name of the input data.

Examples

set.seed(123)
x1 <- rnorm(500, mean = 5, sd = 2)
ADgof(x1, dist = "norm", mean = 5, sd = 2)

x2 <- rexp(400, rate = 1.5)
ADgof(x2, dist = "exp")
ADgof(x2, dist = "exp", rate = 1.5)

x3 <- runif(300, min = -2, max = 4)
ADgof(x3, dist = "unif", min = -2, max = 4)

[Package Dogoftest version 0.2 Index]