R/aggrStrata2.R
aggrStrata2.RdThis function builds the dataframe "strata" considering as input a given domain in the sampling frame. In case a dataframe "model" is given, the anticipated variance in the strata for each target variable is calculated
aggrStrata2(dataset, model = NULL, vett, dominio)This is the name of the dataframe containing the sample data, or the frame data. It is strictly required that auxiliary information is organised in variables named as X1, X2, ... , Xm (there should be at least one of them) and the target variables are denoted by Y1, Y2, ... , Yn. In addition, in case of sample data, a variable named 'WEIGHT' must be present in the dataframe, containing the weigths associated to each sampling unit
Dataframe with the parameters of the model(s) to be used to calculate anticipated variance (see buildStrataDF). For type "spatial" the variance in a stratum is s1^2 / fitting + s2^2, with optional columns fitting (default 1), nugget (default 0), vgm_model (variogram model of the errors: "exponential" (default), "spherical" or "gaussian", or the gstat abbreviations "Exp", "Sph", "Gau"), kappa (default 3, as in optimStrata; not used by the spherical model) and gamma (default 0 here); fitting must be 1 when sig2 > 0. Default is null.
vector of values indicating how the units in the dataset must be aggregated in strata.
Value indicating the domain in the dataset to be processed.
A dataframe containing strata
data(swissmunicipalities)
swissmunicipalities$id <- seq_len(nrow(swissmunicipalities))
frame <- buildFrameDF(swissmunicipalities, id = "id", X = "POPTOT",
Y = c("Pop020", "Pop2040"), domainvalue = "REG")
# strata of domain 1: three classes of POPTOT
dom1 <- frame[frame$domainvalue == 1, ]
vett <- var.bin(dom1$X1, bins = 3)
strata <- aggrStrata2(dataset = dom1,
model = NULL,
vett = vett,
dominio = 1)
strata
#> STRATO N M1 M2 S1 S2 COST CENS DOM1 X1
#> 1 1 561 275.7469 303.8378 369.7194 428.8167 1 0 1 1
#> 2 2 26 3642.6538 4693.4231 1414.1586 1854.7336 1 0 1 2
#> 3 3 2 28360.0000 52138.0000 4069.0000 7936.0000 1 0 1 3