Chitest
Jump to navigation
Jump to search
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)