R/aggrStrata_spatial.r
aggrStrataSpatial.RdThis function builds the dataframe "strata" considering as input a given domain in the sampling frame. The variance in each stratum is calculated by considering also the component of spatial autocorrelation.
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
Default is 1, to be used when the frame contains the prediction-error variances (VAR columns). A value < 1 (R2 of the prediction model) is meant only for the rescaling correction, with all variances = 0: with positive variances the function stops (the error variance would be counted twice). If only R2 is known, use fitting = 1 with a constant variance var(predictions) * (1 - R2) / R2. See buildStrataDFSpatial().
Range of the correlation function of the prediction errors (in the units of the coordinates), as defined by the variogram model given in vgm_model. 0 means no spatial correlation.
Factor used in evaluating spatial autocorrelation with the exponential and gaussian models: 1 if range is the range parameter of the variogram (as returned by gstat), 3 if it is the practical range. Not used by the spherical model. Any finite value > 0 is accepted; 0 or negative values give an error. Default is 3.
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.
Relative nugget c0/(c0+c1) of the variogram of the prediction errors, in [0, 1]. Default is 0.
Variogram model fitted on the prediction errors: "exponential" (default), "spherical" or "gaussian" (or the gstat abbreviations "Exp", "Sph", "Gau"). A single value, or one value for each target variable Y. See buildStrataDFSpatial() for the correlation functions.
A dataframe containing strata
# synthetic spatial frame: one domain, one target variable with its
# prediction variance and the coordinates of each unit
set.seed(1234)
frame <- data.frame(id = 1:100, X1 = runif(100), Y1 = runif(100, 10, 20),
var1 = 0.5, lon = runif(100), lat = runif(100),
domainvalue = 1)
# three strata defined on X1
strata <- aggrStrataSpatial(dataset = frame,
fitting = 1,
range = 0.5,
kappa = 3,
nugget = 0.3,
vett = var.bin(frame$X1, bins = 3),
dominio = 1)
strata
#> stratum N COST CENS DOM1 M1 S1
#> 1 1 49 1 0 1 15.45067 3.103938
#> 2 2 28 1 0 1 14.96384 2.918240
#> 3 3 23 1 0 1 15.34802 2.787478