Chitest: Difference between revisions
Jump to navigation
Jump to search
imported>Jeremy (Importing text file) |
imported>Jeremy |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Line 18: | Line 17: | ||
* '''distribution''' = Optional distribution name to assume as the parent distribution for thesample. If this argument is missing, then 'normal' is assumed. This argument must be in single quotes and the name may be abbreviated. | * '''distribution''' = Optional distribution name to assume as the parent distribution for thesample. If this argument is missing, then 'normal' is assumed. This argument must be in single quotes and the name may be abbreviated. | ||
* '''classes''' = Optional argument naming the number of equal probability intervals for which counts should be collected for the test. If this argument is missing, then the number of classes is taken to be | * '''classes''' = Optional argument naming the number of equal probability intervals for which counts should be collected for the test. If this argument is missing, then the number of classes is taken to be | ||
::<math>\left[ \frac{ max\{x\}-min\{x\} }{ 3.5 var\{x\}} length\{x\} \right ] +1</math> | |||
:where {x} is the smallest integer z such that z <= x. If specified, the number of classes may not be greater than the length of the data vector. | |||
====Outputs==== | ====Outputs==== | ||
Line 28: | Line 25: | ||
The return value is a structure with fields: | The return value is a structure with fields: | ||
* '''chi2''' = value of the test statistic | * '''distname''' = distribution name for the given fit | ||
* '''function''' = function used to evaluate this distribution | |||
* '''chi2''' = value of the test statistic, <math>\chi^2</math> | |||
* '''pval''' = ''p''-value associated with the test statistic | * '''pval''' = ''p''-value associated with the test statistic | ||
* '''df''' = degrees of freedom of the test | * '''df''' = degrees of freedom of the test | ||
* '''classes''' = number of intervals for which counts are obtained | * '''classes''' = number of intervals for which counts are obtained | ||
* '''parameters''' = maximum likelihood estimates | * '''parameters''' = maximum likelihood estimates | ||
* '''E''' = expected counts for the classes | * '''E''' = expected counts for the classes | ||
* '''O''' = observed counts for the classes | * '''O''' = observed counts for the classes | ||
Line 46: | Line 39: | ||
===Examples=== | ===Examples=== | ||
chitest(x) | chitest(x) | ||
chitest(x,'exp') | |||
chitest(x,'exp') | chitest(x,'logistic',12) | ||
chitest(x,'logistic',12) | |||
===See Also=== | ===See Also=== | ||
[[distfit]], [[kstest]], [[plotcqq]], [[plotkd]], [[plotqq]] | [[chilimit]], [[distfit]], [[kstest]], [[plotcqq]], [[plotkd]], [[plotqq]] |
Latest revision as of 13:14, 30 May 2012
Purpose
Uses chi-squared to test if sample has a specific distribution.
Synopsis
- vals = chitest(x,distname,classes)
Description
Assesses how well a particular distribution fits the data (x).
Inputs
- x = The name of a matrix (column vector) in which the sample data is stored.
- distribution = Optional distribution name to assume as the parent distribution for thesample. If this argument is missing, then 'normal' is assumed. This argument must be in single quotes and the name may be abbreviated.
- classes = Optional argument naming the number of equal probability intervals for which counts should be collected for the test. If this argument is missing, then the number of classes is taken to be
- where {x} is the smallest integer z such that z <= x. If specified, the number of classes may not be greater than the length of the data vector.
Outputs
The return value is a structure with fields:
- distname = distribution name for the given fit
- function = function used to evaluate this distribution
- chi2 = value of the test statistic,
- pval = p-value associated with the test statistic
- df = degrees of freedom of the test
- classes = number of intervals for which counts are obtained
- parameters = maximum likelihood estimates
- E = expected counts for the classes
- O = observed counts for the classes
Note: If a sample contains all negative values, then some of the overlay distributions will not be drawn as they are not applicable. If only some of the sample is made up of negative values, these values are ignored in obtaining the maximum likelihood estimates and subsequent results.
Examples
chitest(x) chitest(x,'exp') chitest(x,'logistic',12)