calc_ftest

sherpa.utils.calc_ftest(dof1, stat1, dof2, stat2)

Compare two models using the F test.

The F-test is a model comparison test; that is, it is a test used to select from two competing models which best describes a particular data set. A model comparison test statistic, T, is created from the best-fit statistics of each fit; as with all statistics, it is sampled from a probability distribution p(T). The test significance is defined as the integral of p(T) from the observed value of T to infinity. The significance quantifies the probability that one would select the more complex model when in fact the null hypothesis is correct. See also calc_mlr.

Parameters:
  • dof1 (int) – degrees of freedom of the simple model
  • stat1 (number) – best-fit chi-square statistic value of the simple model
  • dof2 (int) – degrees of freedom of the complex model
  • stat2 (number) – best-fit chi-square statistic value of the complex model
Returns:

sig – The significance, or p-value. A standard threshold for selecting the more complex model is significance < 0.05 (the ‘95% criterion’ of statistics).

Return type:

number

See also

calc_mlr()
Compare two models using the Maximum Likelihood Ratio test.
incbet()
Calculate the incomplete Beta function.

Notes

The F test uses the ratio of the reduced chi2, which follows the F-distribution, (stat1/dof1)/(stat2/dof2). The incomplete Beta function is used to calculate the integral of the tail of the F-distribution.

The F test should only be used when:

  • the simpler of the two models is nested within the other; that is, one can obtain the simpler model by setting the extra parameters of the more complex model (often to zero or one);
  • the extra parameters have values sampled from normal distributions under the null hypothesis (i.e., if one samples many datasets given the null hypothesis and fits these data with the more complex model, the distributions of values for the extra parameters must be Gaussian);
  • those normal distributions are not truncated by parameter space boundaries;
  • the best-fit statistics are sampled from the chi-square distribution.

See Protassov et al. 2002 [1] for more discussion.

References

[1]Protassov et al., Statistics, Handle with Care: Detecting Multiple Model Components with the Likelihood Ratio Test, Astrophysical Journal, vol 571, pages 545-559, 2002, http://adsabs.harvard.edu/abs/2002ApJ...571..545P

Examples

In this example, the simple model has 5 degrees of freedom and a chi-square statistic of 7.73, while the complex model has 8 degrees of freedom and a chi-square statistic of 8.94. The F test does not provide any evidence that the complex model is a better fit to the data than the simple model since the result is much larger than 0.

>>> calc_ftest(5, 7.73, 8, 8.94)
0.32480691622314933