Calculates chi-square statistics for one- and two-way tables (A.D. Todd & P.K. Leech).
Options
PRINT = string tokens |
Output required (test , probability , fittedvalues , tchisquare ); default test , prob |
---|---|
METHOD = string token |
Method for calculating chi-square (pearson , maximumlikelihood ); default pear |
GOODNESSOFFIT = string token |
Whether to carry out a goodness-of-fit test for the DATA values against a supplied set of FITTEDVALUES (yes , no ); default no |
Parameters
DATA = tables |
Table containing observed data |
---|---|
CHISQUARE = scalars |
Scalar to save the chi-square value |
DF = scalars |
Scalar to supply or save the degrees of freedom |
PROBABILITY = scalars |
Scalar to save the probability value |
FITTEDVALUES = tables |
Table of expected values |
RESIDUALS = tables |
Table of standardized residuals |
TCHISQUARE = tables |
Table whose cells show the individual contributions to the chi-square value |
Description
The CHISQUARE
procedure calculates chi-square statistics. The DATA
parameter supplies the data values. If these are in a two-way table, CHISQUARE
produces the usual test of association between the row and column factor of the table; if a one-way table is supplied, the statistic assesses whether the different cells of the table contain different proportions of the data. Alternatively, you can set option GOODNESSOFFIT=yes
to request a goodness-of-fit test between the data values and the set of expected values supplied by the FITTEDVALUES
parameter; if you provide the degrees of freedom, using the DF
parameter, the procedure can also calculate the probability value.
The PRINT
option controls the printed output, with the settings: test
to print the chi-square value and degrees of freedom; probability
for the probability value; fittedvalues
data, fitted (expected) values and standardized residuals; and tchisquare
to show the contribution of each cell of the table to the chi-square value. By default, the statistic is calculated by the usual Pearson approximation (see the Method section), but you can set option METHOD=likelihood
to calculate the chi-square by maximum likelihood (using the Genstat facilities for generalized linear models).
Parameters CHISQUARE
, DF
, PROBABILITY
, FITTEDVALUES
, RESIDUALS
and TCHISQUARE
allow the results to be saved in appropriate Genstat data structures.
Options: PRINT
, METHOD
, GOODNESSOFFIT
.
Parameters: DATA
, CHISQUARE
, DF
, PROBABILITY
, FITTEDVALUES
, RESIDUALS
, TCHISQUARE
.
Method
With option METHOD=pearson
, the statistic is calculated by the usual Pearson formula:
chi-square = sum( (o–e) × (o–e) / e ),
where o = observed, and e = expected.
If GOODNESSOFFIT=yes
, the table e is supplied by the FITTEDVALUES
parameter. Otherwise, for a one-way table e is the mean of the DATA
values, while for a two-way table
e = (row total) × (column total) / (total in table).
For METHOD=maximumlikelihood
, CHISQUARE
takes the deviance from fitting a generalized linear model with a log link and a Poisson distribution.
See also
Procedures: CHIPERMTEST
, CATRENDTEST
, CMHTEST
.
Commands for: Basic and nonparametric statistics, Regression analysis.
Example
CAPTION 'CHISQUARE example',!t('1) Data from Snedecor & Cochran (1980)',\ 'Statistical Methods (7th edition), p. 210.'); STYLE=meta,plain FACTOR [LABELS=!T(Ulcer,Cancer,Control); VALUES=3(1...3)] Disease FACTOR [LABELS=!T(O,A,B); VALUES=(1...3)3] BloodTp TABLE [CLASSIFICATION=Disease,BloodTp; VALUES=983,679,134,\ 383,416,84, 2892,2625,570] Cases CHISQUARE Cases CAPTION !t('2) Goodness of fit test: Mead, Curnow & Hasted (1993),',\ 'Statistical Methods in Agriculture & Experimental Biology,',\ 'Chapman & Hall, Example 14.1, p. 306-7. Test that that 3 types',\ 'of cell AA, AS, SS occur in ratio 3:7:3 for total over 5 plants.',\ 'There are 2 df as 1 parameter (total) has been calculated from',\ '3 data values i.e. df=3-1.') FACTOR [LABELS=!t(AA,AS,SS)] Assoc TABLE [CLASSIFICATION=Assoc] Observed,Expratio;\ VALUES=!(152,340,175),!(3,7,3) CALCULATE Expected = SUM(Observed)*Expratio/SUM(Expratio) CHISQUARE [PRINT=test,probability,fitted; GOODNESSOFFIT=yes]\ Observed; DF=2; FITTED=Expected