Creates a srvyr::tbl_svy object from a tbl_sample by first
converting to a survey::svydesign() object via as_svydesign(),
then wrapping with srvyr::as_survey_design().
Arguments
- .data
A
tbl_sampleobject produced byexecute().- ...
Additional arguments passed to
as_svydesign().
Details
This method is registered on the srvyr::as_survey_design() generic,
so it is available when srvyr is loaded.
Random-size Poisson designs (bernoulli, pps_poisson) export to a
pps survey design. These are summarized, grouped, and subset like any
other srvyr design, with Horvitz-Thompson Poisson variances.
See also
as_svydesign() for converting to a survey.design2 object
Examples
library(srvyr)
#>
#> Attaching package: ‘srvyr’
#> The following object is masked from ‘package:stats’:
#>
#> filter
sample <- sampling_design() |>
stratify_by(region, alloc = "proportional") |>
draw(n = 300) |>
execute(bfa_eas, seed = 12345)
# Returns a tbl_svy for use with srvyr verbs
svy <- as_survey_design(sample)
svy |>
group_by(region) |>
summarise(mean_hh = survey_mean(households))
#> # A tibble: 13 × 3
#> region mean_hh mean_hh_se
#> <fct> <dbl> <dbl>
#> 1 Boucle du Mouhoun 50 11.4
#> 2 Cascades 36.8 6.01
#> 3 Centre 131. 7.95
#> 4 Centre-Est 69.6 8.76
#> 5 Centre-Nord 55.2 8.45
#> 6 Centre-Ouest 77.3 9.85
#> 7 Centre-Sud 98.5 14.9
#> 8 Est 52.2 6.38
#> 9 Hauts-Bassins 56.8 10.5
#> 10 Nord 55.7 7.66
#> 11 Plateau-Central 69.2 12.9
#> 12 Sahel 36.3 6.72
#> 13 Sud-Ouest 56.6 14.8