% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bz_helpers.R
\name{bz_helpers}
\alias{bz_helpers}
\alias{Rs_bz_supported}
\alias{R_for_bz}
\title{Helpers for the Boos-and-Zhang (2000) Method}
\usage{
Rs_bz_supported(
  alpha = 0.05,
  Rmax = getOption("power4mome.bz_Rmax", default = 359)
)

R_for_bz(R_target, alpha = 0.05)
}
\arguments{
\item{alpha}{The level of significance,
two-tailed.}

\item{Rmax}{The maximum number of resamples
to be returned. Default is 359.
Though it is possible to use 1999
resamples or even more with Boos-Zhang-2000,
using such a large number of resamples defeats
the goal to reduce processing time.}

\item{R_target}{The target maximum
number of resamples.}
}
\value{
The function \code{\link[=Rs_bz_supported]{Rs_bz_supported()}} returns
a numeric vector of the numbers of
resamples supported.

The function \code{\link[=R_for_bz]{R_for_bz()}} returns
a scalar.
}
\description{
Helpers for the method
by Boos and Zhang (2000) for estimating
rejection rate for resampling-based
tests.
}
\details{
Boos and Zhang (2000) proposed
a method to estimate the rejection
rate (power, if the null hypothesis is false)
for methods based on resampling, such
as nonparametric bootstrapping. This
method is used by some functions
in \code{power4mome}, such as \code{\link[=x_from_power]{x_from_power()}}.

This method is implemented internally.
Some helper functions regarding this
method is exported for users.

The function \code{\link[=Rs_bz_supported]{Rs_bz_supported()}} returns
the number of bootstrap samples (for bootstrapping)
or simulated samples (for Monte Carlo),
both called resamples below for brevity,
usually specified by the argument \code{R},
that can be
used for the Boos-Zhang-2000 method,
given the desired two-tailed level of significance,
(.05 by default).
If possible, setting the number of resamples.
(e.g., setting \code{R} when calling \code{\link[=x_from_power]{x_from_power()}})
will automatically enable the Boos-Zhang-2000
method (unless explicitly turned off
by setting the option \code{"power4mome.bz"}
to \code{FALSE} by \code{options("power4mome.bz") <- FALSE}),
substantially reducing the processing
time. For now, only two-tailed tests are supported.

Given a target maximum number of
resamples and a level of significance,
the function \code{\link[=R_for_bz]{R_for_bz()}} returns
largest number of resamples that can be
used for the Boos-Zhang-2000 method.
This function can be used for
arguments such as \code{R} in \code{\link[=x_from_power]{x_from_power()}}
to automatically find the largest
value supported by the Boos-Zhang-2000
method.
}
\examples{
# === Rs_bz_supported ===

# alpha = .05
Rs_bz_supported()

# alpha = .01
Rs_bz_supported(alpha = .01)

# === R_for_bz ===

R_for_bz(200)
R_for_bz(500)

}
\references{
Boos, D. D., & Zhang, J. (2000).
Monte Carlo evaluation of
resampling-based hypothesis tests.
\emph{Journal of the American Statistical Association},
\emph{95}(450), 486--492.
\doi{10.1080/01621459.2000.10474226}
}
\seealso{
\code{\link[=x_from_power]{x_from_power()}}
}
