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

View source: R/elliptic.sim.old.R

elliptic.simR Documentation

Perform elliptic.test on simulated data

Description

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

Usage

elliptic.sim(
  nsim = 1,
  nn,
  ty,
  ex,
  a,
  shape_all,
  ein,
  eout,
  cl = NULL,
  min.cases = 2
)

Arguments

nsim

A positive integer indicating the number of simulations to perform.

nn

A list of nearest neighbors produced by elliptic.nn.

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.

a

The penalty for the spatial scan statistic. The default is 0.5.

shape_all

A vector of the shapes associated with all of the possible zones constructed from nn. This can be obtained from elliptic.nn.

ein

The expected number of cases in the zone. Conventionally, this is the estimated overall disease risk across the study area, multiplied by the total population size of the zone.

eout

The expected number of cases outside the zone. This should be ty - ein and is computed automatically if not provided.

cl

A cluster object created by makeCluster, or an integer to indicate number of child-processes (integer values are ignored on Windows) for parallel evaluations (see Details on performance). It can also be "future" to use a future backend (see Details), NULL (default) refers to sequential evaluation.

min.cases

The minimum number of cases required for a cluster. The default is 2.

Value

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

Examples

data(nydf)
data(nyw)
coords <- with(nydf, cbind(longitude, latitude))
pop <- nydf$pop
enn <- elliptic.nn(coords, pop,
  ubpop = 0.1,
  shape = c(1, 1.5), nangle = c(1, 4)
)
cases <- floor(nydf$cases)
ty <- sum(cases)
ex <- ty / sum(pop) * pop
yin <- nn.cumsum(enn$nn, cases)
ein <- nn.cumsum(enn$nn, ex)
tsim <- elliptic.sim(
  nsim = 2, nn = enn$nn, ty = ty, ex = ex,
  a = 0.5, shape_all = enn$shape_all,
  ein = ein, eout = ty - ein
)

jfrench/smerc documentation built on Oct. 27, 2024, 5:13 p.m.