
Calling Sequence


ChiSquareSuitableModelTest(X, F, options)


Parameters


X



observed data sample

F



function, algebraic; probability distribution or random variable to match data against

options



(optional) equation(s) of the form option=value where option is one of bins, fittedparameters, level, output, range, or summarize; specify options for the ChiSquareSuitableModelTest function





Description


•

The ChiSquareSuitableModelTest function performs the chisquare suitable model test on an observed data sample against a known random variable or probability distribution. The test attempts to determine if the given sample can be considered to have been drawn from the given random variable or probability distribution by constructing probability categories and applying a goodnessoffit test

•

The first parameter X is a data set of observed data to use in the analysis.

•

The second parameter F is a random variable or probability distribution that is compared to the observed data set. If any parameters are symbolic, then MaximumLikelihoodEstimate is used to estimate them. This is taken into account when computing the degrees of freedom; see the description of the fittedparameters option.

•

As much as possible, the bins are chosen so that the expected number of points in each bin is the same, because if there are bins where this number is very small, the test does not perform well. This is relatively straightforward if F describes a continuous random variable, but if it is a discrete random variable this is not the case.



Options



The options argument can contain one or more of the options shown below.

•

bins='deduce' or posint


This option indicates the number of bins to use when categorizing data from X and probabilities from F. If set to 'deduce' (default), the function attempts to determine a reasonable value for this option.


If F describes a discrete random variable, the final number of bins may not be exactly equal to the value of the option given.

•

fittedparameters=nonnegative integer


The degreesoffreedom parameter of the chisquare distribution is by default set equal to $NP1$, where $N$ is the number of bins used and $P$ is the number of parameters fitted using MaximumLikelihoodEstimate as described above. This is correct if these are the only fitted parameters. For example, to test whether a data sample comes from a standard normal distribution (with parameters $\mathrm{\mu}=0$ and $\mathrm{\sigma}=1$), you would submit a standard normal distribution as F, and Maple would use $P=0$ above, which is correct. But if the parameters of the distribution have been fitted before the call to ChiSquareSuitableModelTest, then those parameters should be counted. For example, if you estimate that the mean of the data is $9.3$ and the standard deviation is $1.7$, you could submit a $\mathrm{NormalDistribution}\left(9.3\,1.7\right)$ to ChiSquareSuitableModelTest; but it would use $P=0$ in the formula above. The value of $P$ can be overridden using the fittedparameters option. In this example, you would supply fittedparameters = 2.


This option is used to specify the level of the analysis (minimum criteria for the observed data to be considered wellfit to the expected data). By default, this value is 0.05.

•

output='report', 'statistic', 'pvalue', 'criticalvalue', 'distribution', 'hypothesis', or list('statistic', 'pvalue', 'criticalvalue', 'distribution', 'hypothesis')


This option is used to specify the desired format of the output from the function. If 'report' is specified then a module containing all output from this test is returned. If a single parameter name is specified other than 'report' then that quantity alone is returned. If a list of parameter names is specified then a list containing those quantities in the specified order will be returned.

•

range='deduce' or range


This option indicates the range to use when considering data values  data outside of the range is discarded during processing. If set to 'deduce' (default), the function attempts to determine a suitable range.

•

summarize= 'true', 'false', 'embed'


This option controls the display of a printed or embedded summary for the hypothesis test. Unlike the output option, the displayed summary is not assignable output.



Notes


•

This test generates a complete report of all calculations in the form of a userinfo message. In order to access this report, specify infolevel[Statistics] := 1 or use the summarize option.



Examples


Initialize an array of data
>

S := Sample(Uniform(0,1), 100):

Perform the suitable model test on this sample. The null hypothesis in both cases is that the data came from the specific distribution given, with the given parameter values.
>

ChiSquareSuitableModelTest(S, Uniform(0,1), bins=10, summarize=embed):


Null Hypothesis:

Sample was drawn from specified probability distribution

Alternative Hypothesis:

Sample was not drawn from specified probability distribution

Bins

Degrees of Freedom

Distribution

Computed Statistic

Computed pvalue

Critical Value

${10.}$

${9.}$

${\mathrm{ChiSquare}}{}\left({9}\right)$

${4.40000}$

${0.883171}$

${16.9190}$




Result:

Accepted: This statistical test does not provide enough evidence to conclude that the null hypothesis is false.


>

ChiSquareSuitableModelTest(S, Normal(0,1), bins=10, summarize=true);

ChiSquare Test for Suitable Probability Model
 

 
Null Hypothesis:
Sample was drawn from specified probability distribution
 
Alt. Hypothesis:
Sample was not drawn from specified probability distribution
 
Distribution: ChiSquare(9)
 
Computed Statistic: 169.0000000
 
Critical Values: 16.9189774487099
 
Result: [Rejected]
This statistical test provides evidence that the null hypothesis is false.
 
${\mathrm{hypothesis}}{=}{\mathrm{false}}{,}{\mathrm{criticalvalue}}{=}{16.9189774487099}{,}{\mathrm{distribution}}{=}{\mathrm{ChiSquare}}{}\left({9}\right){,}{\mathrm{pvalue}}{=}{0.}{,}{\mathrm{statistic}}{=}{169.0000000}$
 (1) 
As an alternative to using the summarize option, setting infolevel[Statistics] := 1 also returns the printed summary.
>

infolevel[Statistics] := 1:

If we test whether the data could come from any uniform or normal distribution, we get different numbers, and the test is no longer able to exclude the possibility that the data came from a normal distribution.
>

ChiSquareSuitableModelTest(S, Uniform(a,b), bins=10);

ChiSquare Test for Suitable Probability Model
 

 
Null Hypothesis:
Sample was drawn from specified probability distribution
 
Alt. Hypothesis:
Sample was not drawn from specified probability distribution
 
Model Specialization: [a = .1190e1, b = .9706]
 
Distribution: ChiSquare(7)
 
Computed Statistic: 5.600000000
 
Computed pvalue: .587151103869373
 
Critical Values: 14.0671405764057
 
Result: [Accepted]
This statistical test does not provide enough evidence to conclude that the null hypothesis is false.
 
${\mathrm{hypothesis}}{=}{\mathrm{true}}{,}{\mathrm{criticalvalue}}{=}{14.0671405764057}{,}{\mathrm{distribution}}{=}{\mathrm{ChiSquare}}{}\left({7}\right){,}{\mathrm{pvalue}}{=}{0.587151103869373}{,}{\mathrm{statistic}}{=}{5.600000000}$
 (2) 
>

ChiSquareSuitableModelTest(S, Normal(a,b), bins=10);

ChiSquare Test for Suitable Probability Model
 

 
Null Hypothesis:
Sample was drawn from specified probability distribution
 
Alt. Hypothesis:
Sample was not drawn from specified probability distribution
 
Model Specialization: [a = .5280, b = .2955]
 
Distribution: ChiSquare(7)
 
Computed Statistic: 11.80000000
 
Computed pvalue: .10733081190306
 
Critical Values: 14.0671405764057
 
Result: [Accepted]
This statistical test does not provide enough evidence to conclude that the null hypothesis is false.
 
${\mathrm{hypothesis}}{=}{\mathrm{true}}{,}{\mathrm{criticalvalue}}{=}{14.0671405764057}{,}{\mathrm{distribution}}{=}{\mathrm{ChiSquare}}{}\left({7}\right){,}{\mathrm{pvalue}}{=}{0.107330811903060}{,}{\mathrm{statistic}}{=}{11.80000000}$
 (3) 
If we obtain the parameters for the distribution, from the data set, we need to specify this using the fittedparameters option.
>

X := RandomVariable(Normal(Mean(S), StandardDeviation(S)));

${X}{\u2254}{\mathrm{\_R6}}$
 (4) 
>

ChiSquareSuitableModelTest(S, X, bins=10, fittedparameters=2);

ChiSquare Test for Suitable Probability Model
 

 
Null Hypothesis:
Sample was drawn from specified probability distribution
 
Alt. Hypothesis:
Sample was not drawn from specified probability distribution
 
Distribution: ChiSquare(7)
 
Computed Statistic: 10.20000000
 
Computed pvalue: .177520137810359
 
Critical Values: 14.0671405764057
 
Result: [Accepted]
This statistical test does not provide enough evidence to conclude that the null hypothesis is false.
 
${\mathrm{hypothesis}}{=}{\mathrm{true}}{,}{\mathrm{criticalvalue}}{=}{14.0671405764057}{,}{\mathrm{distribution}}{=}{\mathrm{ChiSquare}}{}\left({7}\right){,}{\mathrm{pvalue}}{=}{0.177520137810359}{,}{\mathrm{statistic}}{=}{10.20000000}$
 (5) 
Note that the $p$value is slightly different from the previous example, because the maximum likelihood estimate for the parameter $\mathrm{\mu}$ is the uncorrected sample standard deviation, in contrast to the result of the $\mathrm{StandardDeviation}$ command: that is the corrected sample standard deviation (the square root of the unbiased estimator for the variance).


References



Kanju, 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 F parameter was updated in Maple 18.

•

The fittedparameters option was introduced in Maple 18.

•

The Statistics[ChiSquareSuitableModelTest] command was updated in Maple 2016.

•

The summarize option was introduced in Maple 2016.



