Compute the sample size per occasion required to estimate the change in a mean, a proportion or a ratio of totals between two occasions of the same population with a specified margin of error or coefficient of variation, given how far the two samples overlap.
Usage
n_change(var = NULL, ...)
# Default S3 method
n_change(
var = NULL,
...,
sd = NULL,
p = NULL,
r = NULL,
cv_num = NULL,
cv_den = NULL,
component_cor = NULL,
change = NULL,
moe = NULL,
cv = NULL,
rmoe = NULL,
alpha = 0.05,
N = Inf,
deff = 1,
resp_rate = 1,
eligibility_rate = 1,
ratio = 1,
overlap = 0,
overlap_cor = 0,
overlap_draw = c("fixed", "independent"),
df = NULL,
plan = NULL
)
# S3 method for class 'svyplan_prec'
n_change(var, ..., moe = NULL, cv = NULL, rmoe = NULL)Arguments
- var
For the default method: the population variance \(S^2\) on each occasion, one value for both or one per occasion. Estimate from a pilot study, a previous round, or published data. Supply this,
porr. Forsvyplan_precobjects: a precision result fromprec_change().- ...
Additional arguments passed to methods. Unused arguments are rejected.
- sd
Population standard deviation on each occasion, an alternative spelling of
var. Supply exactly one ofvarorsd.- p
The two occasion proportions,
c(p1, p2), as an alternative tovar. The occasion variances are then \(Np(1-p)/(N-1)\), the same finite population variancen_prop()uses, and the change is \(p_2 - p_1\), sochangeis determined and must not be supplied. Sizing for a change in a proportion is the ordinary case for a repeated household survey tracking an indicator.- r
The two occasion ratios of totals,
c(r1, r2), eachmean(y) / mean(x)as inn_ratio(), as an alternative tovarandp. The change is \(r_2 - r_1\), sochangeis determined and must not be supplied. See the section on a ratio of totals.- cv_num
Coefficient of variation of the ratio's numerator variable, one value for both occasions or one per occasion. Used with
ronly.- cv_den
Coefficient of variation of the ratio's denominator variable, one value for both occasions or one per occasion. Used with
ronly.- component_cor
Correlation between the ratio's numerator and denominator on one unit, in \([-1, 1]\), one value or one per occasion. Used with
ronly. It is notoverlap_cor, which correlates the occasions.- change
Expected change, \(\mu_2 - \mu_1\), on the
varscale. It may be negative. Required whencvorrmoeis specified, both being defined against it. Determined bypon the proportion scale.- moe
Desired margin of error on the change, the half-width of its confidence interval, in the units the change is measured in. Specify exactly one of
moe,cv, orrmoe.- cv
Target standard error relative to the change, so
cv = 0.10asks for a standard error one tenth of the change being measured. Requireschange. Specify exactly one ofmoe,cv, orrmoe.- rmoe
Target margin of error relative to the change, so
rmoe = 0.25asks for a 95 percent interval whose half-width is a quarter of the change. It ismoe / abs(change)and requireschange. Specify exactly one ofmoe,cv, orrmoe.- alpha
Significance level, default 0.05.
- N
Population size.
Inf(default) means no finite population correction. One value covers both occasions, and two are accepted only atoverlap = 0, where the occasions are independent and may legitimately be different populations. A positiveoverlaprequires a singleN, since units can only be shared by samples drawn from one population.- deff
Design effect multiplier (> 0), applied to the variance of the change rather than to either occasion separately. See Details.
- resp_rate
Expected response rate among eligible units, in (0, 1]. Default 1 (no adjustment). Each occasion's size is inflated by
1 / resp_rate. It is a single round's response, not attrition across a panel. See the nonresponse section of svyplan-package for what the rate counts and what this adjustment does and does not claim.- eligibility_rate
Share of issued units in scope, such as dwellings found occupied, in (0, 1]. Default 1. It applies to both occasions, and with a finite
Nthe population in scope isN * eligibility_rate. See the nonresponse section of svyplan-package.- ratio
Size of the first occasion relative to the second, so
ratio = 2sizes a large baseline against a smaller follow-up. Default 1, equal occasions, which returns a single size. Becauseoverlapis measured against the first occasion it cannot exceed1 / ratioonce the first occasion is the larger.- overlap
Fraction of the first occasion's responding sample carried into the second, in \([0, 1]\).
0(default) drops the covariance entirely and reproduces the two-independent-samples size.1means every responding unit of the first occasion is measured again, which is a full panel when the occasions are the same size. A rotation pattern determines the issued figure,(D - 1) / Dbetween consecutive occasions of an in-for-Dschedule, anddesign_overlap()computes it at every lag, an occasion there being a period of the rotation. The two are the same number at full response only. Seeprec_change()on what a response rate below 1 does to this reading.- overlap_cor
Correlation between the two occasions among the overlapping units, in \([0, 1]\). Default 0, which makes overlap worthless, since it is the product
overlap * overlap_corthat reduces the size, so a full panel of uncorrelated measurements saves nothing. On the proportion scale two Bernoulli marginals bound the correlation they can have, and a value above that bound is rejected. For a ratio it is the correlation of the ratio's linearized variable. See the section on a ratio of totals.- overlap_draw
How the shared units are drawn,
"fixed"(default) for a fixed count drawn with the rest of each occasion's sample, or"independent"for a retained panel topped up on each occasion by a fresh sample drawn independently of it from the whole frame. Seeprec_change()for the variance under each.- df
Degrees of freedom of the variance estimator the planned design will have, typically sampled PSUs minus strata, and available from
design_df(). It switches the interval quantile from normal to t.NULL(default) applies no adjustment.- plan
Optional
svyplan()object providing design defaults.
Value
A svyplan_n object with type = "change":
nRequired size per occasion, continuous and gross. It already carries
deffand the1 / (resp_rate * eligibility_rate)inflation, so it counts the units to release on each occasion, not the completed interviews. A single value whenratio = 1, otherwise one per occasion.$nandas.double()keep the unrounded value, which is what makes the round trip throughprec_change()exact, whereasprint()rounds up to the whole units you would field. A positive overlap means the occasions are not disjoint, so the number of distinct units sampled is less than the sum. The number of interviews is not, since a shared unit is interviewed on both occasions.se,moe,cv,rmoePrecision the design achieves at that size, the same values
prec_change()reports for the same inputs.cvandrmoeareNAunless the change is known.paramsThe validated inputs, including whichever of
moe,cv, orrmoewas the target. Dispersion is always stored asvar, a pair, andpis kept as well when the proportion scale was used. A ratio keepsr, its three moments and theunit_relvarof each occasion,varthen being the variance of its linearized variable.
Details
Level or change
A repeated survey publishes three things, and each is sized by its own
function. The level at one occasion is n_mean() or n_prop() and is a
function of that occasion's size alone. The change between two occasions
is this function, which overlap improves while the covariance it induces
is positive (see the finite population case below). The average of
several
occasions is n_pooled(), which overlap works against, because the
covariance it induces is subtracted in a difference and added in a sum. A
design serving more than one of the three takes the largest of the three
requirements, since none dominates.
The change variance is \(A/n_2 + B\) in the net second-occasion size, where
$$A = v_1/r + v_2 - 2\,\mathrm{overlap}\,\rho\sqrt{v_1v_2}, \qquad B = -\frac{v_1 + v_2 - 2\rho\sqrt{v_1v_2}}{N},$$
with \(r\) the ratio, \(\rho\) the overlap_cor and \(N\) the
population in scope, N * eligibility_rate. The finite
population terms collect into \(B\), a constant no sample size can
move, so the target inverts in closed form rather than by search. Both
coefficients are written above for a positive overlap. At
overlap = 0 the covariance is dropped entirely, so
\(A = v_1/r + v_2\) and \(B = -v_1/N_1 - v_2/N_2\), which is what
lets the two occasions come from different populations. See
prec_change() for the variance itself and for the piecewise statement.
Overlap and correlation only ever act together. At overlap_cor = 0 the
size is what two independent samples would need whatever the overlap, and
the two arguments are worth setting from the same evidence. A rotation
pattern fixes overlap, and a previous round of the same survey is what
identifies overlap_cor.
The design effect is that of the change, not of either occasion. A clustered design revisiting the same clusters has a smaller one than a design that reclusters between occasions, because the cluster effects partly cancel in the difference. Passing an occasion's design effect here therefore over-sizes a design that keeps its clusters.
A ratio of totals
A ratio \(R = \bar Y / \bar X\), such as an
unemployment rate, enters through its linearized variable
\(z = (y - Rx)/\bar X\), whose variance on each
occasion is \(R^2 L\), with \(L\) the unit relative variance
n_ratio() reports. That variance takes the place of var in every
formula here and is what params$var records. overlap_cor is then the
correlation of \(z\) between the occasions, not of the numerator. The
two are close when the denominator is stable, as for an unemployment
rate over a steady labor force, and the first can be derived from the
cross-occasion correlations of the two components where those are known.
deff is the design effect of the change in \(z\).
When no size is enough, and when any size is
At positive overlap, the two responding samples must fit their shared
finite population. A target whose required sizes violate
n1_net + n2_net - overlap * n1_net <= N is unattainable at the stated
overlap, even if each individual sample fits, and so is one whose whole
size ceiling(n) breaks the bound. Increase overlap or relax the
precision target. See prec_change() for the variance and bound.
Two boundaries are worth knowing before reading a result. Full overlap with unit correlation at equal sizes and variances leaves the change with no sampling variance at all, since the same units are measured twice, so no size is identified and the function says so rather than returning zero.
At a finite N with equal occasions and full response, the requirement
rises toward N but never past it, because two censuses of one
population measure the change exactly. Every target is attainable there,
and a demanding one simply returns a near-census. Unequal occasions or a
response rate below 1 remove that guarantee, since the size released is
then larger than the sample carrying the precision, and a target beyond
reach is reported as unattainable.
Sizing for a change, a level, or an average
Overlap improves a change and does nothing for the level at a single
occasion, which is a function of that occasion's size alone. A fresh
sample each round is not the reverse of this. It does nothing for the
level either, and the two designs give the same single-occasion
precision at the same size. What overlap does work against is an
estimate pooled across occasions, an annual average of quarterly rounds
say, because the covariance it induces is subtracted in a difference and
added in a sum. That holds while the covariance is positive, which needs
the overlap to exceed the sampling fraction when N is finite. See
prec_pooled() for the boundary. A design serving more than one of the
three is sized by
taking the largest of n_change(), n_pooled() and the corresponding
n_mean() or n_prop() requirement, since none dominates.
See also
prec_change() for the inverse (compute precision from a size),
n_mean() and n_prop() for a single occasion, power_mean() and
power_prop() to frame the same overlap as a hypothesis test.
Other repeated survey functions:
design_overlap(),
design_rotation(),
design_schedule(),
n_panel(),
n_pooled(),
prec_change(),
prec_panel(),
prec_pooled()
Examples
# Two independent occasions
n_change(var = 100, moe = 2)
#> Sample size for change (mean scale)
#> n = 193 per occasion (var = 100, 100, moe = 2, deff = 1)
#> No between-occasion covariance (overlap x overlap_cor = 0)
# A half-overlapping panel correlated 0.6 needs fewer units per occasion
n_change(var = 100, moe = 2, overlap = 0.5, overlap_cor = 0.6)
#> Sample size for change (mean scale)
#> n = 135 per occasion (var = 100, 100, moe = 2, deff = 1)
#> overlap = 0.5, overlap_cor = 0.6 (70.0% of the independent variance)
# A 6-point rise in a proportion, resolved to within 2 points
n_change(p = c(0.30, 0.36), moe = 0.02)
#> Sample size for change (proportion scale)
#> n = 4230 per occasion (p = 0.3 to 0.36, moe = 0.02, deff = 1)
#> No between-occasion covariance (overlap x overlap_cor = 0)
# The same target under a consecutive-month CPS-style overlap of 0.75
n_change(p = c(0.30, 0.36), moe = 0.02, overlap = 0.75, overlap_cor = 0.5)
#> Sample size for change (proportion scale)
#> n = 2646 per occasion (p = 0.3 to 0.36, moe = 0.02, deff = 1)
#> overlap = 0.75, overlap_cor = 0.5 (62.5% of the independent variance)
# A change in an unemployment rate between two quarters, to within half
# a point, with 80 percent of the sample shared
n_change(r = c(0.0615, 0.0646), cv_num = 4.9, cv_den = 0.73,
component_cor = 0.15, moe = 0.005, overlap = 0.8,
overlap_cor = 0.54)
#> Sample size for change (ratio of totals)
#> n = 16311 per occasion (r = 0.0615 to 0.0646, moe = 0.005, deff = 1)
#> overlap = 0.8, overlap_cor = 0.54 (56.9% of the independent variance)
# Relative target: resolve the change to within a quarter of itself
n_change(var = 100, change = 5, rmoe = 0.25)
#> Sample size for change (mean scale)
#> n = 492 per occasion (var = 100, 100, change = 5, rmoe = 0.250, deff = 1)
#> No between-occasion covariance (overlap x overlap_cor = 0)
# A large baseline against a smaller follow-up
n_change(var = 100, moe = 2, ratio = 2)
#> Sample size for change (mean scale)
#> n = 289 then 145 (var = 100, 100, moe = 2, deff = 1)
#> No between-occasion covariance (overlap x overlap_cor = 0)
# With FPC, design effect, and response
n_change(var = 100, moe = 2, N = 20000, deff = 1.5, resp_rate = 0.8)
#> Sample size for change (mean scale)
#> n = 356 per occasion (net: 285) (var = 100, 100, moe = 2, deff = 1.50, resp_rate = 0.80)
#> No between-occasion covariance (overlap x overlap_cor = 0)
# A small frame with a retained panel and independent fresh draws
n_change(var = 100, moe = 4, N = 400, overlap = 0.5, overlap_cor = 0.8,
overlap_draw = "independent")
#> Sample size for change (mean scale)
#> n = 28 per occasion (var = 100, 100, moe = 4, deff = 1)
#> overlap = 0.5, overlap_cor = 0.8 (60.0% of the independent variance), independent draws