Skip to contents

population_truth() computes, on the realized population, the totals, means and variances a survey of it estimates, and the homogeneity of the outcome within households. None of them depends on how the households are cut into EAs.

frame_truth() computes the values a design on a frame depends on. They are the share of the population the frame misses, the truth over the full and the covered population, and the homogeneity of the outcome within the EAs and households of the frame. The homogeneity depends on the size and shape of the EAs, so frames built on one population give different values for the same persons, and on the frame's measure of size, so a stale frame gives other values than an exact one.

Both are computed from the population, not taken from the arguments of sim_outcome(), since a spatial field, household structure, unequal EA sizes and a binary threshold all change the realized values.

Usage

population_truth(x, outcome, by = NULL)

frame_truth(frame, outcome, mos = "mos", by = NULL, population = NULL)

Arguments

x

A decoupage_population with the outcome, or a decoupage_frame, whose population is used.

outcome

The name of an outcome of the population's persons, a numeric or logical column with a finite value for every person. A factor is refused, so convert it first.

by

For population_truth(), a column of the households defining domains, such as "urban", "region" or "district". For frame_truth(), a column of the EAs, such as "stratum" or "urban". NULL (default) gives the whole population.

frame

For frame_truth(), a decoupage_frame.

mos

For frame_truth(), the column of the frame (frame$frame) EAs are drawn in proportion to, "mos" by default, the measure of size the frame records. A planner's frame holds no persons, so a design by persons needs that column added to it first.

population

For frame_truth(), a newer copy of the frame's population, such as one with an outcome added after the frame was built, or NULL (default) for the copy the frame holds. Its households must be those of the frame.

Value

population_truth() returns a data frame with one row per domain, holding domain, the counts households and persons, the outcome's total, mean, variance and unit_relvar (the variance over the squared mean), and the analysis of variance intraclass correlation within households (icc_household).

frame_truth() returns a data frame with one row per domain, holding

  • domain, and eas, households and persons, the counts of the population.

  • eas_frame, the EAs of the frame with a positive measure of size, and households_missed and persons_missed, the shares of the population in no such EA.

  • total and mean of the outcome over the population, and total_covered and mean_covered over its covered part.

  • unit_relvar, icc and var_ratio, the components of the EA stage, and icc_ssu and var_ratio_ssu, those of the household stage, on the covered population.

  • icc_ea, the analysis of variance intraclass correlation within the EAs, on the covered population.

Details

A domain of population_truth() is a set of households, so a person in an urban household counts as urban whatever the EA. A domain of frame_truth() is a set of EAs, so the urban domain holds the persons of EAs with a majority of urban households.

The components of frame_truth() follow the complete-frame definitions of svyplan::varcomp(), so they go to svyplan::n_cluster() and svyplan::n_alloc() as they are. EAs are drawn with probability proportional to mos, read from the frame, so stale sizes change the components as they would for a planner. An EA whose mos is 0 cannot be drawn, and its persons count as missed. Within an EA, icc and var_ratio serve a design that draws persons, or households with all their persons, by simple random sampling, as the EA stage of svyplan::varcomp(y ~ ea) and of svyplan::varcomp(y ~ ea / household) give the same values. icc_ssu and var_ratio_ssu are the household stage of the three-stage design, with persons drawn within households. The components are those of the covered population, the one a sample from the frame reaches. A study that targets the full population compares its estimates with total and mean, and one that targets the covered population with total_covered and mean_covered.

A quantity whose denominator is 0 is NA, and the others are kept. Where a domain's outcome is constant, its variance and unit_relvar are 0, while var_ratio, var_ratio_ssu, icc_household and icc_ea are NA. Where its mean is 0, unit_relvar is NA. An icc or icc_ssu is NA when its stage has no variance to split, and it can be 1 for a constant outcome, since EA totals still vary against a measure of size that does not count persons. The ANOVA terms are NA for a domain of one group, or where no group holds two persons. A domain with no covered person has NA for mean_covered and every component, and a domain whose EAs hold no person has NA for its mean and shares missed as well. Each case gives one warning that names the quantities and the domains. svyplan::varcomp() reports a constant outcome as icc = 0 and var_ratio = 1 by convention, and a mean of 0 as infinite relvariances.

The intraclass correlations icc_household and icc_ea are the one-way analysis of variance estimates with unequal group sizes, the measure most published tables report. They coincide with icc only for EAs of equal size.

The variance has denominator N - 1.

References

Valliant, R., Dever, J. A., and Kreuter, F. (2018). Practical Tools for Designing and Weighting Survey Samples (2nd ed.). Springer. Chapter 9. doi:10.1007/978-3-319-93632-1

See also

sim_population().

Other simulation functions: populate_frame(), simulate

Examples

pop <- sim_territory(n_regions = 1, n_districts = 2, width = 6000,
  height = 4000, seed = 1) |>
  sim_households(n = 800, seed = 2) |>
  sim_outcome("y", components = c(spatial = 0.2, household = 0.2,
    person = 0.6), range = 1000, seed = 3)
population_truth(pop, "y")
#>   domain households persons    total     mean variance unit_relvar
#> 1    all        800    4089 405065.2 99.06217 377.5187  0.03847005
#>   icc_household
#> 1     0.3478141
f <- sim_frame(pop, target = 60, max = 100, seed = 4)
frame_truth(f, "y")
#>   domain eas eas_frame households persons households_missed persons_missed
#> 1    all  13        13        800    4089                 0              0
#>      total     mean total_covered mean_covered unit_relvar       icc var_ratio
#> 1 405065.2 99.06217      405065.2     99.06217  0.03847005 0.1234051  1.051832
#>     icc_ssu var_ratio_ssu     icc_ea
#> 1 0.8583098      5.324824 0.08572644
stale <- sim_frame_defects(f, years = 10, undercoverage = 0.1, seed = 5)
frame_truth(stale, "y")
#>   domain eas eas_frame households persons households_missed persons_missed
#> 1    all  13        12        800    4089            0.0875     0.08706285
#>      total     mean total_covered mean_covered unit_relvar       icc var_ratio
#> 1 405065.2 99.06217      368514.1     98.71795  0.03911876 0.4519211  1.732398
#>     icc_ssu var_ratio_ssu     icc_ea
#> 1 0.8554217      5.303313 0.08994587