R/prepareSuggestion.R
evalSuggestion.RdComputes the partition of the frame implied by one of the two chromosomes
returned by prepareSuggestion, using the same rule as
strataGenalg2(), and the corresponding Bethel sample size in each
domain. Useful to check the seeds before running the genetic algorithm,
and to compare them with its final solution.
The strata are built with buildStrataDF, i.e. without the
prediction variance and the spatial correlation used by
method = "spatial": for frames of the spatial method the sample
sizes are lower than those of the spatial optimisation and only indicative.
evalSuggestion(frame, errors, sugg, which = 1, minnumstr = 2)The sampling frame used to build sugg (see
prepareSuggestion).
Data frame of precision constraints (columns DOM,
CV1, CV2, ..., domainvalue), as required by
optimStrata.
Data frame returned by prepareSuggestion.
Chromosome to evaluate: 1 (column suggestions1) or 2
(column suggestions2).
Minimum number of units allocated to each stratum
(passed to bethel as minnumstrat). Default 2.
A data frame with one row per domain and columns
domainvalue, strata_requested (H),
strata_nonempty (number of non-empty strata produced by the
chromosome) and n (Bethel sample size, rounded to one decimal).
data(iris)
iris$id <- seq_len(nrow(iris))
frame <- buildFrameDF(df = iris, id = "id",
X = c("Petal.Length", "Petal.Width", "Sepal.Width"),
Y = c("Sepal.Length", "Petal.Length"),
domainvalue = "Species")
errors <- data.frame(DOM = "DOM1", CV1 = 0.02, CV2 = 0.03, domainvalue = 1:3)
set.seed(1234) # the seed "kmeans1d" uses stats::kmeans()
sugg <- prepareSuggestion(frame, nStrata = 3, active = c("X1", "X2"))
evalSuggestion(frame, errors, sugg, which = 1)
#> domainvalue strata_requested strata_nonempty n
#> 1 1 3 3 7.9
#> 2 2 3 3 8.9
#> 3 3 3 3 12.5
evalSuggestion(frame, errors, sugg, which = 2)
#> domainvalue strata_requested strata_nonempty n
#> 1 1 3 3 10.7
#> 2 2 3 3 7.7
#> 3 3 3 3 7.4