cong2_estima_media: Estimate the population mean under two-stage cluster sampling

View source: R/cap06-conglomerados-2etapas.R

cong2_estima_mediaR Documentation

Estimate the population mean under two-stage cluster sampling

Description

Estimates the population mean from a two-stage cluster sample (a sample of clusters – UPA – followed by a sample of elements within each sampled cluster – USA), when the total population size M is known, following Eqs. (6.12)-(6.18) of the course notes.

Usage

cong2_estima_media(
  dados = NULL,
  Mi = NULL,
  mi = NULL,
  yi_bar = NULL,
  si2 = NULL,
  Nc,
  M,
  conf = 0.95,
  ...
)

Arguments

dados

A data.frame (or list of data frames / a list with one element per cluster) with, for every sampled element, at least the columns conglomerado (cluster id), Mi (cluster population size), and y (the measured value for that element). Alternatively, supply Mi, mi, yi_bar, and si2 directly (pre-summarised per cluster) – see Details.

Mi

Optional numeric vector with the population size of each sampled cluster (used instead of dados when the data are already summarised per cluster).

mi

Optional numeric vector with the number of sampled elements in each cluster.

yi_bar

Optional numeric vector with the sample mean of each cluster.

si2

Optional numeric vector with the sample variance within each cluster (Eq. 6.15).

Nc

Total number of clusters in the population.

M

Total number of elements in the population.

conf

Confidence level, default 0.95.

...

Ignored (see package overview on tolerated extra arguments).

Details

Two calling styles are supported: (1) pass raw per-element data via dados (a data.frame with one row per sampled element), or (2) pass already-summarised per-cluster vectors Mi, mi, yi_bar, si2 directly. The second style is convenient when a problem statement (as in a textbook exercise) already gives per-cluster summaries instead of raw data – any of dados/Mi/mi/yi_bar/si2 not needed for the chosen style are simply ignored.

Value

A sampling_result object with the estimated mean, its two-part variance decomposition, and confidence interval.

References

Cochran, W.G. (1977). Sampling Techniques, 3rd ed. Wiley, cap. 10.

Examples

Mi <- c(50, 65, 45, 48, 52, 58, 42, 66, 40, 56)
mi <- c(10, 13, 9, 10, 10, 12, 8, 13, 8, 11)
yi_bar <- c(5.4, 4.0, 5.6667, 4.8, 4.3, 3.8333, 5.0, 3.8462, 4.875, 5.0)
si2 <- c(11.3778, 10.6667, 16.75, 13.2889, 11.1222, 14.8788, 5.1429,
         4.3077, 6.125, 11.8)
cong2_estima_media(Mi = Mi, mi = mi, yi_bar = yi_bar, si2 = si2,
                    Nc = 90, M = 4500)

sampleone documentation built on Oct. 13, 2026, 5:07 p.m.