Learn R Programming

SamplingStrata (version 1.5-4)

updateFrame: Updates the initial frame on the basis of the optimized stratification

Description

Once optimal stratification has been obtained, and new labels have been attributed to initial atomic strata ("newstrata"), it is important to report the new classification of units in the sampling frame by attributing new strata labels to each unit. By executing this function, a new frame will be obtained with the same structure of the old, but with the addition of a new stratum label. The initial frame must contain a variable named 'domainvalue' that indicates the same values of the domain that has been used with the 'optimizeStrata' function. If no domains have been defined, this variable will contains all 1's, but it must exist

Usage

updateFrame(frame, newstrata, writeFiles = FALSE)

Value

A dataframe containing the frame

Arguments

frame

This is the (mandatory) dataframe containing the sampling frame.

newstrata

This is the (mandatory) dataframe containing the information related to the optimisation applied to initial stratification (new labels applied to atomic strata). It is produced by executing the "updateStrata" function.

writeFiles

Flag to write or not the new sampling frame into the working directory. Default is "FALSE"

Author

Giulio Barcaroli

Examples

Run this code
#
# The following example is realistic, but is time consuming
#
if (FALSE) {
library(SamplingStrata)
data(swisserrors)
data(swissstrata)
# optimisation of sampling strata
solution <- optimizeStrata ( 
    errors = swisserrors, 
    strata = swissstrata)
# updating sampling strata with new strata labels
newstrata <- updateStrata(swissstrata, solution, writeFiles = TRUE)
# updating sampling frame with new strata labels
data(swissframe)
framenew <- updateFrame(frame=swissframe, newstrata=newstrata, writeFiles = TRUE)
}

Run the code above in your browser using DataLab