Learn R Programming

r6qualitytools (version 1.0.1)

adSim: adSim: Bootstrap-based Anderson-Darling Test for Univariate

Description

Performs the Anderson-Darling test for univariate distributions with an option for bootstrap-based p-value determination. It also allows p-value determination using tabled critical values.

Usage

adSim(x, distribution = "normal", b = 10000)

Value

A list containing the following components:

distribution

The distribution for which the Anderson-Darling test was applied.

parameter_estimation

The estimated parameters for the distribution.

Anderson_Darling

The value of the Anderson-Darling test statistic.

p_value

The corresponding p-value, either simulated or from tabled values.

critical_values

The critical values corresponding to the 0.75, 0.90, 0.95, 0.975, and 0.99 quantiles, either simulated or from tables.

simAD

The bootstrap-based Anderson-Darling distribution.

Arguments

x

A numeric vector.

distribution

A character string specifying the distribution to test. Recognized distributions include `cauchy`, `exponential`, `gumbel`, `gamma`, `log-normal`, `lognormal`, `logistic`, `normal`, and `weibull`.

b

A numeric value indicating the number of bootstraps to perform. Allowed values range from 1000 to 1,000,000. If b is set to NA, the Anderson-Darling test will be applied without simulation. Note that higher values of b can significantly increase computation time, potentially taking hours depending on the distribution, sample size, and computer system.

Details

The function first estimates the parameters for the tested distribution, typically using Maximum-Likelihood Estimation (MLE) via the FitDistr function. For normal and log-normal distributions, parameters are estimated by the mean and standard deviation. Cauchy distribution parameters are fitted by the sums of the weighted order statistic when using tabled critical values. The Anderson-Darling statistic is then calculated based on these estimated parameters.

Parametric bootstrapping generates the distribution of the Anderson-Darling test statistic, which is used to determine the p-value. This simulation-based Anderson-Darling distribution and its corresponding critical values for selected quantiles can be printed. If simulation is not performed, a p-value is obtained from tabled critical values, although no exact expressions exist except for the log-normal, normal, and exponential distributions.

Examples

Run this code
x <- rnorm(25, 32, 2)
adSim(x)
adSim(x, "logistic", 2000)
adSim(x, "cauchy", NA)
adSim(x, "exponential", 2000)
adSim(x, "gumbel", 2000)

Run the code above in your browser using DataLab