| nEdge | R Documentation |
Compute the total stratified, simple random sample size for various allocations that is large enough to insure adequate coverage of a normal approximation confidence interval (CI) for a population mean.
nEdge(ci.lev, side, epsilon = 0.005, dat, pop.sw = TRUE, wts = NULL, hcol=NULL, ycol,
alloc = NULL, Costh = NULL, nh.lowerbd = NULL
)
ci.lev |
desired confidence level for a 1- or 2-sided normal approximation confidence interval based on an estimated mean; must be in the interval (0,1) |
side |
either |
epsilon |
tolerance on coverage probability; the sample should be large enough that CI coverage is within |
dat |
either a population or sample data frame |
pop.sw |
TRUE if |
wts |
vector of weights if |
hcol |
column of |
ycol |
column of |
alloc |
allocation to the strata; must be one of |
Costh |
vector of costs per unit in each stratum; these exclude fixed costs that do not vary with the sample size |
nh.lowerbd |
Scalar value of the minimum value of the sample size allowed for any stratum |
nEdge computes the total sample size needed in either a stratified or unstratified simple random sample so that
the coverage probability of a confidence interval is within a specified tolerance (epsilon) of a nominal confidence
level (ci.lev). The calculation assumes that there is a single estimated mean of the variable ycol
that is of key importance in a sample. Confidence intervals for the finite population mean are usually computed using the
normal approximation whose accuracy depends on the underlying structure of the analytic variable and the total sample size.
In some applications, assuring that CIs have near nominal coverage is critical. For example, for some items on business tax
returns the US Internal Revenue Service allows sample estimates to be used but sets precision standards based on the lower
(or upper) limit of a 1-sided CI. In some cases the computed sample size from nEdge may be too small to meet other
goals of a sample (such as a precision requirement) and may need to be adjusted.
Using a three-term Edgeworth approximation to the distribution of the estimated overall mean in Qing & Valliant (2026),
which extends results in Qing & Valliant (2025), nEdge computes the total sample size needed so that a CI will have coverage
equal to the nominal value in ci.lev plus or minus
the tolerance epsilon. The remainder term in the approximation used in nEdge is O(n^{-3/2}). In previous versions of
PracTools, the remainder term in the approximation used in nEdge was O(n^{-1}), i.e. this version of nEdge
provides a more accurate sample size approximation. See Qing & Valliant (2026) for comparisons between the two levels of approximation.
This was also the level of approximation used in the function
nEdgeSRS in previous versions of Practools. nEdgeSRS has been deleted from the package because nEdge
also can be used for simple random sampling. The calculation in nEdge assumes that the sampling fraction in each stratum is negligible. The total sample size
returned by nEdge is based on the overall Edgeworth criterion; the resulting stratum sample sizes may not be large enough so
that the normal approximation is adequate for each stratum estimator.
When dat is a sample, the weights (wts) used in
the estimator of the mean are assumed to be scaled for estimating population totals. They can be inverse selection probabilities,
i.e. ones used in the \pi-estimator, or weights that have been adjusted to account for nonresponse or coverage errors.
The value of nh.lowerbd is usually set to be 2 or more to permit variances to be estimated.
If there are no strata, the value is a list with components:
CI type |
one-sided lower, one-sided upper, or two-sided |
epsilon |
tolerance on CI coverage |
Total sample size |
numeric sample size |
allocation |
type of allocation to strata or NULL if no strata are used |
g1 |
skewness of y |
g2 |
excess kurtosis of y, i.e., 4th central moment divided by the square of the variance minus 3 |
q1 |
1st polynomial in Edgeworth expansion of the t-statistic |
q2 |
2nd polynomial in Edgeworth expansion of the t-statistic |
If the sample design has strata, the value is a list with the first four items above followed by
Stratum values |
Data frame with columns for stratum, number of population units in each stratum, number of sample units
allocated to each stratum ( |
If alloc = "totcost" or "totvar", the total cost of the allocation is returned and Stratum values contains a column for Costh.
Richard Valliant, Siyu Qing
Qing, S. and Valliant, R. (2025). Extending Cochran's Sample Size Rule to Stratified Simple Random Sampling with Applications to Audit Sampling. Journal of Official Statistics, 41(1), 309-328.
Qing, S. and Valliant, R. (2026). Minimum Sample Size Rule for STSRS: A Three-Term Edgeworth Expansion for the Studentized Sample Mean, accepted by Journal of Survey Statistics and Methodology.
U.S. Internal Revenue Service (2011). 26 CFR 601.105: Examination of returns and claims for refund, credit or abatement: determination of correct tax liability. Washington DC. https://www.irs.gov/pub/irs-drop/rp-11-42.pdf
nCont, nLogOdds, nProp, nPropMoe, nWilson
require(PracTools)
set.seed(1289129963)
pop <- HMT(N=10000, H=5)
# run for full population, 2-sided CI, Neyman allocation
nEdge(ci.lev = 0.95, side = "two.sided", epsilon = 0.005, dat = pop,
pop.sw = TRUE, wts = NULL, hcol = "strat", ycol = "y", alloc = "neyman",
Costh = NULL)
nEdge(ci.lev = 0.95, side = "two.sided", epsilon = 0.005,dat = pop,
pop.sw = TRUE, wts = NULL, hcol = "strat", ycol = "y", alloc = "totcost",
Costh = c(5, 10, 15, 20, 25)
)
# run for a stratified sample, 1-sided lower CI, equal allocation
require(sampling)
sam <- strata(data=pop, stratanames="strat", size=c(30, 40, 50, 60, 70), method=c("srswor"),
description=TRUE)
samdat <- pop[sam$ID_unit,]
w = 1/sam$Prob
nEdge(ci.lev = 0.99, side = "one.sided.lower", epsilon = 0.01, dat = samdat,
pop.sw = FALSE, wts = w, hcol = "strat", ycol = "y", alloc = "equal",
Costh = NULL, nh.lowerbd = 2)
# simple radom sample size
nEdge(ci.lev = 0.95, side = "two.sided", epsilon = 0.005, dat = pop,
pop.sw = TRUE, wts = NULL, hcol = NULL, ycol = "y")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.