Student[Statistics] - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Education : Student Packages : Statistics : Hypothesis Tests : Student/Statistics/ChiSquareGoodnessOfFitTest

Student[Statistics]

 ChiSquareGoodnessOfFitTest
 apply the chi-square test for goodness-of-fit

 Calling Sequence ChiSquareGoodnessOfFitTest(Ob, Ex, level_option, fitparameters_option, output_option)

Parameters

 Ob - data sample of categorized observed data Ex - data sample of categorized expected data level_option - (optional) equation of the form level=float. fitparameters_option - (optional) equation of the form fitparameters=posint. output_option - (optional) equation of the form output=x where x is report, plot, or both

Description

 • The ChiSquareGoodnessOfFitTest function computes the chi-square test for goodness-of-fit. This tests whether an observed sample follows the distribution specified by the expected sample.
 • The first parameter Ob is a data sample of categorized observed data; that is, each entry of the sample is a count of observations of a particular category, as in a histogram. This parameter must have the same length as Ex.
 • The second parameter Ex is a data sample of categorized expected data. Each entry of Ex is an expected count of observations, as in a histogram, just like with Ob. The categories, or bins of the histograms, are expected to be the same for both samples. In particular, the samples must have the same length.
 • level=float
 This option is used to specify the level of the analysis (minimum criteria for the observed data to be considered well-fit to the expected data).  By default, this value is 0.05.
 • fitparameters=posint
 This option is used to specify if this goodness-of-fit test is used to indicate the number of categories used when fitting this data to a distribution. A positive value for this parameter negatively affects the number of degrees of freedom used in the calculation, and so should be no greater than rtable_num_elems(Ex)-1.
 • To compare observed samples against a distribution rather than a categorized data set, the chi-square suitable model test should be applied instead.
 • If the option output is not included or is specified to be output=report, then the function will return a report. If output=plot is specified, then the function will return a plot of the sample test. If output=both is specified, then both the report and the plot will be returned.

Examples

 > with(Student[Statistics]):

Specify the matrices of categorized data values.

 > Ob1 := [25, 17, 15, 23, 24, 16]:
 > Ex1 := [20, 20, 20, 20, 20, 20]:

Perform the goodness-of-fit test upon this sample.

 > ChiSquareGoodnessOfFitTest(Ob1, Ex1, level=.05);
 Chi-Square Test for Goodness-of-Fit ----------------------------------- Null Hypothesis: Observed sample does not differ from expected sample Alt. Hypothesis: Observed sample differs from expected sample   Categories:              6 Distribution:            ChiSquare(5) Computed Statistic:      5.000000000 Computed p-value:        .415879723998286 Critical Values:         11.0704974062099   Result: [Accepted] This statistical test does not provide enough evidence to conclude that the null hypothesis is false.
 $\left[{\mathrm{hypothesis}}{=}{\mathrm{true}}{,}{\mathrm{criticalvalue}}{=}{11.0704974062099}{,}{\mathrm{distribution}}{=}{\mathrm{ChiSquare}}{}\left({5}\right){,}{\mathrm{pvalue}}{=}{0.415879723998286}{,}{\mathrm{statistic}}{=}{5.000000000}\right]$ (1)

Another example.

 > Ob2 := [1, 2, 3, 2, 2, 2, 4, 1, 6]:
 > Ex2 := [5, 2, 2, 1, 1, 1, 8, 5, 2]:
 > ChiSquareGoodnessOfFitTest(Ob2, Ex2);
 Chi-Square Test for Goodness-of-Fit ----------------------------------- Null Hypothesis: Observed sample does not differ from expected sample Alt. Hypothesis: Observed sample differs from expected sample   Categories:              9 Distribution:            ChiSquare(8) Computed Statistic:      19.90000000 Computed p-value:        .0107210773034122 Critical Values:         15.5073130558655   Result: [Rejected] This statistical test provides evidence that the null hypothesis is false.
 $\left[{\mathrm{hypothesis}}{=}{\mathrm{false}}{,}{\mathrm{criticalvalue}}{=}{15.5073130558655}{,}{\mathrm{distribution}}{=}{\mathrm{ChiSquare}}{}\left({8}\right){,}{\mathrm{pvalue}}{=}{0.0107210773034122}{,}{\mathrm{statistic}}{=}{19.90000000}\right]$ (2)

If the output=plot option is included, then a plot will be returned.

 > ChiSquareGoodnessOfFitTest(Ob2, Ex2, output = plot);

If the output=both option is included, then both a report and a plot will be returned.

 > report,graph:=ChiSquareGoodnessOfFitTest(Ob2, Ex2, output = both):
 Chi-Square Test for Goodness-of-Fit ----------------------------------- Null Hypothesis: Observed sample does not differ from expected sample Alt. Hypothesis: Observed sample differs from expected sample   Categories:              9 Distribution:            ChiSquare(8) Computed Statistic:      19.90000000 Computed p-value:        .0107210773034122 Critical Values:         15.5073130558655   Result: [Rejected] This statistical test provides evidence that the null hypothesis is false. Histogram Type:  default Data Range:      1 .. 6 Bin Width:       1/6 Number of Bins:  30 Frequency Scale: relative Histogram Type:  default Data Range:      1 .. 8 Bin Width:       7/30 Number of Bins:  30 Frequency Scale: relative
 > report;
 $\left[{\mathrm{hypothesis}}{=}{\mathrm{false}}{,}{\mathrm{criticalvalue}}{=}{15.5073130558655}{,}{\mathrm{distribution}}{=}{\mathrm{ChiSquare}}{}\left({8}\right){,}{\mathrm{pvalue}}{=}{0.0107210773034122}{,}{\mathrm{statistic}}{=}{19.90000000}\right]$ (3)
 > graph;

References

 Kanji, Gopal K. 100 Statistical Tests. London: SAGE Publications Ltd., 1994.
 Sheskin, David J. Handbook of Parametric and Nonparametric Statistical Procedures. London: CRC Press, 1997.

Compatibility

 • The Student[Statistics][ChiSquareGoodnessOfFitTest] command was introduced in Maple 18.
 • For more information on Maple 18 changes, see Updates in Maple 18.