The function may be called by the names: g08cgc, nag_nonpar_test_chisq or nag_chi_sq_goodness_of_fit_test.
The goodness-of-fit test performed by g08cgc is used to test the null hypothesis that a random sample arises from a specified distribution against the alternative hypothesis that the sample does not arise from the specified distribution.
Given a sample of size , denoted by , drawn from a random variable , and that the data have been grouped into classes,
then the goodness-of-fit test statistic is defined by:
where is the observed frequency of the th class, and is the expected frequency of the th class.
The expected frequencies are computed as
where is the probability that lies in the th class, that is
These probabilities are either taken from a common probability distribution or are supplied by you. The available probability distributions within this function are:
Normal distribution with mean , variance ;
uniform distribution on the interval ;
exponential distribution with probability density function ;
distribution with degrees of freedom; and
gamma distribution with .
You must supply the frequencies and classes. Given a set of data and classes the frequencies may be calculated using g01aec.
g08cgc returns the test statistic, , together with its degrees of freedom and the upper tail probability from the distribution associated with the test statistic. Note that the use of the distribution as an approximation to the distribution of the test statistic improves as the expected values in each class increase.
Conover W J (1980) Practical Nonparametric Statistics Wiley
Kendall M G and Stuart A (1973) The Advanced Theory of Statistics (Volume 2) (3rd Edition) Griffin
Siegel S (1956) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill
1: – IntegerInput
On entry: the number of classes, , into which the data is divided.
2: – const IntegerInput
On entry: must specify the frequency of the th class, , for .
, for .
3: – const doubleInput
On entry: must specify the upper boundary value for the th class, for .
For the exponential, gamma and distributions .
4: – Nag_DistributionsInput
On entry: indicates for which distribution the test is to be carried out.
The Normal distribution is used.
The uniform distribution is used.
The exponential distribution is used.
The distribution is used.
The gamma distribution is used.
You must supply the class probabilities in the array prob.
, , , , or .
5: – const doubleInput
On entry: par must contain the arguments of the distribution which is being tested. If you supply the probabilities (i.e., ) the array par is not referenced.
If a Normal distribution is used then and must contain the mean, , and the variance, , respectively.
If a uniform distribution is used then and must contain the boundaries and respectively.
If an exponential distribution is used then must contain the argument . is not used.
If a distribution is used then must contain the number of degrees of freedom. is not used.
If a gamma distribution is used and must contain the arguments and respectively.
if , ;
if , and ;
if , ;
if , ;
if , and .
6: – IntegerInput
On entry: the number of estimated arguments of the distribution.
7: – const doubleInput
On entry: if you are supplying the probability distribution (i.e., ) then must contain the probability that lies in the th class.
This is a warning that expected values for certain classes are less than . This implies that one cannot be confident that the distribution is a good approximation to the distribution of the test statistic.
The solution obtained when calculating the probability for a certain class for the gamma or distribution did not converge in 600 iterations. The solution may be an adequate approximation.
An expected frequency is equal to zero when the observed frequency is not.
On entry, , .
On entry, .
On entry, .
Constraint: , for .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
The time taken by g08cgc is dependent both on the distribution chosen and on the number of classes, .
The example program applies the goodness-of-fit test to test whether there is evidence to suggest that a sample of 100 observations generated by g05sqc do not arise from a uniform distribution . The class intervals are calculated such that the interval (0,1) is divided into five equal classes. The frequencies for each class are calculated using g01aec.