find_n_ksigma: Find N for k-sigma sample interval

View source: R/find_n_ksigma.R

find_n_ksigmaR Documentation

Find N for k-sigma sample interval

Description

Find required sample size for "k-sigma sample interval" (i.e., parametric sample interval applied to a Normal distribution) to achieve targeted reliability using bisection algorithm

Usage

find_n_ksigma(
  proximity_range,
  reliability,
  k = NULL,
  search_interval = c(3, 500),
  n_sim = 1e+06,
  tolerance = 1e-05,
  plot = FALSE,
  verbose = FALSE,
  seed = NULL
)

Arguments

proximity_range

Range within which sample coverage should fall with pre-specified reliability.

reliability

Targeted probability that individual coverage of parametric sample interval applied to a Normal distribution falls within proximity_range.

k

Standard deviation multiplier for parametric sample interval applied to Normal distribution (typically 2 or 3). If NULL, k is assigned based on the midpoint of the proximity_range.

search_interval

Initial interval of sample sizes for bisection algorithm. Default is c(3, 500).

n_sim

Number of simulation iterations used to estimate reliability. Default is 1000000.

tolerance

Threshold for difference between targeted and estimated reliability that indicates sufficient proximity of the root-finding function to 0, triggering the end of the search. Default is 0.00001.

plot

If TRUE, plot sampling distribution for true interval coverage using sample size identified through bisection.

verbose

If TRUE, print the search interval used for each round of the bisection algorithm search.

seed

Randomization seed. Defaults to NULL so that no seed is used.

Value

A list with the following elements:

  • The estimated sample size required to achieve target reliability.

  • If plot is TRUE, the plot object.

Examples

find_n_ksigma(
  proximity_range = c(0.93, 0.97),
  reliability = 0.7,
  k = 2
)

dygobeng/nterval documentation built on March 22, 2022, 6:40 p.m.