############################################################### Find the Cluster Sizes for the Testing Algorithm Based on Events ############################################################### DESCRIPTION: For specified number of cluster sizes per cell, obtains the minimum number of events that need to be obtained to be significant based on combining neighbouring population sizes. USAGE: get.kmat.event(maxw,eventmat,popmat,nnmat,signiflevel=0.05,mink=2) REQUIRED ARGUMENTS: maxw the maximum number of neighbours that should be combined to obtain the cluster sizes. If maxw=0, only the the population of each cell is used in the determination of the cluster size. If maxw=j where j is a non-negative integer, then the cluster sizes will be obtained based on each cell's population alone, each cell's population combined with its 1st nearest neighbour (NN),..., each cell's population combined with its jth NN. eventmat array of event frequencies by cell (row), frequency (column), and stratum (layer): eventmat[i,j,s]=number of cases in cell i and stratum s that have j events. If no strata, eventmat is a matrix. 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 test. The default is 0.05. mink the minimum cluster size for each cell. The default is 2. VALUE: a vector (if maxw=0) or a matrix (if maxw>0) containing the cluster sizes for each cell (row). DETAILS: The testing algorigthm for events described in Rosychuk, Huston, and Prasad (2006) and 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 #event data with 2 strata, at most 3 events per case eventEx=array(0,dim=c(10,3,2)) eventEx[,,1]=matrix(scan(),ncol=3,byrow=T) #for stratum 1 3 2 0 0 0 0 0 0 0 2 0 0 2 3 2 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 #the above translates to: in stratum 1, cell 1 has 3 cases with 1 event each, #cell 1 has 2 cases with 2 events each, cell 1 has 0 cases with 3 events, #...cell 9 has 1 case with 1 event, cell 9 has 1 case with 2 events,.... eventEx[,,2]=matrix(scan(),ncol=3,byrow=T) #for stratum 2 0 1 0 0 0 0 0 0 0 0 0 0 2 3 2 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 #determine the cluster sizes with stratification, using only the population in each cell #alone and it each cell with its nearest neighbour kEx=get.kmat.event(1,eventEx,popEx,nnEx) print(kEx) #print the output # [,1] [,2] # [1,] 19 43 # [2,] 15 16 # [3,] 4 16 # [4,] 4 6 # [5,] 31 40 # [6,] 5 5 # [7,] 2 5 # [8,] 4 5 # [9,] 19 21 #[10,] 5 21 #determine the cluster sizes without stratification, using only the population in each cell #alone kEx=get.kmat.event(0,apply(eventEx,2,rowSums),rowSums(popEx),nnEx) print(kEx) #print the output # [,1] # [1,] 19 # [2,] 15 # [3,] 4 # [4,] 4 # [5,] 31 # [6,] 5 # [7,] 2 # [8,] 4 # [9,] 19 #[10,] 5