svyplan helps you determine survey sample sizes, allocate samples across strata and clusters, and assess expected precision or power. Start with anticipated outcome variability and design assumptions, then compare plans under different precision targets, budgets, and response rates.
The results describe a planned design. svyplan reports stratum-level design quantities such as sizes, sampling fractions and base weights. It never draws a sample and never attaches selection probabilities or weights to units. When the plan is settled, sondage draws it, and analysis of the realized sample belongs to survey or srvyr.
Installation
Install the development version from GitLab:
install.packages("pak")
pak::pkg_install("gitlab::dickoa/svyplan")A quick example
Suppose a survey must estimate 70% vaccination coverage with a 5 percentage point margin of error. Previous surveys suggest a design effect of 1.5 and an 85% response rate.
library(svyplan)
coverage <- n_prop(
p = 0.70,
moe = 0.05,
deff = 1.5,
resp_rate = 0.85
)
coverage
#> Sample size for proportion (wald)
#> n = 570 gross (net: 485) (p = 0.70, moe = 0.050, deff = 1.50, resp_rate = 0.85)
#> expected cases = 338.8The reported sample is the number of eligible people to approach. The response-rate adjustment increases that number so the expected responding sample meets the precision target. It does not correct nonresponse bias.
Pass the result to the paired precision function to check the same plan:
prec_prop(coverage)
#> Sampling precision for proportion (wald)
#> n = 570 (net: 485)
#> se = 0.0255, moe = 0.0500, cv = 0.0364, rmoe = 0.0714
#> expected cases = 338.8
confint(coverage)
#> 2.5 % 97.5 %
#> 0.65 0.75The interval is an expected interval under the planning values. Survey data and realized design features determine the interval after collection.
Uncertain assumptions should be varied rather than treated as exact:
predict(
coverage,
data.frame(resp_rate = c(0.70, 0.80, 0.90, 1.00))
)
#> resp_rate n se moe cv rmoe
#> 1 0.7 691.4626 0.02551067 0.05 0.03644382 0.07142857
#> 2 0.8 605.0298 0.02551067 0.05 0.03644382 0.07142857
#> 3 0.9 537.8042 0.02551067 0.05 0.03644382 0.07142857
#> 4 1.0 484.0238 0.02551067 0.05 0.03644382 0.07142857Find the right guide
| Planning task | Functions | Guide |
|---|---|---|
| Start with sample size and precision |
n_prop(), n_mean(), prec_prop(), prec_mean()
|
Getting started |
| Choose a precision target or ratio estimand |
n_prop(), n_mean(), n_ratio()
|
Precision targets |
| Combine indicators or domain requirements |
n_multi(), prec_multi()
|
Multiple indicators and domains |
| Construct strata and allocate a sample |
strata_bound(), n_alloc(), prec_alloc()
|
Stratification and allocation |
| Meet several allocation constraints | n_alloc() |
Joint allocation |
| Plan a clustered survey |
varcomp(), n_cluster(), design_effect(), effective_n(), design_df()
|
Multistage surveys |
| Plan screening or nonresponse follow-up |
n_twophase(), prec_twophase()
|
Two-phase surveys |
| Plan changes, averages, panels, and rotations |
n_change(), n_pooled(), n_panel(), design_rotation(), design_schedule()
|
Repeated surveys |
| Plan a detectable comparison |
power_prop(), power_mean(), power_did()
|
Power |
Function reference pages document every argument and returned component. The package website collects the reference and the task-oriented guides. Report problems through the issue tracker.
