Compute the sample size that satisfies precision requirements for multiple survey indicators simultaneously under a simple sampling design. Optional domain columns support separate requirements by subpopulation.
Usage
n_multi(indicators, ...)
# Default S3 method
n_multi(
indicators,
...,
domains = NULL,
domain_sampling = c("separate", "natural"),
min_n_domain = NULL,
prop_method = c("wald", "wilson", "logodds", "beta"),
resp_rate = 1,
eligibility_rate = 1,
eligible_per_unit = 1,
plan = NULL
)
# S3 method for class 'svyplan_prec'
n_multi(indicators, ...)Arguments
- indicators
For the default method: a data frame where each row is one survey indicator you want to measure. For example, a prevalence (proportion) or a population mean. Surveys typically track several indicators simultaneously and the sample must be large enough for the most demanding one.
n_multi()finds that size.See the Details section for the full column reference. At minimum, each row needs:
What to measure:
pfor a proportion (e.g. 0.30 for 30% stunting),varfor a continuous variable's population variance, orrfor a ratio of two means, with its momentscv_num,cv_denandcomponent_cor. Each row must use exactly one.How precise:
moe(margin of error),rmoe(margin of error relative to the estimand) orcv(coefficient of variation). Each row must specify exactly one.
For
svyplan_precobjects: a precision result fromprec_multi().- ...
Additional arguments passed to methods. Unused arguments are rejected.
- domains
Character vector of column names in
indicatorsto treat as domain variables, orNULL(default) for no domains. All names must exist inindicators. When specified, sizing runs independently for each domain combination. A domain column cannot be callednameor start with a dot, the names of result columns.- domain_sampling
How the per-domain requirements combine into one overall size, either
"separate"(default) or"natural". It applies only when domains are present."separate"treats the domains as disjoint quotas drawn independently, the usual case for regional or urban/rural domains in one national survey, and reportsnas their sum. Every quota has to be met, so no smaller total delivers the design."natural"treats them as analytic domains that arise at their own rate inside one sample. It requires asharecolumn giving each domain's expected share of the population, constant within a domain, and reportsnasmax(.n / share). That is an expected yield. A sample of that size delivers each domain's quota on average, not with certainty in any one realized sample.- min_n_domain
Numeric scalar or
NULL(default). Minimum total sample size per domain. It applies only when domains are present. Per-domain sample sizes are floored tomin_n_domain.- prop_method
Proportion CI method, one of
"wald"(default),"wilson","logodds", or"beta". This is passed ton_prop()for proportion rows and ignored for mean rows. An optionalprop_methodcolumn inindicatorsoverrides this default on a per-row basis."wilson","logodds"and"beta"size from an interval half-width, so those rows needmoeorrmoerather thancv.- resp_rate
Default expected response rate among eligible ultimate units, in (0, 1]. Used for rows whose
resp_ratecolumn is absent orNA, and a non-missing row value overrides it. See the nonresponse section of svyplan-package for what the rate counts and what this adjustment does and does not claim.- eligibility_rate
Default share of issued units in scope, in (0, 1]. Used for rows whose
eligibility_ratecolumn is absent orNA, and a non-missing row value overrides it. With a finiteN, a row's population in scope isN * eligibility_rate. See the nonresponse section of svyplan-package.- eligible_per_unit
Default eligible units per sampled unit, a positive number such as married women per household, which can exceed 1. Used for rows whose
eligible_per_unitcolumn is absent orNA, and a non-missing row value overrides it. Proportion and mean rows. See theeligible_per_unitcolumn under Details.- plan
Optional
svyplan()object providing design defaults.
Value
A svyplan_n object. The output class is the same with or without
domains.
Without domains, the object contains:
nThe sample size required by the binding indicator.
detailOne row per indicator:
name, its requirement.n,.cv_target,.cv_achievedatn,.cv_fieldatceiling(n),.binding,.constraint(what sets the row's requirement:"precision","min_cases"or"min_respondents"), and the target as stated,.target_scale("moe","rmoe"or"cv") and.target. A row with only a respondent floor hasNAprecision.bindingName or index of the binding (most demanding) indicator.
binding_causeWhat made it bind, one of the
.constraintvalues.indicatorsThe input indicators data frame.
With domains, the object additionally contains:
nThe overall size, read according to
domain_sampling: the sum of the domain quotas under"separate", or the size whose expected yield meets every quota under"natural". It is not the largest domain requirement, which is a different and smaller number.n_domain_maxThe largest single domain requirement. Under
domain_sampling = "natural", this need not be the domain that determinesn, which is selected after division by.share.bindingThe binding indicator within the domain that determines
n: the largest domain quota under"separate", or the largest share-adjusted requirement under"natural". Use$domainsto identify the domain itself.domainsData frame with one row per domain, including domain variables,
.n,.binding, and.shareunder"natural".detailOne row per indicator and domain, the domain variables first, then
name,.n,.cv_target,.binding,.constraint,.target_scaleand.target. These are each domain's own requirements, beforemin_n_domainor natural incidence raises its size.summary()reads what each row achieves at the fielded size.binding_causeAs without domains, or
"min_n_domain"when that floor sets the binding domain's quota.
Details
Building the indicators data frame
Each row of indicators represents one survey indicator. The two key
decisions per row are:
Type of indicator: is it a proportion (binary variable like "stunted yes/no"), a mean (continuous variable like "household expenditure"), or a ratio of two means (such as expenditure per adult equivalent)? This determines whether you fill the
p,varorrcolumn.Precision target: do you want an absolute margin of error (
moe, e.g. +/- 5 percentage points), the same margin stated relative to the estimand (rmoe, e.g. 12 percent of the proportion), or a relative coefficient of variation (cv, e.g. 10 percent relative error)?
A minimal example for three health indicators:
indicators <- data.frame(
name = c("stunting", "vaccination", "expenditure"),
p = c(0.30, 0.70, NA),
var = c(NA, NA, 2500),
moe = c(0.05, 0.05, 10)
)Rows with p are treated as proportions, rows with var (and
p = NA) as means, and rows with r as ratios. A row carries only one
of p, var and r.
A row may instead carry only a floor on the number of respondents,
min_respondents, with no p, var or target. It stands for an
estimate whose precision is not modeled, such as the fertility rates a
DHS sizes by a count of interviews with women. Its resp_rate and
eligible_per_unit turn the count into sampled units, and it raises the
size the other rows set. Every domain needs at least one row with an
estimate and a target.
Column reference
nameIndicator label (optional). If omitted, each row is labeled by its row number in
indicators, with domains as without. When given, every row needs a name, unique within a domain.pExpected proportion, in (0, 1). Use this for binary indicators such as prevalences or coverage rates. The value is your best prior guess (e.g. from a previous survey or literature). One of
p,varorrper row.varPopulation variance of a continuous indicator. Use this for means (e.g. income, expenditure, weight). One of
p,varorrper row.rAnticipated ratio of two means, marking a ratio row, sized as
n_ratio()sizes it. It requirescv_num,cv_denandcomponent_coralongside it. One ofp,varorrper row.cv_num,cv_denCoefficients of variation of a ratio row's numerator and denominator, strictly positive.
component_corCorrelation between a ratio row's numerator and denominator across units, in \([-1, 1]\).
meanPopulation mean, finite. It may be negative. It is required when
varis used withcvbecause CV = SE / abs(mean), and it must then be non-zero, as it must in multistage mode, which works on the cv scale. With amoetarget a zero mean is accepted and the row'scvandrmoeareNA.moeMargin of error, the half-width of the confidence interval you want. For proportions, this is on the probability scale (e.g. 0.05 for +/- 5 percentage points). For means, it is in the same units as the variable (e.g. 10 dollars).
rmoeMargin of error relative to the row's estimand, so 0.12 asks for a half-width of 12 percent of
por ofabs(mean). It is converted tomoeon ingestion, so the row needspormean, and it is read under the row's ownprop_method.cvTarget coefficient of variation (relative standard error). For example, 0.10 means the SE should be at most 10% of the estimate.
alphaSignificance level for the confidence interval (default 0.05, giving a 95 percent CI).
2 * pnorm(-2)gives the multiplier of 2 that the DHS and MICS manuals use in place of 1.96.deffDesign effect multiplier (default 1). Set > 1 to inflate the sample size for complex designs (e.g. 1.5 for a cluster design). A published DEFT is squared first. See
varcomp()for that and for removing the published survey's weighting loss.NPopulation size (default
Inf). A finite value applies a finite population correction, reducing the required sample size.prop_methodProportion CI method:
"wald"(default),"wilson","logodds", or"beta"."wilson"is recommended for rare proportions (below 0.1 or above 0.9), and"beta"(Korn-Graubard) when the expected number of positive counts is small enough that the interval should stay inside[0, 1]by construction. It is used only for rows withp. Seen_prop()for how to choose.dfDegrees of freedom of the planned variance estimator, typically sampled PSUs minus strata, and available from
design_df(). It switches that row's interval quantile from normal to t, under every method.NA(the default) applies no adjustment. A df is a property of the design rather than of an indicator, so every row of a single-domain table shares one value. The column earns its place when the rows are domains, each covering its own set of strata:design_df(alloc)$domains$.dfgives one value per domain to match in.min_casesMinimum expected number of positive cases the row must yield, a floor on that row's own size, as in
n_prop()(min_cases = ). Proportion rows only, andNA(the default) sizes the row on precision alone. The row that ends up largest is still the binding one, whichever constraint raised it. Single-stagen_multi()only, because a multistage design sizes stages against a cost and has no single total for a count to raise.min_respondentsMinimum expected number of eligible respondents,
n * resp_rate * eligibility_rate * eligible_per_unit, a floor on the row's size. Unlikemin_cases, it counts every respondent of the row's group, not those with the attribute, and it applies to any row. A row with this floor and no estimand is the floor-only row described above.NA(the default) sets no floor. Single-stagen_multi()only, as formin_cases.unit_relvarUnit relvariance. If omitted, derived automatically from
p(as(1 - p) / p) or fromvar/mean^2. A ratio row derives it from its moments, and a value given there must agree with them.resp_rateExpected response rate at the ultimate unit, in (0, 1]. Default 1 (no adjustment). A value of 0.90 inflates the sample size by
1 / 0.90to compensate for 10 percent nonresponse. It means the same thing in a cluster design, wheren_cluster()additionally takesresp_rate_1for whole clusters that cannot be worked andresp_rate_2for second-stage units in a three-stage design. Naming a stage the design does not have is an error rather than a column carried along and ignored.eligibility_rateShare of the row's issued units in scope, in (0, 1]. It inflates the row's size by
1 / eligibility_rate, and with a finiteNthe population in scope isN * eligibility_rate.NAtakes theeligibility_rateargument.eligible_per_unitEligible units per sampled unit for the row's estimate, such as married women or children aged 12 to 23 months per household. The row is sized as
n_prop()orn_mean()size it witheligible_per_unit. Sizes stay in sampled units, and the variance readsN * eligibility_rate * eligible_per_uniteligible units andresp_rate * eligibility_rate * eligible_per_unitrespondents per sampled unit. Each row can carry its own group. Proportion and mean rows, so a ratio row takes 1. The several-indicators mode ofn_cluster()reads the same column.
Domain columns are specified via the domains parameter. When domains
are present, sizing runs independently for each domain combination, and
domain_sampling decides how those requirements combine into the one
number n reports. The two readings answer different questions and give
different sizes, so the choice belongs to the design rather than to a
default. Separate quotas need every requirement met and therefore their
sum, while natural domains need a sample large enough that the rarest
demanding domain turns up often enough. Neither is the largest single
requirement, which n_domain_max reports separately.
Columns beyond those listed are carried along and ignored, so the table
can keep questionnaire modules, sources, or other bookkeeping. The
exception is a name the rest of the package would lead you to expect
here: mu (tables use mean across the package, while scalar functions
such as n_mean() take mu), indicator or label (it takes name),
method (it takes prop_method), and icc or var_ratio (which are
per stage here, so icc_1 and var_ratio_1). Those are rejected
with the name they should have carried rather than silently ignored. A
column named through domains is exempt, so a domain may be called
label or method.
The dispersion of a continuous indicator may be given as var or as
sd, whichever the source reports, exactly as in n_mean(). They are
different quantities rather than two names for one, so supplying both
in the same table is an error rather than a preference. sd is squared
on the way in and everything downstream reads var.
n_multi() computes sample size per indicator by delegating proportion
rows to n_prop(), mean rows to n_mean() and ratio rows to
n_ratio(), then takes the maximum per domain. Use prop_method or a
indicators$prop_method column to choose "wald", "wilson",
"logodds" or "beta" for proportion rows.
A domain that takes most of its PSUs
A deff column carries the clustering of a design whose first stage is
treated as drawn with replacement, and N corrects only for the units.
Nothing here knows how many PSUs a domain holds. A small domain, such as
an island district of 16 enumeration areas, can then be given more PSUs
than it has, and a sample that takes most of them is assessed as if
they were a few among many. n_alloc() and prec_alloc() read N_1
in the frame and, with fpc = "stage", apply the stage-by-stage
correction. They size and assess such a domain, as the Details of
n_alloc() describe.
References
Cochran, W. G. (1977). Sampling Techniques, 3rd ed. Wiley.
Valliant, R., Dever, J. A., and Kreuter, F. (2018). Practical Tools for Designing and Weighting Survey Samples, 2nd ed. Springer.
See also
n_prop() and n_mean() for single-indicator sizing,
n_alloc() to split a multi-indicator size across strata or domains,
n_cluster() for a multistage cluster design over the same indicator
table, and prec_multi() for the inverse.
Other multi-indicator functions:
prec_multi()
Examples
# Simple mode: three indicators, take the max
indicators <- data.frame(
name = c("stunting", "vaccination", "anemia"),
p = c(0.30, 0.70, 0.10),
moe = c(0.05, 0.05, 0.03)
)
n_multi(indicators)
#> Multi-indicator sample size
#> n = 385 (binding: anemia)
#>
#> name .n .cv_target .cv_achieved .binding
#> stunting 323 0.0850 0.0778
#> vaccination 323 0.0364 0.0334
#> anemia 385 0.1531 0.1529 *
#>
#> # summary() for each indicator at the field size
# MICS-style: state precision as a relative margin of error
targets_rmoe <- data.frame(
name = c("stunting", "vaccination", "anemia"),
p = c(0.30, 0.70, 0.10),
rmoe = 0.12,
deff = c(2.0, 1.5, 2.5)
)
n_multi(targets_rmoe)
#> Multi-indicator sample size
#> n = 6003 (binding: anemia)
#>
#> name .n .cv_target .cv_achieved .binding
#> stunting 1245 0.0612 0.0279
#> vaccination 172 0.0612 0.0103
#> anemia 6003 0.0612 0.0612 *
#>
#> # summary() for each indicator at the field size
# Continuous indicators: 'var' for the dispersion, 'mean' for the mean.
# A CV target needs 'mean', because a relative standard error is relative
# to something. A MOE target does not.
targets_mean <- data.frame(
name = c("expenditure", "hh_size"),
var = c(250000, 4.0),
mean = c(1200, 5.4),
cv = c(0.05, 0.03)
)
n_multi(targets_mean)
#> Multi-indicator sample size
#> n = 153 (binding: hh_size)
#>
#> name .n .cv_target .cv_achieved .binding
#> expenditure 70 0.0500 0.0337
#> hh_size 153 0.0300 0.0299 *
#>
#> # summary() for each indicator at the field size
# Proportions and means in one table, sized to a common CV
targets_both <- data.frame(
name = c("stunting", "expenditure"),
p = c(0.30, NA),
var = c(NA, 250000),
mean = c(NA, 1200),
cv = c(0.08, 0.05)
)
n_multi(targets_both)
#> Multi-indicator sample size
#> n = 365 (binding: stunting)
#>
#> name .n .cv_target .cv_achieved .binding
#> stunting 365 0.0800 0.0800 *
#> expenditure 70 0.0500 0.0218
#>
#> # summary() for each indicator at the field size
# Rare proportion: use Wilson globally in simple mode
n_multi(indicators[3, , drop = FALSE], prop_method = "wilson")
#> Multi-indicator sample size
#> n = 388 (binding: anemia)
#>
#> name .n .cv_target .cv_achieved .binding
#> anemia 388 0.1525 0.1523 *
#>
#> # summary() for each indicator at the field size
# Korn-Graubard for an indicator whose expected count is small, with the
# degrees of freedom of the planned variance estimator. 'df' is read on
# every row that sets it, and NA keeps the normal quantile on the other.
targets_rare <- data.frame(
name = c("stunting", "cocaine_use"),
p = c(0.30, 0.02),
moe = c(0.05, 0.01),
prop_method = c("wald", "beta"),
df = c(NA, 25)
)
n_multi(targets_rare)
#> Multi-indicator sample size
#> n = 949 (binding: cocaine_use)
#>
#> name .n .cv_target .cv_achieved .binding
#> stunting 323 0.0850 0.0496
#> cocaine_use 949 0.2273 0.2272 *
#>
#> # summary() for each indicator at the field size
# Per-row proportion methods in a mixed target table
targets_mixed <- data.frame(
name = c("rare_prop", "mean_ind"),
p = c(0.05, NA),
var = c(NA, 100),
moe = c(0.02, 2),
prop_method = c("wilson", NA)
)
n_multi(targets_mixed)
#> Multi-indicator sample size
#> n = 469 (binding: rare_prop)
#>
#> name .n .cv_target .cv_achieved .binding
#> rare_prop 469 0.2015 0.2013 *
#> mean_ind 97
#>
#> # summary() for each indicator at the field size
# Simple mode with domains
targets_dom <- data.frame(
name = rep(c("stunting", "anemia"), each = 2),
p = c(0.30, 0.25, 0.10, 0.15),
moe = c(0.05, 0.05, 0.03, 0.03),
region = rep(c("North", "South"), 2)
)
n_multi(targets_dom, domains = "region")
#> Multi-indicator sample size (2 domains, separate quotas)
#> n = 930 (sum of domain quotas)
#> Largest single domain = 545 (binding: anemia)
#>
#> region .n .binding
#> North 385 anemia
#> South 545 anemia
#>
#> # summary() for each indicator at the field size
# One indicator in several domains, each with its own design effect. The
# 'name' column is optional with a single indicator.
poverty <- data.frame(
district = c("North", "Centre", "South"),
p = c(0.31, 0.45, 0.52),
moe = 0.10,
deff = c(4.4, 3.1, 2.8)
)
n_multi(poverty, domains = "district")
#> Multi-indicator sample size (3 domains, separate quotas)
#> n = 926 (sum of domain quotas)
#> Largest single domain = 362 (binding: 1)
#>
#> district .n .binding
#> North 362 1
#> Centre 295 2
#> South 269 3
#>
#> # summary() for each indicator at the field size
# A household survey whose estimates are over persons. Each row counts
# its own group per household, and a row with only 'min_respondents'
# asks for 800 interviewed women whatever the targets need.
dhs <- data.frame(
region = rep(c("Coast", "Inland"), 3),
name = rep(c("mcpr", "vaccination", "women"), each = 2),
p = c(0.22, 0.08, 0.77, 0.85, NA, NA),
cv = c(0.10, 0.10, 0.10, 0.10, NA, NA),
deff = c(1.03, 2.71, 1.32, 2.37, NA, NA),
resp_rate = 0.88,
eligible_per_unit = c(0.59, 2.30, 0.09, 0.47, 1.13, 2.89),
min_respondents = c(NA, NA, NA, NA, 800, 800)
)
n_multi(dhs, domains = "region")
#> Multi-indicator sample size (2 domains, separate quotas)
#> n = 2345 (sum of domain quotas)
#> Largest single domain = 1540 (binding: mcpr)
#>
#> region .n .binding
#> Coast 805 women
#> Inland 1540 mcpr
#>
#> # summary() for each indicator at the field size