A survey design object for two-phase (double) sampling. Create with
as_survey_twophase().
Usage
survey_twophase(
data = data.frame(),
metadata = survey_metadata(),
variables = list(),
groups = character(0),
call = NULL
)Arguments
- data
A
data.framecontaining the survey data (all Phase 1 rows, with a logical indicator for Phase 2 membership). Preferas_survey_twophase()over calling this constructor directly.- metadata
A survey_metadata object. Inherited from the Phase 1 design when using
as_survey_twophase().- variables
A named list of design specification (phase1, phase2, subset, method). Set automatically by
as_survey_twophase().- groups
Set by surveytidy's
group_by(). Alwayscharacter(0)in standalone surveycore use.- call
Language object capturing the construction call.
Design variables (@variables)
phase1Named list containing the Phase 1 design specification (from a
survey_taylorobject's@variables).phase2Named list with optional Phase 2 design columns:
ids,strata,probs,fpc— eachNULLor a character vector of column names.subsetCharacter string naming the logical column that indicates Phase 2 membership (
TRUE= selected into Phase 2).method"full","approx", or"simple".
See also
as_survey_twophase() to create a survey_twophase object.
Other constructors:
as_survey(),
as_survey_nonprob(),
as_survey_replicate(),
as_survey_twophase(),
survey_data(),
survey_glm(),
survey_glm_fit(),
survey_nonprob(),
survey_replicate(),
survey_taylor()
Examples
# Prefer as_survey_twophase() over calling survey_twophase() directly
set.seed(1)
df <- data.frame(id = 1:100, y = rnorm(100), x = rnorm(100),
wt = runif(100, 1, 3),
in_phase2 = c(rep(TRUE, 40), rep(FALSE, 60)))
phase1 <- as_survey(df, weights = wt)
d <- as_survey_twophase(phase1, subset = in_phase2)
class(d)
#> [1] "surveycore::survey_twophase" "surveycore::survey_base"
#> [3] "S7_object"
