Chitest: Difference between revisions
Jump to navigation
Jump to search
imported>Jeremy (Importing text file) |
imported>Jeremy |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Uses chi-squared to test if sample has a specific distribution. | Uses chi-squared to test if sample has a specific distribution. | ||
===Synopsis=== | ===Synopsis=== | ||
:vals = chitest(x,distname,''classes'') | :vals = chitest(x,distname,''classes'') | ||
===Description=== | ===Description=== | ||
Assesses how well a particular distribution fits the data (x). | Assesses how well a particular distribution fits the data (x). | ||
* x = The name of a matrix (column vector) in which the sample data is stored. | ====Inputs==== | ||
* 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 | * '''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 | |||
::<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==== | |||
The return value is a structure with fields: | The return value is a structure with fields: | ||
* chi2 = value of the test statistic | |||
* pval = ''p''-value associated with the test statistic | * '''distname''' = distribution name for the given fit | ||
* df = degrees of freedom of the test | * '''function''' = function used to evaluate this distribution | ||
* classes = number of intervals for which counts are obtained | * '''chi2''' = value of the test statistic, <math>\chi^2</math> | ||
* parameters = maximum likelihood estimates | * '''pval''' = ''p''-value associated with the test statistic | ||
* E = expected counts for the classes | * '''df''' = degrees of freedom of the test | ||
* O = observed counts for the classes | * '''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. | '''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=== | ===Examples=== | ||
chitest(x) | |||
chitest(x,'exp') | chitest(x) | ||
chitest(x,'logistic',12) | chitest(x,'exp') | ||
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)