scan.sim.adj: Perform 'scan.test' on simulated data

View source: R/scan.sim.adj.R

scan.sim.adjR Documentation

Perform scan.test on simulated data

Description

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

Usage

scan.sim.adj(
  nsim = 1,
  nn,
  ty,
  ex,
  type = "poisson",
  logein = NULL,
  logeout = NULL,
  tpop = NULL,
  popin = NULL,
  popout = NULL,
  logpopin = NULL,
  logpopout = NULL,
  cl = NULL,
  simdist = "multinomial",
  pop = NULL,
  min.cases = 2
)

Arguments

nsim

A positive integer indicating the number of simulations to perform.

nn

A list of nearest neighbors produced by nnpop.

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.

type

The type of scan statistic to compute. The default is "poisson". The other choice is "binomial".

logein

The log of the expected number of cases in each candidate zone.

logeout

The log of the expected number of cases outside of each candidate zone.

tpop

The total population in the study area.

popin

The total population in the zone.

popout

The population outside the zone. This should be tpop - popin and is computed automatically if not provided.

logpopin

The log of the population in each candidate zone.

logpopout

The log of the population outside of each candidate zone.

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.

simdist

Character string indicating the simulation distribution. The default is "multinomial", which conditions on the total number of cases observed. The other options are "poisson" and "binomial"

pop

The population size associated with each region.

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)
coords <- with(nydf, cbind(longitude, latitude))
d <- gedist(as.matrix(coords), longlat = TRUE)
nn <- scan.nn(d, pop = nydf$pop, ubpop = 0.1)
cases <- floor(nydf$cases)
ty <- sum(cases)
ex <- ty / sum(nydf$pop) * nydf$pop
yin <- nn.cumsum(nn, cases)
ein <- nn.cumsum(nn, ex)
tsim <- scan.sim.adj(
  nsim = 2, nn, ty, ex,
  logein = log(ein),
  logeout = log(sum(ex) - ein)
)

jpfrench81/smerc documentation built on Jan. 13, 2024, 4:30 a.m.