rflex.sim: Perform 'rflex.test' on simualated data

Description Usage Arguments Value Examples

View source: R/rflex.sim.R

Description

rflex.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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
rflex.sim(
  nsim = 1,
  nn,
  w,
  ex,
  alpha1 = 0.2,
  type = "poisson",
  pop = NULL,
  cl = NULL
)

Arguments

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.

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 "poisson". The other choice is "binomial".

pop

The population size associated with each region.

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).

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

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