hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_nonpar_gofstat_anddar_normal (g08ck)

Purpose

nag_nonpar_gofstat_anddar_normal (g08ck) calculates the Anderson–Darling goodness-of-fit test statistic and its probability for the case of a fully-unspecified Normal distribution.

Syntax

[ybar, yvar, a2, aa2, p, ifail] = g08ck(issort, y, 'n', n)
[ybar, yvar, a2, aa2, p, ifail] = nag_nonpar_gofstat_anddar_normal(issort, y, 'n', n)

Description

Calculates the Anderson–Darling test statistic A2A2 (see nag_nonpar_gofstat_anddar (g08ch)) and its upper tail probability for the small sample correction:
Adjusted ​ A2 = A2 (1 + 0.75 / n + 2.25 / n2) ,
Adjusted ​ A2 = A2 ( 1+0.75/n+ 2.25/n2 ) ,
for nn observations.

References

Anderson T W and Darling D A (1952) Asymptotic theory of certain ‘goodness-of-fit’ criteria based on stochastic processes Annals of Mathematical Statistics 23 193–212
Stephens M A and D'Agostino R B (1986) Goodness-of-Fit Techniques Marcel Dekker, New York

Parameters

Compulsory Input Parameters

1:     issort – logical scalar
Set issort = trueissort=true if the observations are sorted in ascending order; otherwise the function will sort the observations.
2:     y(n) – double array
n, the dimension of the array, must satisfy the constraint n > 1n>1.
yiyi, for i = 1,2,,ni=1,2,,n, the nn observations.
Constraint: if issort = trueissort=true, the values must be sorted in ascending order.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array y.
nn, the number of observations.
Constraint: n > 1n>1.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     ybar – double scalar
The maximum likelihood estimate of mean.
2:     yvar – double scalar
The maximum likelihood estimate of variance.
3:     a2 – double scalar
A2A2, the Anderson–Darling test statistic.
4:     aa2 – double scalar
The adjusted A2A2.
5:     p – double scalar
pp, the upper tail probability for the adjusted A2A2.
6:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
Constraint: n > 1n>1.
  ifail = 3ifail=3
issort = trueissort=true and the data in y is not sorted in ascending order.
  ifail = 999ifail=-999
Dynamic memory allocation failed.

Accuracy

Probabilities are calculated using piecewise polynomial approximations to values estimated by simulation.

Further Comments

None.

Example

function nag_nonpar_gofstat_anddar_normal_example
y = [0.3131132, 0.2520412, 1.5788841, 1.4416712,-0.8246043,-1.6466685, ...
     0.7943184, 1.2874915,-0.8347250, 0.3352505, 0.9434467, 2.1099520, ...
    -0.2801654,-0.7843009, 0.6218187, 2.0963809, 1.7170403,-0.1350142, ...
     0.7982763,-0.2980977, 1.2283043, 1.5576090,-0.4828757, 2.6070754, ...
     0.1213996, 0.1431621];
% Let nag_nonpar_gofstat_anddar_normal sort the data
issort = false;

% Calculate a-squared and probability
[ybar, yvar, a2, aa2, p, ifail] = nag_nonpar_gofstat_anddar_normal(issort, y);

% Results
fprintf('\nH0: data from normal distribution with mean %10.4e and variance %10.4e\n', ybar, yvar);
fprintf('Test statistic, A-squared: %8.4f\n', a2);
fprintf('Adjusted A-squared:        %8.4f\n', aa2);
fprintf('Upper tail probability:    %8.4f\n', p);
 

H0: data from normal distribution with mean 5.6388e-01 and variance 1.1386e+00
Test statistic, A-squared:   0.1660
Adjusted A-squared:          0.1713
Upper tail probability:      0.9312

function g08ck_example
y = [0.3131132, 0.2520412, 1.5788841, 1.4416712,-0.8246043,-1.6466685, ...
     0.7943184, 1.2874915,-0.8347250, 0.3352505, 0.9434467, 2.1099520, ...
    -0.2801654,-0.7843009, 0.6218187, 2.0963809, 1.7170403,-0.1350142, ...
     0.7982763,-0.2980977, 1.2283043, 1.5576090,-0.4828757, 2.6070754, ...
     0.1213996, 0.1431621];
% Let g08ck sort the data
issort = false;

% Calculate a-squared and probability
[ybar, yvar, a2, aa2, p, ifail] = g08ck(issort, y);

% Results
fprintf('\nH0: data from normal distribution with mean %10.4e and variance %10.4e\n', ybar, yvar);
fprintf('Test statistic, A-squared: %8.4f\n', a2);
fprintf('Adjusted A-squared:        %8.4f\n', aa2);
fprintf('Upper tail probability:    %8.4f\n', p);
 

H0: data from normal distribution with mean 5.6388e-01 and variance 1.1386e+00
Test statistic, A-squared:   0.1660
Adjusted A-squared:          0.1713
Upper tail probability:      0.9312


PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013