Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: stats
See also: jarber

Quantlet: anddar
Description: performs an Anderson-Darling test for a goodness of fit for normal, exponential or uniform distributions.

Reference(s):

Usage: {A2,accept}=anddar(data,distribution,par1,par2{,alpha{,opt}})
Input:
data n x 1 vector, data
distribution string, distribution of hypothesis H0: "normal" for a normal distribution "exponential" for an exponential distribution "uniform" for a uniform distribution
par1 scalar or NaN, first parameter of the distribution under H0, representing the mean mu for "normal", the mean gamma for "exponential" and the lower boundary a for "uniform"
par2 scalar or NaN, second parameter of the distribution under H0, representing the variance sigma2 for "normal", nothing (NaN) for "exponential" since it has only one parameter and the upper boundary b for "uniform"
alpha (optional) scalar, critical level of the test, possible values are 0.1,0.05,0.025,0.01; if alpha is not given, 0.05 will be set as a default; if not equal to the possible values, the closest of them is used
opt (optional) string, possible options are: "notext" (no text output is generated), "text" (text output is generated); default value is "text"

Note:

Example:
library("stats")
randomize(6)
results=anddar(normal(100),"normal",0,1,0.15)

Result:
Contents of _tmp
[ 1,] "=====================================================                    "
[ 2,] "ANDERSON - DARLING TEST"
[ 3,] "=====================================================                    "
[ 4,] "Empirical characteristics of the data:                          "
[ 5,] "     n    mean    var      min     max"
[ 6,] "    100  0.1014  0.9435  -2.0018  2.5766"
[ 7,] "=====================================================                    "
[ 8,] "Hypothesis of:  normal distribution with                          "
[ 9,] "parameters: 0.0000 , 1.0000"
[10,] "=====================================================                    "
[11,] "critical level alpha = 0.10   0.05   0.025  0.01                    "
[12,] "critical values      = 1.933  2.492  3.070  3.857"
[13,] "=====================================================                    "
[14,] "Test statistic A2 = 0.5762"
[15,] "Reject H0 at the level alpha if A2 > c.v.                                    "
[16,] "=====================================================                    "
[17,] "!!! Decision: ACCEPT at the level 0.100 !!!          "
[18,] "=====================================================                    "
[19,] ""
Example:
library("stats")
randomize(6)
results=anddar(normal(100),"normal",0,1,"notext")
results

Result:
Contents of results.A2
[1,]  0.57622

Contents of results.accept
[1,]        1
Example:
library("stats")
randomize(6)
data=-log(1-uniform(10000))*5  ; exponential data with mean 5
results=anddar(data,"exponential",2,NaN)
results

Result:
Contents of _tmp
[ 1,] "====================================================="
[ 2,] "ANDERSON - DARLING TEST"
[ 3,] "====================================================="
[ 4,] "Empirical characteristics of the data:"
[ 5,] "     n    mean    var      min     max"
[ 6,] "  10000  4.8734  23.6509  0.0003  40.9731"
[ 7,] "====================================================="
[ 8,] "Hypothesis of:  exponential distribution with"
[ 9,] "parameters: 2.0000 , +NAN"
[10,] "====================================================="
[11,] "critical level alpha = 0.10   0.05   0.025  0.01"
[12,] "critical values      = 1.933  2.492  3.070  3.857"
[13,] "====================================================="
[14,] "Test statistic A2 = 3948.7272"
[15,] "Reject H0 at the level alpha if A2 > c.v."
[16,] "====================================================="
[17,] "!!! Decision: REJECT at the level 0.050 !!!          "
[18,] "=====================================================                    "
[19,] ""

Contents of results.A2
[1,]   3948.7

Contents of results.accept
[1,]        0



Author: M. Hanek, 20020524 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006