Skip to contents

Compute the required sample size for estimating a ratio of two population totals, such as consumption per person or yield per hectare, with a specified margin of error or coefficient of variation.

Usage

n_ratio(r = NULL, ...)

# Default S3 method
n_ratio(
  r = NULL,
  ...,
  cv_num = NULL,
  cv_den = NULL,
  component_cor = NULL,
  moe = NULL,
  cv = NULL,
  rmoe = NULL,
  alpha = 0.05,
  N = Inf,
  deff = 1,
  resp_rate = 1,
  df = NULL,
  plan = NULL
)

# S3 method for class 'svyplan_prec'
n_ratio(r, ..., moe = NULL, cv = NULL, rmoe = NULL)

Arguments

r

For the default method: the anticipated ratio, mean(y) / mean(x). It may be negative but not zero, since a relative precision has no scale at zero. Named r rather than ratio, which already means an allocation ratio in svyplan() profiles. For svyplan_prec objects: a precision result from prec_ratio().

...

Additional arguments passed to methods. Unused arguments are rejected.

cv_num

Coefficient of variation of the numerator variable, sd(y) / abs(mean(y)), taken on the magnitude so it carries no sign. It must be strictly positive. A component with no variation at all is not a sampling problem, and at cv_num = 0 the ratio's own variance comes entirely from the denominator.

cv_den

Coefficient of variation of the denominator variable, sd(x) / abs(mean(x)).

component_cor

Correlation between the numerator and denominator variables across units, in [-1, 1]. Distinct from overlap_cor, which is a correlation between occasions. What makes a ratio precise is component_cor * sign(r) being close to 1 while the two coefficients of variation are similar, so for a positive ratio that means a strongly positive correlation and for a negative ratio a strongly negative one.

moe

Desired margin of error on the ratio scale, the half-width of the confidence interval in the units of r. Specify exactly one of moe, cv, or rmoe.

cv

Target coefficient of variation of the estimated ratio. Specify exactly one of moe, cv, or rmoe.

rmoe

Target margin of error relative to r, so rmoe = 0.05 asks for an interval whose half-width is 5 percent of the ratio. Specify exactly one of moe, cv, or rmoe.

alpha

Significance level, default 0.05.

N

Population size, in the units the ratio is observed on. Inf (default) means no finite population correction.

deff

Design effect of the ratio estimator (> 0). See the section above, which is the one place this differs from n_mean().

resp_rate

Expected response rate, in (0, 1]. Default 1. The rate is for records usable on both components, not on either alone. See the nonresponse section of svyplan-package for what this adjustment does and does not claim.

df

Degrees of freedom of the variance estimator the planned design will have, 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 = "ratio" and method = "linearization":

n

Required sample size, continuous and gross. It carries deff and the 1 / resp_rate inflation, so it counts units to release rather than completed interviews. print() and as.integer() round it up.

se, moe, cv, rmoe

Precision achieved at that n, on the ratio scale.

params

The inputs, plus unit_relvar, the coefficient \(L_R\) defined below.

Details

Write \(CV_y\) and \(CV_x\) for the component coefficients of variation and \(\rho\) for their correlation. The unit relative variance of the ratio is

$$L_R = CV_y^2 + CV_x^2 - 2 \rho \, CV_y CV_x \, \mathrm{sign}(R)$$

which equals \(S_e^2 / \mu_y^2\) for \(e = y - Rx\). The sign(R) factor matters only when the two means differ in sign, and it keeps the result unchanged when either component is negated.

The required responding sample for a target relative standard error \(c\) is

$$n = \frac{\mathrm{deff} \cdot L_R}{c^2 + \mathrm{deff} \cdot L_R / N}$$

and the gross sample is that divided by resp_rate. A margin of error converts to \(c\) exactly, as \(c = \mathrm{moe} / (q |R|)\).

The method is first order. It omits the ratio estimator's \(O(1/n)\) bias and assumes the denominator is far enough from zero that its sampling distribution does not approach it. A large cv_den, a skewed denominator, or a small effective sample all call for simulation rather than this approximation. The interval is the symmetric \(\hat{R} \pm q \cdot SE\), not a Fieller interval.

What this ratio is

The estimand is \(R = T_y / T_x\), the ratio of two totals from one finite population, equivalently the ratio of two means observed on the same sampled units. The numerator and denominator must be measured on the same units, and resp_rate is the expected rate of records usable for both.

It is not the population mean of the unit ratios \(y_i / x_i\), which is an ordinary mean and belongs in n_mean(). It is not a ratio whose parts come from different samples, nor a comparison of two ratios, nor a regression slope.

A rate whose denominator is a subpopulation count, such as a coverage rate among an eligible group, is usually easier to plan as a domain proportion with n_prop(). This function earns its place when the denominator is a continuous per-unit quantity, where there is no domain share to inflate by.

Design effect and clustering

deff is the design effect of the ratio estimator, or first-order equivalently of the linearized variable \(e = y - Rx\). It is not the design effect of the numerator, nor of the denominator, and it cannot be derived from their design effects. The clustering loss on a ratio is routinely an order of magnitude away from the loss on either component, because the correlation that makes a ratio precise also removes much of the between-cluster variation.

For a multistage plan, compute the linearized variable from pilot data and pass its variance components to n_cluster() rather than passing a deff here. See varcomp() and the example below.

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

prec_ratio() for the inverse, n_mean() for a mean, n_cluster() for a multistage design, varcomp() for the linearized variable's components.

Other proportion, mean and ratio functions: n_mean(), n_prop(), prec_mean(), prec_prop(), prec_ratio()

Examples

# Per-capita household consumption: total consumption over total members
n_ratio(r = 420, cv_num = 1.20, cv_den = 0.45, component_cor = 0.65,
        cv = 0.05)
#> Sample size for ratio (linearization)
#> n = 377 (r = 420, unit_relvar = 0.941, cv = 0.050, deff = 1)

# Margin of error on the ratio scale
n_ratio(r = 420, cv_num = 1.20, cv_den = 0.45, component_cor = 0.65,
        moe = 20)
#> Sample size for ratio (linearization)
#> n = 1594 (r = 420, unit_relvar = 0.941, moe = 20.000, deff = 1)

# Relative margin of error, with a design effect and nonresponse
n_ratio(r = 420, cv_num = 1.20, cv_den = 0.45, component_cor = 0.65,
        rmoe = 0.05, deff = 1.3, resp_rate = 0.85)
#> Sample size for ratio (linearization)
#> n = 2211 gross (net: 1879) (r = 420, unit_relvar = 0.941, rmoe = 0.050, deff = 1.30, resp_rate = 0.85)

# A high correlation between the parts makes the ratio cheap to estimate
n_ratio(r = 420, cv_num = 1.20, cv_den = 1.15, component_cor = 0.95,
        cv = 0.05)
#> Sample size for ratio (linearization)
#> n = 57 (r = 420, unit_relvar = 0.14, cv = 0.050, deff = 1)

## Planning a clustered ratio from pilot data
# The homogeneity that matters belongs to e = y - R * x, not to y or x.
set.seed(1)
psu <- rep(1:30, each = 20)
x <- stats::rlnorm(600, 1, 0.4)
y <- 3 * x + stats::rnorm(600, 0, 0.8)
R <- mean(y) / mean(x)
e <- y - R * x
vc <- suppressWarnings(varcomp(e, stage_id = list(psu)))
# varcomp reports an infinite unit_relvar because e has mean zero, so take
# the ratios from it and supply the ratio's own coefficient separately.
n_cluster(stage_cost = c(500, 50), icc = vc$icc,
          unit_relvar = stats::var(e) / mean(y)^2,
          var_ratio = vc$var_ratio, cv = 0.05)
#> Warning: the design selects a single PSU, so no between-PSU variance can be estimated. Raise the budget, the PSU count, or the number of stages
#> Optimal 2-stage allocation
#> field design: n_psu = 1 | n_per_psu = 5 -> total n = 5
#> cv = 0.0471, cost = 750
#> continuous optimum: n_psu = 0.3799752 | n_per_psu = 15.88247 (cv = 0.0500, cost = 492)
#> design df = 0