shuffle_replicates {svrep} | R Documentation |
Shuffle the order of replicates in a survey design object
Description
Shuffle the order of replicates in a survey design object. In other words, the order of the columns of replicate weights is randomly permuted.
Usage
shuffle_replicates(design)
Arguments
design |
A survey design object, created with either the |
Value
An updated survey design object, where the order of the replicates has been shuffled (i.e., the order has been randomly permuted).
Examples
library(survey)
set.seed(2023)
# Create an example survey design object
sample_data <- data.frame(
STRATUM = c(1,1,1,1,2,2,2,2),
PSU = c(1,2,3,4,5,6,7,8)
)
survey_design <- svydesign(
data = sample_data,
strata = ~ STRATUM,
ids = ~ PSU,
weights = ~ 1
)
rep_design <- survey_design |>
as_fays_gen_rep_design(variance_estimator = "Ultimate Cluster")
# Inspect replicates before shuffling
rep_design |> getElement("repweights")
# Inspect replicates after shuffling
rep_design |>
shuffle_replicates() |>
getElement("repweights")
[Package svrep version 0.6.4 Index]