------------------------------------------------------------------------ IMSL Name: CTCHI/DCTCHI (Single/Double precision version) Revised: June 3, 1991 Purpose: Perform a chi-squared analysis of a two-way contingency table. Usage: CALL CTCHI (NROW, NCOL, TABLE, LDTABL, ICMPT, IPRINT, EXPECT, LDEXPE, CHI, LDCHI, CHISQ, STAT, LDSTAT) Arguments: NROW - Number of rows in the table. (Input) NCOL - Number of columns in the table. (Input) TABLE - NROW by NCOL matrix containing the observed counts in the contingency table. (Input) LDTABL - Leading dimension of TABLE exactly as specified in the dimension statement of the calling program. (Input) ICMPT - Computing option. (Input) If ICMPT = 0, all of the values in CHISQ and STAT are computed. ICMPT = 1 means compute only the first 5 values of CHISQ and none of the values in STAT. (All values not computed are set to NaN (not a number).) IPRINT - Printing option. (Input) IPRINT = 0 means no printing is performed. If IPRINT = 1, printing is performed. EXPECT - (NROW+1) by (NCOL+1) matrix containing the expected values of each cell in TABLE, under the null hypothesis, in the first NROW rows and NCOL columns and the marginal totals in the last row and column. (Output) LDEXPE - Leading dimension of EXPECT exactly as specified in the dimension statement in the calling program. (Input) CHI - (NROW+1) by (NCOL+1) matrix containing the contributions to chi-squared for each cell in TABLE in the first NROW rows and NCOL columns. (Output) The last row and column contain the total contribution to chi-squared for that row or column. LDCHI - Leading dimension of CHI exactly as specified in the dimension statement in the calling program. (Input) CHISQ - Vector of length 10 containing chi-squared statistics associated with this contingency table. (Output) I CHISQ(I) 1 Pearson chi-squared statistic 2 Probability of a larger Pearson chi-squared 3 Degrees of freedom for chi-squared 4 Likelihood ratio G**2 (chi-squared) 5 Probability of a larger G**2 6 Exact mean 7 Exact standard deviation The following statistics are based upon the chi-squared statistic CHISQ(1). If ICMPT = 1, NaN (not a number) is reported. I CHISQ(I) 8 Phi 9 Contingency coefficient 10 Cramer's V STAT - 23 by 5 matrix containing statistics associated with this table. (Output) If ICMPT = 1, STAT is not referenced and may be a vector of length 1. Each row of the matrix corresponds to a statistic. ROW STATISTIC 1 Gamma 2 Kendall's tau B 3 Stuart's tau C 4 Somers' D for rows given columns 5 Somers' D for columns given rows 6 Product moment correlation 7 Spearman rank correlation 8 Goodman and Kruskal tau for rows given columns 9 Goodman and Kruskal tau for columns given rows 10 Uncertainty coefficient U (symmetric) 11 Uncertainty U (rows) 12 Uncertainty U (columns) 13 Optimal prediction lambda (symmetric) 14 Optimal prediction lambda (rows) 15 Optimal prediction lambda (columns) 16 Optimal prediction lambda star (rows) 17 Optimal prediction lambda star (columns) 18 Test for linear trend in row probabilities if NROW = 2. If NROW is not 2, a test for linear trend in column probabilities if NCOL = 2. 19 Kruskal-Wallis test for no row effect 20 Kruskal-Wallis test for no column effect 21 Kappa (square tables only) 22 McNemar test of symmetry (square tables only) 23 McNemar one degree of freedom test of symmetry (square tables only) If a statistic cannot be computed, its value is reported as NaN (not a number). The columns are as follows: COLUMN STATISTIC 1 The estimated statistic 2 Its standard error for any parameter value 3 Its standard error under the null hypothesis 4 The t value for testing the null hypothesis 5 p-value of the test in column 4 In the McNemar tests, column 1 contains the statistic, column 2 contains the chi-squared degrees of freedom, column 4 contains the exact p-value (one degree of freedom only), and column 5 contains the chi-squared asymptotic p-value. The Kruskal-Wallis test is the same except no exact p-value is computed. LDSTAT - Leading dimension of STAT exactly as specified in the dimension statement in the calling program. (Input) Remark: Informational errors Type Code 3 1 Twenty percent of the expected values are less than 5. 3 2 The degrees of freedom for chi-squared are greater than 30. The exact mean, standard deviation, and normal distribution function should be used. 3 3 Some expected values are less than 2. Some asymptotic p-values may not be good. 3 4 Some expected values are less than 1. Some asymptotic p-values may not be good. Keywords: Contingency table; G**2; Phi; Cramer's V; Contingency coefficient; Gamma; Kendall's tau; Stuart's tau; Spearman rank correlation; Somers' D; Goodman and Kruskal tau; Uncertainty coefficient; McNemar test; Kappa; Categorical and discrete data analysis GAMS: L9b Chapter: STAT/LIBRARY Categorical and Discrete Data Analysis Page No.: STAT/LIBRARY User's Manual page 483