Learn R Programming

surveycore (version 0.8.3)

survey_twophase: Two-Phase Survey Design

Description

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
)

Value

A survey_twophase object.

Arguments

data

A data.frame containing the survey data (all Phase 1 rows, with a logical indicator for Phase 2 membership). Prefer as_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(). Always character(0) in standalone surveycore use.

call

Language object capturing the construction call.

Design variables (<code>@variables</code>)

phase1

Named list containing the Phase 1 design specification (from a survey_taylor object's @variables).

phase2

Named list with optional Phase 2 design columns: ids, strata, probs, fpc — each NULL or a character vector of column names.

subset

Character 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

Run this code
# 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)

Run the code above in your browser using DataLab