正在加载图片...
14.4 Contingency Table Analysis of Two Distributions 631 The formula for Cramer's V is V= x2 N min(I-1,J-1) (14.4.4) where I and J are again the numbers of rows and columns,and N is the total number of events.Cramer's V has the pleasant property that it lies between zero and one inclusive,equals zero when there is no association,and equals one only when the association is perfect:All the events in any row lie in one unique column, and vice versa.(In chess parlance,no two rooks,placed on a nonzero table entry, can capture each other. In the case of I=J=2,Cramer's V is also referred to as the phi statistic. The contingency coefficient C is defined as C x2+N (14.4.5) RECIPES It also lies between zero and one,but (as is apparent from the formula)it can never achieve the upper limit.While it can be used to compare the strength of association of two tables with the same I and J,its upper limit depends on I and J.Therefore it can never be used to compare tables of different sizes. 兰 49 Press. The trouble with both Cramer's V and the contingency coefficient Cis that,when they take on values in between their extremes,there is no very direct interpretation 9 of what that value means.For example,you are in Las Vegas,and a friend tells you that there is a small,but significant,association between the color of a croupier's SCIENTIFIC eyes and the occurrence of red and black on his roulette wheel.Cramer's V is about 0.028,your friend tells you.You know what the usual odds against you are(because 6 of the green zero and double zero on the wheel).Is this association sufficient for you to make money?Don't ask us! 1920 COMPUTING (ISBN #include <math.h> #include "nrutil.h" #define TINY 1.0e-30 A small number Numerica 10621 void cntabl(int **nn,int ni,int nj,float *chisq,float *df,float *prob, float *cramrv,float *ccc) Recipes 43108 Given a two-dimensional contingency table in the form of an integer array nn[1..ni][1..nj] this routine returns the chi-square chisq,the number of degrees of freedom df,the significance level prob(small values indicating a significant association),and two measures of association, (outside Cramer's V (cramrv)and the contingency coefficient C (ccc). North Software. float gammg(float a,float x); int nnj,nni,j,i,minij; float sum=0.0,expctd,*sumi,*sumj,temp; sumi=vector(1,ni); sumj=vector(1,nj); nnisni; Number of rows nnj=nj; and columns. for(i=1;1<=n1;i++)[ Get the row totals. sumi[i]=0.0; for (j=1;j<=mj;j++){ sumi[i]+nn[i][j]; sum +nn[i][j];14.4 Contingency Table Analysis of Two Distributions 631 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). The formula for Cramer’s V is V = χ2 N min (I − 1, J − 1) (14.4.4) where I and J are again the numbers of rows and columns, and N is the total number of events. Cramer’s V has the pleasant property that it lies between zero and one inclusive, equals zero when there is no association, and equals one only when the association is perfect: All the events in any row lie in one unique column, and vice versa. (In chess parlance, no two rooks, placed on a nonzero table entry, can capture each other.) In the case of I = J = 2, Cramer’s V is also referred to as the phi statistic. The contingency coefficient C is defined as C = χ2 χ2 + N (14.4.5) It also lies between zero and one, but (as is apparent from the formula) it can never achieve the upper limit. While it can be used to compare the strength of association of two tables with the same I and J, its upper limit depends on I and J. Therefore it can never be used to compare tables of different sizes. The trouble with both Cramer’s V and the contingency coefficient C is that, when they take on values in between their extremes, there is no very direct interpretation of what that value means. For example, you are in Las Vegas, and a friend tells you that there is a small, but significant, association between the color of a croupier’s eyes and the occurrence of red and black on his roulette wheel. Cramer’s V is about 0.028, your friend tells you. You know what the usual odds against you are (because of the green zero and double zero on the wheel). Is this association sufficient for you to make money? Don’t ask us! #include <math.h> #include "nrutil.h" #define TINY 1.0e-30 A small number. void cntab1(int **nn, int ni, int nj, float *chisq, float *df, float *prob, float *cramrv, float *ccc) Given a two-dimensional contingency table in the form of an integer array nn[1..ni][1..nj], this routine returns the chi-square chisq, the number of degrees of freedom df, the significance level prob (small values indicating a significant association), and two measures of association, Cramer’s V (cramrv) and the contingency coefficient C (ccc). { float gammq(float a, float x); int nnj,nni,j,i,minij; float sum=0.0,expctd,*sumi,*sumj,temp; sumi=vector(1,ni); sumj=vector(1,nj); nni=ni; Number of rows nnj=nj; and columns. for (i=1;i<=ni;i++) { Get the row totals. sumi[i]=0.0; for (j=1;j<=nj;j++) { sumi[i] += nn[i][j]; sum += nn[i][j];
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有