The user can indicate the number of samples that must be selected by the optmized frame. First, the true values of the parameters are calculated from the frame. Then, for each sample the sampling estimates are calculated, together with the differences between them and the true values of the parameters. At the end, an estimate of the CV is produced for each target variable, in order to compare them with the precision constraints set at the beginning of the optimization process. If the flag 'writeFiles' is set to TRUE, boxplots of distribution of the CV's in the different domains are produced for each Y variable ('cv.pdf'), together with boxplot of the distributions of differences between estimates and values of the parameters in the population ('differences.pdf').

evalSolution(frame,
    outstrata,
    nsampl=100,
    cens=NULL,
    writeFiles=TRUE,
    outputFolder = file.path(getwd(),"simulation"),
    progress=TRUE)

Arguments

frame

The frame to which the optimal stratification has been applied.

outstrata

The new (aggregated) strata generated by the function 'optimizeStrata'.

nsampl

The number of samples to be drawn from the frame.

cens

A dataframe containing units to be selected in any cases.

writeFiles

A flag to write in the output directory the outputs of the function. Default is TRUE.

outputFolder

A path to a directory ot be used for the outputs. It will be emptied beforehand!

progress

If set to TRUE, a progress bar is visualised during the execution. Default is TRUE.

Value

A list containing (i) the CV distribution in the domains, (ii) the bias distribution in the domains, (iii) the dataframe containing the sampling estimates by domain

Author

Giulio Barcaroli

Examples

if (FALSE) {
library(SamplingStrata)
data(swisserrors)
data(swissstrata)
solution <- optimizeStrata (
  errors = swisserrors,
  strata = swissstrata,
)
# update sampling strata with new strata labels
newstrata <- updateStrata(swissstrata, solution, writeFiles = TRUE)
# update sampling frame with new strata labels
data(swissframe)
framenew <- updateFrame(frame=swissframe,newstrata=newstrata,writeFile=TRUE)
samp <- selectSample(framenew,solution$aggr_strata,writeFiles=TRUE)
# evaluate the current solution
results <- evalSolution(framenew, solution$aggr_strata, 10, cens=NULL, writeFiles = TRUE)
results$coeff_var
results$rel_bias
}