Obtains the average number of sampling bouts and the rate of acceptance for \(H_{1}\), from a sequential test of \(H_{0}:\mu = \psi_{0}\) vs. \(H_{1}:\mu < \psi_{1}\) across a range of true population densities, based on simulations. Sometimes called "operating characteristics".
Arguments
- obj
An object of class
"SPRT"
.- eval.range
A vector with a sequence of true population densities to evaluate.
- overdispersion.sim
A character string (if a function) or a non-negative number specifying the overdispersion parameter used to generate simulated counts. Only required when using
"negative binomial"
or"beta-binomial"
as kernel densities. See details.- N
Number of simulations per true population density being evaluated.
- seed
Optional seed for random count generation.
Value
A list with the average number of sampling bouts required to reach a decision
($AvgSamples
), and the rate of acceptance for \(H_{1}\) across
the provided range of population densities ($AcceptRate
).
Details
The kernel probability density function to evaluate the test is that specified in the
argument density_func
to create the "SPRT"
object, but overdispersion
can be different to generate simulated counts. If "negative binomial"
is used
as kernel density for the test and overdispersion.sim
is not specified (NA),
then the same specification of the test is used to generate the counts. Ideally,
overdispersion for simulations should include uncertainty about the parameter to
produce more robust test evaluations. For example, if using a negative binomial
kernel
and the Taylor's Power Law approach to obtain overdispersion, then overdispersion for
simulations should be specified as: $$k = \frac{\mu^2}{a \mu^b e^z - \mu}$$ where \(k\)
is the overdispersion parameter of the negative binomial distribution, \(a\) and \(b\)
are parameters of the Taylor's Power Law and \(z\) is a normally distributed
variable with mean \(0\) and standard deviation \(\sigma_{e}\), which is the root
of the mean square error for the regression used to estimate \(a\) and \(b\). See
examples.
References
Binns, M.R., Nyrop, J.P. & Werf, W.v.d. (2000) Sampling and monitoring in crop protection: the theoretical basis for developing practical decision guides. CABI Pub., Wallingford, Oxon, UK; New York, N.Y.
Examples
# Function that describes negative binomial overdisperion from the mean
# and Taylor's Power Law parameters, a and b:
estimate_k <- function(mean) {
a = 1.830012
b = 1.218041 # a and b are Taylor's Power Law parameters
(mean^2) / ((a * mean^(b)) - mean)
}
# Generate a SPRT object with negative binomial and varying overdispersion
counts <- c(2, 5, 6, 2, 7)
test11 <- sprt(data = counts,
mu0 = 8,
mu1 = 10,
density_func = "negative binomial",
overdispersion = estimate_k(9),
alpha = 0.1,
beta = 0.1)
# Stochastic version of 'estimate k', where sd here is the the root of the
# mean square error for the regression used to estimate a and b.
estimate_k_stoch <- function(mean) {
a <- 1.830012
b <- 1.218041
(mean^2) /
((a * mean^(b) *
exp(truncdist::rtrunc(1,
"norm",
a = log(1 / (a * mean^(b - 1))),
b = Inf,
mean = 0,
sd = 0.3222354)))
- mean)
}
# Run model evaluation for test11 with varying overdispersion and
# added stochasticity.
eval4 <- SPRT.eval(test11, eval.range = seq(4, 13),
overdispersion.sim = "estimate_k_stoch", N = 30)
#> Error in estimate_k_stoch(pop_mean): could not find function "estimate_k_stoch"
plot(seq(4, 13), eval4$AvgSamples, type = "o", xlab = "True population size",
ylab = "Average number of bouts")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'y' in selecting a method for function 'plot': object 'eval4' not found
plot(seq(4, 13), eval4$AcceptRate, type = "o", xlab = "True population size",
ylab = "Acceptance rate of H1")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'y' in selecting a method for function 'plot': object 'eval4' not found
## End (Not run)