stat.poisson.adj: Compute Poisson test statistic

View source: R/stat.poisson.adj.R

stat.poisson.adjR Documentation

Compute Poisson test statistic

Description

Efficiently compute a vector of Poisson test statistics. This function does no sanity checking. We encourage you to compare the results against scan.stat for correctness. stat_poisson_adj is a C++ version implementation of the code and should be faster. stat_binomial_adj is a C++ version implementation of stat.binom.

Usage

stat.poisson.adj(
  yin,
  ty,
  logein,
  logeout,
  a = 0,
  pen = 1,
  min.cases = 2,
  return.max = FALSE
)

stat_poisson_adj(
  yin,
  ty,
  logein,
  logeout,
  a = 0,
  pen = 1,
  min.cases = 2,
  return.max = FALSE
)

stat_binom_adj(
  yin,
  ty,
  popin,
  popout,
  logpopin,
  logpopout,
  tpop,
  min.cases = 2,
  return.max = FALSE
)

Arguments

yin

The total number of cases in the zone.

ty

The total number of cases in the study area.

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.

a

A tuning parameter for the adjusted log-likelihood ratio. See details.

pen

The eccentricity penalty for each candidate zone.

min.cases

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

return.max

A logical value. Default is FALSE. If TRUE, then only the maximum statistic is returned.

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.

tpop

The total population in the study area.

Value

A numeric vector.

Examples

data(nydf)
coords <- with(nydf, cbind(longitude, latitude))
enn <- elliptic.nn(coords, nydf$pop, ubpop = 0.015)
cases <- floor(nydf$cases)
ty <- sum(cases)
ex <- ty / sum(nydf$pop) * nydf$pop
yin <- nn.cumsum(enn$nn, cases)
ein <- nn.cumsum(enn$nn, ex)
logein <- log(ein)
logeout <- log(ty - ein)
pen <- elliptic.penalty(a = 0.5, enn$shape_all)
stat.poisson.adj(yin, ty, logein, logeout,
  a = 0.5, pen = pen, return.max = TRUE
)

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