rflex.sim {smerc} | R Documentation |
rflex.test
on simualated datarflex.sim
efficiently performs
rflex.test
on a simulated data set. The
function is meant to be used internally by the
rflex.test
function, but is informative for
better understanding the implementation of the test.
rflex.sim( nsim = 1, nn, w, ex, alpha1 = 0.2, type = "poisson", pop = NULL, cl = NULL )
nsim |
A positive integer indicating the number of simulations to perform. |
nn |
A matrix of the k nearest neighbors for the
regions described by |
w |
A binary spatial adjacency matrix for the regions. |
ex |
The expected number of cases for each region. The default is calculated under the constant risk hypothesis. |
alpha1 |
The middle p-value threshold. |
type |
The type of scan statistic to compute. The
default is |
pop |
The population size associated with each region. |
cl |
A cluster object created by |
A vector with the maximum test statistic for each simulated data set.
data(nydf) data(nyw) # determine knn coords = with(nydf, cbind(longitude, latitude)) nn = knn(coords, longlat = TRUE, k = 50) # determine expected number of cases in each region cases = floor(nydf$cases) pop = nydf$pop ex = pop * sum(cases)/sum(pop) tsim = rflex.sim(nsim = 5, nn = nn, w = nyw, ex = ex)