############################################# Conduct the Cluster Detection Based on Cases ############################################# DESCRIPTION: For specified cluster sizes, conducts the cluster detection tests based on cases. USAGE: case.test(kmat,datmat,popmat,nnmat,signiflevel=0.05,print.it=F) REQUIRED ARGUMENTS: kmat the cluster sizes used for the testing. If a vector, each element corresponds to the cluster size for each cell (has dimension equal to the total number of cells). If kmat is a matrix, each row contains the sequence of cluster sizes to test for each cell. The testing algorithm is employed if kmat is a matrix. Each cluster size must be > 1. datmat the matrix containing the number of cases in each cell (rows) by each stratum (columns). popmat the matrix containing the number of population in each cell (rows) by each stratum (columns). nnmat the square matrix containing the ordered nearest neighbours: nnmat[i,1]=i, nnmat[i,j]=cell i's (j+1)th nearest neighbour. Assumes that the cells are indexed (labelled) from 1 to the total number of cells. OPTIONAL ARGUMENTS: signiflevel the significance level for each cluster test. The default is 0.05. print.it a flag to indicate if intermediate calculations should be printed (print.it=T) or not (print.it=F). The default is print.it=F. VALUE: a matrix containing the results of the testing. The columns are the cell number (Cell), the testing algorithm flag (Alg(w)), the cluster size tests (ClustSize), the observed value of the test statistic (TestStat), the observed number of cases in the cell and its neighbours (Observed), the expected number of cases in the cell and its neighbours (Expected), the observed to expected ratio (Obs/Exp), the p-value for the test (p-value), and a flag that indicates significance of the test at significance level signiflevel (Flag=0 if insignificant, =1 if significant). Alg(w) will be NA if kmat is a vector. If kmat is a matrix, Alg(w) will display the test result for kmat[i,w+1] used as the cluster size. DETAILS: This method is based on the Besag and Newell (1991) test statistic. The testing algorigthm is based on Le, Petkau, and Rosychuk (1996). EXAMPLES: #hypothetical 10 cell region #provide the nearest neighbour for cells 1 to 10 nnEx=matrix(scan(),ncol=10,byrow=T) 1 5 2 3 9 4 10 6 7 8 2 3 5 4 1 8 9 10 6 7 3 2 4 5 1 8 9 10 6 7 4 3 2 5 8 6 7 1 9 10 5 2 3 4 1 8 10 9 6 7 6 7 4 8 3 2 5 10 9 1 7 6 8 4 3 2 5 9 10 1 8 4 10 7 3 6 2 1 5 9 9 10 7 6 4 5 2 1 3 8 10 9 7 8 6 4 5 2 1 3 #population data with 2 strata popEx=matrix(scan(),ncol=2,byrow=T) 1358 1405 1005 1089 117 120 66 62 2827 2749 152 158 16 26 67 92 1456 1444 174 180 #case data with 2 strata datEx=matrix(scan(),ncol=2,byrow=T) 3 2 0 0 0 0 2 0 2 3 0 0 0 0 0 0 1 1 0 0 #do the testing with user supplied cluster sizes and incorporating strata kEx=rep(2,10)#test each cell at cluster size=2 resultEx=case.test(kEx,datEx,popEx,nnEx) print(resultEx) #print the output of the test # Cell Alg(w) ClustSize TestStat Observed Expected Obs/Exp p-value Flag # [1,] 1 NA 2 0 5 5.317 0.940 0.969 0 # [2,] 2 NA 2 2 5 7.607 0.657 0.996 0 # [3,] 3 NA 2 2 2 2.354 0.850 0.681 0 # [4,] 4 NA 2 0 2 0.246 8.119 0.026 1 # [5,] 5 NA 2 0 5 10.730 0.466 1.000 0 # [6,] 6 NA 2 2 2 0.460 4.347 0.078 0 # [7,] 7 NA 2 3 2 0.610 3.281 0.125 0 # [8,] 8 NA 2 1 2 0.273 7.322 0.031 1 # [9,] 9 NA 2 0 2 5.581 0.358 0.975 0 #[10,] 10 NA 2 1 2 3.132 0.639 0.820 0 #do the testing without strata resultEx=case.test(kEx,rowSums(datEx),rowSums(popEx),nnEx) print(resultEx) #print the output of the test # Cell Alg(w) ClustSize TestStat Observed Expected Obs/Exp p-value Flag # [1,] 1 NA 2 0 5 2.656 1.882 0.743 0 # [2,] 2 NA 2 2 5 7.601 0.658 0.996 0 # [3,] 3 NA 2 2 2 2.364 0.846 0.684 0 # [4,] 4 NA 2 0 2 0.123 16.253 0.007 1 # [5,] 5 NA 2 0 5 5.360 0.933 0.970 0 # [6,] 6 NA 2 2 2 0.461 4.334 0.079 0 # [7,] 7 NA 2 3 2 0.614 3.256 0.127 0 # [8,] 8 NA 2 1 2 0.276 7.249 0.032 1 # [9,] 9 NA 2 0 2 2.788 0.717 0.767 0 #[10,] 10 NA 2 1 2 3.128 0.639 0.819 0