#include "k.h" /* * Perform a chi-sq test using Armitage's additive model * Input o (case) and e (control) (each vectors, length 3), R and N * Output chi-sq value */ double chi(int *o, int *e, int R, int N) { int n1,n2,r1,r2; double num,den; n1=o[1]+e[1]; n2=o[2]+e[2]; r1=o[1]; r2=o[2]; num=N*pow(N*(r1+2.*r2)-R*(n1+2.*n2),2.); den=R*(N-R)*(N*(n1+4.*n2)-pow(n1+2.*n2,2.)); return(sqrt(num/den)); }