gstat {gstat} | R Documentation |
Function that creates gstat objects; objects that hold all the information necessary for univariate or multivariate geostatistical prediction (simple, ordinary or universal (co)kriging), or its conditional or unconditional Gaussian or indicator simulation equivalents. Multivariate gstat object can be subsetted.
gstat(g, id, formula, locations, data, model = NULL, beta, nmax = Inf, nmin = 0, maxdist = Inf, dummy = FALSE, set, fill.all = FALSE, fill.cross = TRUE, variance = "identity", weights = NULL) print.gstat(x, ...)
g |
gstat object to append to; if missing, a new gstat object is created |
id |
id of new variable; if missing, varn is used with
n the number for this variable. If a cross variogram is entered,
id is a vector with the two id values , e.g.
c("zn", "cd") and further only supply arguments g
and model |
formula |
formula that defines the dependent variable as a linear
model of independent variables; suppose the dependent variable has name
z , for ordinary and simple kriging use the formula z~1 ;
for simple kriging also define beta (see below); for universal
kriging, suppose z is linearly dependent on x and y ,
use the formula z~x+y |
locations |
formula with only independent variables that define the
spatial data locations (coordinates), e.g. ~x+y ; if data
is of class spatial.data.frame , this argument may be ignored, as
it can be derived from the data |
data |
data frame; contains the dependent variable, independent variables, and locations. |
model |
variogram model for this id ; defined by a call to
vgm; see argument id to see how cross variograms are entered |
beta |
only for simple kriging (and simulation based on simple kriging); vector with the trend coefficients (including intercept); if no independent variables are defined the model only contains an intercept and this should be the simple kriging mean |
nmax |
for local kriging: the number of nearest observations that should be used for a kriging prediction or simulation, where nearest is defined in terms of the space of the spatial locations |
nmin |
for local kriging: if the number of nearest observations
within distance maxdist is less than nmin , a missing
value will be generated; see maxdist |
maxdist |
for local kriging: only observations within a distance
of maxdist from the prediction location are used for prediction
or simulation; if combined with nmax , both criteria apply |
dummy |
logical; if TRUE, consider this data as a dummy variable (only necessary for unconditional simulation) |
set |
named list with optional parameters to be passed to
gstat (only set commands of gstat are allowed; see gstat manual) |
x |
gstat object to print |
fill.all |
logical; if TRUE, fill all of the direct variogram and,
depending on the value of fill.cross also all cross
variogram model slots in g with the given variogram model |
fill.cross |
logical; if TRUE, fill all of the cross variograms, if
FALSE fill only all direct variogram model slots in g with the
given variogram model (only if fill.all is used) |
variance |
character; variance function to transform to non-stationary covariances; "identity" does not transform, other options are "mu" (Poisson) and "mu(1-mu)" (binomial) |
weights |
numeric vector; if present, weights passed to OLS prediction routines (covariates are present, variograms are missing) |
... |
arguments that are passed to the printing of the variogram models only |
to print the full contents of the object g
returned,
use as.list(g)
or print.default(g)
an object of class gstat
, which inherits from list
.
Its components are:
data |
list; each element is a list with the formula ,
locations , data , nvars , beta , etc., for a
variable |
model |
list; each element contains a variogram model; names are
those of the elements of data ; cross variograms have names of
the pairs of data elements, separated by a . (e.g.:
var1.var2 |
set |
list; named list, corresponding to set name =value ;
gstat commands (look up the set command in the gstat manual for a full list) |
The function currently copies the data objects into the gstat object, so this may become a large object. I would like to copy only the name of the data frame, but could not get this to work. Any help is appreciated.
Subsetting (see examples) is done using the id
's of the variables,
or using numeric subsets. Subsetted gstat objects only contain cross
variograms if (i) the original gstat object contained them and (ii) the
order of the subset indexes increases, numerically, or given the order
they have in the gstat object.
Edzer J. Pebesma
data(meuse) # let's do some manual fitting of two direct variograms and a cross variogram g <- gstat(id = "ln.zinc", formula = log(zinc)~1, locations = ~x+y, data = meuse) g <- gstat(g, id = "ln.lead", formula = log(lead)~1, locations = ~x+y, data = meuse) # examine variograms and cross variogram: plot(variogram(g)) # enter direct variograms: g <- gstat(g, id = "ln.zinc", model = vgm(.55, "Sph", 900, .05)) g <- gstat(g, id = "ln.lead", model = vgm(.55, "Sph", 900, .05)) # enter cross variogram: g <- gstat(g, id = c("ln.zinc", "ln.lead"), model = vgm(.47, "Sph", 900, .03)) # examine fit: plot(variogram(g), model = g$model, main = "models fitted by eye") # see also demo(cokriging) for a more efficient approach g["ln.zinc"] g["ln.lead"] g[c("ln.zinc", "ln.lead")] g[1] g[2] # Inverse distance interpolation with inverse distance power set to .5: # (kriging variants need a variogram model to be specified) data(meuse) data(meuse.grid) meuse.gstat <- gstat(id = "zinc", formula = zinc ~ 1, locations = ~ x + y, data = meuse, nmax = 7, set = list(idp = .5)) meuse.gstat z <- predict(meuse.gstat, meuse.grid) levelplot(zinc.pred~x+y, z, aspect = mapasp(z)) # see demo(cokriging) and demo(examples) for further examples, # and the manuals for predict.gstat and image