cepp.sim: Perform 'cepp.test' on simulated data

Description Usage Arguments Value Examples

View source: R/cepp.sim.R

Description

cepp.sim efficiently performs cepp.test on a simulated data set. The function is meant to be used internally by the cepp.test function, but is informative for better understanding the implementation of the test.

Usage

1
cepp.sim(nsim = 1, nn, ty, ex, wts, simdist = "multinomial")

Arguments

nsim

A positive integer indicating the number of simulations to perform.

nn

A list of nearest neighbors produced by casewin.

ty

The total number of cases in the study area.

ex

The expected number of cases for each region. The default is calculated under the constant risk hypothesis.

wts

A list that has the weights associated with each region of each element of nn.

simdist

A character string indicating whether the simulated data should come from a "multinomial" or "poisson" distribution. The default is "multinomial", which fixes the total number of cases observed in each simulated data set.

Value

A vector with the maximum test statistic for each simulated data set.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data(nydf)
coords = with(nydf, cbind(longitude, latitude))
d = sp::spDists(as.matrix(coords), longlat = TRUE)
nn = casewin(d, cases = nydf$pop, cstar = 15000)
cases = floor(nydf$cases)
ty = sum(cases)
ex = ty/sum(nydf$pop) * nydf$pop
# find smallest windows with at least n* pop
nstar = 1000
nn = casewin(d, cases = nydf$pop, cstar = nstar)
# determine ts
wts = cepp.weights(nn, nydf$pop, nstar)
tsim = cepp.sim(1, nn = nn, ty = ty, ex = ex, wts = wts)

smerc documentation built on Oct. 1, 2021, 5:07 p.m.