lilliefors_normality_test
Performs a Lilliefors test for normality.
Synopsis
#include <imsls.h>
float imsls_f_lilliefors_normality_test (int n_observations, float x[], ..., 0)
The type double function is imsls_d_lilliefors_normality_test.
Required Arguments
int n_observations (Input)
Number of observations. Argument n_observations must be greater than 4.
float x[] (Input)
Array of size n_observations containing the observations.
Return Value
The p-value for the Lilliefors test for normality. Probabilities less than 0.01 are reported as 0.01, and probabilities greater than 0.10 for the normal distribution are reported as 0.5.
Synopsis with Optional Arguments
#include <imsls.h>
float imsls_f_lilliefors_normality_test (int n_observations, float x[],
IMSLS_MAX_DIFFERENCE, float *max_difference,
0)
Optional Arguments
IMSLS_MAX_DIFFERENCE, float *max_difference (Output)
The maximum absolute difference between the empirical and the theoretical distributions is returned in max_difference.
Description
This function computes Lilliefors test and its p-value for a normal distribution in which both the mean and variance are estimated. The one-sample, two-sided Kolmogorov-Smirnov statistic D is first computed. The p-value is then computed using an analytic approximation given by Dallal and Wilkinson (1986). Because Dallal and Wilkinson give approximations in the range (0.01, 0.10), if the computed probability of a greater D is less than 0.01, the Lilliefors test by convention calls for rejection and the p-value is set to 0.01. If the computed probability of a greater D is greater than 0.1, by convention the null hypothesis is accepted and the p-value is set to 0.50. Note that because parameters are estimated, p-value in Lilliefors test is not the same as in the Kolmogorov-Smirnov Test.
Observations from a normal distribution should not be tied. If tied observations are found, an informational message is printed. A general reference for the Lilliefors test is Conover (1980). The original reference for the test for normality is Lilliefors (1967).
Example
The data are the head circumference measurements for 50 male infants. The Lilliefors test fails to reject the null hypothesis of normality, i.e., p_value is greater than 0.1.
#include <imsls.h>
#include <stdio.h>
int main()
{
int n_observations = 50;
float x[] = {37.715, 37.89, 37.538, 35.828, 35.039,
34.005, 35.766, 35.337, 37.529, 35.857,
37.827, 35.083, 35.235, 36.782, 35.946,
35.2, 38.995, 36.889, 35.932, 35.835,
38.323, 35.624, 30.925, 37.69, 33.759,
36.697, 39.222, 37.191, 34.814, 36.775,
35.751, 33.163, 35.205, 32.805, 32.517,
37.516, 33.654, 37.382, 36.83, 33.465,
33.613, 35.211, 34.932, 30.645, 35.063,
34.604, 34.666, 33.789, 34.678, 35.123};
float p_value, max_diff;
p_value = imsls_f_lilliefors_normality_test (n_observations, x,
IMSLS_MAX_DIFFERENCE, &max_diff, 0);
printf ("p-value = %11.4f\n", p_value);
printf ("max difference = %f \n", max_diff);
}
Output
p-value = 0.5000
max difference = 0.085558
Warning Errors
IMSLS_TWO_OR_MORE_TIED |
Two or more elements in “x” are tied. |
Fatal Errors
IMSLS_NEED_AT_LEAST_5 |
All but # elements of “x” are missing. At least five non-missing observations are necessary to continue. |
IMSLS_NEG_IN_EXPONENTIAL |
In testing the exponential distribution, an invalid element in “x” is found (“x[]” = #). Negative values are not possible in exponential distributions. |
IMSLS_NO_VARIATION_INPUT |
There is no variation in the input data. All non-missing observations are tied. |