Package: SamplingStrata 1.6

SamplingStrata: Optimal Stratification of Sampling Frames for Multipurpose Sampling Surveys

In the field of stratified sampling design, this package offers an approach for the determination of the best stratification of a sampling frame, the one that ensures the minimum sample cost under the condition to satisfy precision constraints in a multivariate and multidomain case. This approach is based on the use of the genetic algorithm: each solution (i.e. a particular partition in strata of the sampling frame) is considered as an individual in a population; the fitness of all individuals is evaluated applying the Bethel-Chromy algorithm to calculate the sampling size satisfying precision constraints on the target estimates. Functions in the package allows to: (a) analyse the obtained results of the optimisation step; (b) assign the new strata labels to the sampling frame; (c) select a sample from the new frame accordingly to the best allocation. Functions for the execution of the genetic algorithm are a modified version of the functions in the 'genalg' package.

Authors:Giulio Barcaroli, Marco Ballin, Hanjo Odendaal, Daniela Pagliuca, Egon Willighagen, Diego Zardetto

SamplingStrata_1.6.tar.gz
SamplingStrata_1.6.zip(r-4.7)SamplingStrata_1.6.zip(r-4.6)SamplingStrata_1.6.zip(r-4.5)
SamplingStrata_1.6.tgz(r-4.6-x86_64)SamplingStrata_1.6.tgz(r-4.6-arm64)SamplingStrata_1.6.tgz(r-4.5-x86_64)SamplingStrata_1.6.tgz(r-4.5-arm64)
SamplingStrata_1.6.tar.gz(r-4.7-arm64)SamplingStrata_1.6.tar.gz(r-4.7-x86_64)SamplingStrata_1.6.tar.gz(r-4.6-arm64)SamplingStrata_1.6.tar.gz(r-4.6-x86_64)
SamplingStrata_1.6.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
SamplingStrata/json (API)

# Install 'SamplingStrata' in R:
install.packages('SamplingStrata', repos = c('https://barcaroli.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/barcaroli/samplingstrata/issues

Pkgdown/docs site:https://barcaroli.github.io

Uses libs:
  • c++– GNU Standard C++ Library v3
Datasets:
  • errors - Precision constraints (maximum CVs) as input for Bethel allocation
  • nations - Dataset 'nations'
  • strata - Dataframe containing information on strata in the frame
  • swisserrors - Precision constraints (maximum CVs) as input for Bethel allocation
  • swissframe - Dataframe containing information on all units in the population of reference that can be considered as the final sampling unit
  • swissmunicipalities - The Swiss municipalities population
  • swissstrata - Dataframe containing information on strata in the swiss municipalities frame

On CRAN:

Conda:

cpp

8.20 score 16 stars 200 scripts 572 downloads 32 exports 12 dependencies

Last updated from:800340cb7d. Checks:11 WARNING, 2 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64WARNING164
linux-devel-x86_64WARNING164
source / vignettesOK242
linux-release-arm64WARNING194
linux-release-x86_64WARNING195
macos-release-arm64WARNING104
macos-release-x86_64WARNING215
macos-oldrel-arm64WARNING123
macos-oldrel-x86_64WARNING244
windows-develWARNING146
windows-releaseWARNING172
windows-oldrelWARNING122
wasm-releaseOK141

Exports:adjustSizeaggrStrata2aggrStrataSpatialassignStrataLabelbethelbuildErrorsDFbuildFrameDFbuildFrameSpatialbuildStrataDFbuildStrataDFSpatialcheckInputcomputeGammaevalSolutionexpected_CVKmeansSolutionKmeansSolution2KmeansSolutionSpatialoptimizeStrataoptimizeStrata2optimizeStrataSpatialoptimStrataplotSamprateplotStrata2dprocBethelselectSampleselectSampleSpatialselectSampleSystematicsummaryStratatuneParametersupdateFrameupdateStratavar.bin

Dependencies:cachemcodetoolsdoParallelfastmapforeachglueiteratorsmemoisepbapplyRcpprlangSamplingBigData

Optimization of sampling strata with the SamplingStrata package
Introduction | Procedural steps | Preparation of inputs required by the optimization step | Frame | Strata | Precision constraints | Optimization | Method 'atomic' | Method 'continuous' | Analysis of the obtained solution | Strata structure | Evaluation by simulation | Adjustment of the final sampling size | Sample selection | Handling 'take-all' strata | Appendix - Methodological approach | References

Last update: 2025-10-05
Started: 2025-03-02

SamplingStrata workflow with drake
Workflow definition | Execution of the workflow | Output inspection

Last update: 2025-10-05
Started: 2020-08-11

Spatial sampling with SamplingStrata
Optimization with the spatial method | Example | References

Last update: 2025-10-05
Started: 2020-01-14

Use of models in SamplingStrata
Handling Anticipated Variance | Handling heteroscedasticity in linear models | Example | References

Last update: 2025-10-05
Started: 2020-01-14

Optimization of sampling strata with the SamplingStrata package
Introduction | Procedural steps | Preparation of inputs required by the optimization step | Frame | Strata | Precision constraints | Optimization | Method 'atomic' | Method 'continuous' | Analysis of the obtained solution | Strata structure | Evaluation by simulation | Adjustment of the final sampling size | Sample selection | Handling 'take-all' strata | Appendix - Methodological approach | References

Last update: 2025-03-02
Started: 2018-07-03

Readme and manuals

Help Manual

Help pageTopics
Adjustment of the sample size in case it is externally givenadjustSize
Builds the "strata" dataframe containing information on target variables Y's distributions in the different strata, starting from a frameaggrStrata2
Builds the "strata" dataframe containing information on target variables Y's distributions in the different strata, starting from a frame where units are spatially correlated.aggrStrataSpatial
Function to assign the optimized strata labelsassignStrataLabel
Multivariate optimal allocationbethel
Builds the "errors" dataframe containing information on the precision constraints set on the target variablesbuildErrorsDF
Builds the "sampling frame" dataframe from a dataset containing information on all the units in the population of referencebuildFrameDF
Builds the "sampling frame" dataframe from a dataset containing information all the units in the population of reference including spatialbuildFrameSpatial
Builds the "strata" dataframe containing information on target variables Y's distributions in the different strata, starting from sample data or from a framebuildStrataDF
Builds the "strata" dataframe containing information on target variables Y's distributions in the different strata, starting from sample data or from a framebuildStrataDFSpatial
Checks the inputs to the package: dataframes "errors", "strata" and "sampling frame"checkInput
Function that allows to calculate a heteroscedasticity index, together with associate prediction variance, to be used by the optimization step to correctly evaluate the standard deviation in the strata due to prediction errors.computeGamma
Precision constraints (maximum CVs) as input for Bethel allocationerrors
Evaluation of the solution produced by the function 'optimizeStrata' by selecting a number of samples from the frame with the optimal stratification, and calculating average CV's on the target variables Y's.evalSolution
Expected coefficients of variation of target variables Yexpected_CV
Initial solution obtained by applying kmeans clustering of atomic strataKmeansSolution
Initial solution obtained by applying kmeans clustering of frame unitsKmeansSolution2
Initial solution obtained by applying kmeans clustering of frame unitsKmeansSolutionSpatial
Dataset 'nations'nations
Best stratification of a sampling frame for multipurpose surveysoptimizeStrata
Best stratification of a sampling frame for multipurpose surveys (only with continuous stratification variables)optimizeStrata2
Best stratification of a sampling frame for multipurpose surveys considering also spatial correlationoptimizeStrataSpatial
Optimization of the stratification of a sampling frame given a sample surveyoptimStrata
Plotting sampling rates in the different strata for each domain in the solution.plotSamprate
Plot bivariate distibutions in strataplotStrata2d
Procedure to apply Bethel algorithm and select a sample from given strataprocBethel
Selection of a stratified sample from the frame with srswor methodselectSample
Selection of geo-referenced points from the frameselectSampleSpatial
Selection of a stratified sample from the frame with systematic methodselectSampleSystematic
Dataframe containing information on strata in the framestrata
Information on strata structuresummaryStrata
Precision constraints (maximum CVs) as input for Bethel allocationswisserrors
Dataframe containing information on all units in the population of reference that can be considered as the final sampling unit (this example is related to Swiss municipalities)swissframe
The Swiss municipalities populationswissmunicipalities
Dataframe containing information on strata in the swiss municipalities frameswissstrata
Execution and compared evaluation of optimization runstuneParameters
Updates the initial frame on the basis of the optimized stratificationupdateFrame
Assigns new labels to atomic strata on the basis of the optimized aggregated strataupdateStrata
Allows to transform a continuous variable into a categorical ordinal one by applying a modified version of the k-means clustering function in the 'stats' package.var.bin