View source: R/appl_variogram.r
GET.variogram | R Documentation |
The function accompanies the function variogram
with global envelopes
that are based on permutations of the variable(s) or residuals for which the variogram is calculated.
Therefore, one can inspect the hypothesis of "no spatial autocorrelation" of the variable or the residuals
of the fitted model.
GET.variogram(
object,
nsim = 999,
data = NULL,
...,
GET.args = NULL,
savefuns = TRUE
)
object |
An object of class |
nsim |
The number of permutations. |
data |
A data frame where the names in formula are to be found. If NULL,
the data are assumed to be found in the |
... |
Additional parameters to be passed to |
GET.args |
A named list of additional arguments to be passed to |
savefuns |
Logical. If TRUE, then the functions from permutations are saved to the attribute simfuns. |
if(require("sp", quietly=TRUE) & require("gstat", quietly=TRUE)) {
# Examples from gstat complemented with global envelopes
#-------------------------------------------------------
data("meuse")
coordinates(meuse) <- ~x+y
# topsoil zinc concentration, mg kg-1 soil ("ppm")
bubble(meuse, "zinc",
col=c("#00ff0088", "#00ff0088"), main="zinc concentrations (ppm)")
# Variogram can be calculated as follows by the function variogram of the gstat package.
# The function variogram takes a formula as its first argument:
# log(zinc)~1 means that we assume a constant trend for the variable log(zinc).
lzn.vgm <- variogram(object=log(zinc)~1, data=meuse)
plot(lzn.vgm)
# Variogram with global envelopes is as easy:
lzn.vgm.GET <- GET.variogram(object=log(zinc)~1, data=meuse)
plot(lzn.vgm.GET)
# Instead of the constant mean, denoted by ~1, a mean function can
# be specified, e.g. using ~sqrt(dist) as a predictor variable:
lznr.vgm <- variogram(log(zinc)~sqrt(dist), meuse)
# In this case, the variogram of residuals with respect
# to a fitted mean function are shown.
plot(lznr.vgm)
# The variogram with global envelopes (obtained by permuting the residuals):
lznr.vgm.GET <- GET.variogram(object=log(zinc)~sqrt(dist), data=meuse)
plot(lznr.vgm.GET)
# Directional variograms
lzn.dir <- variogram(object=log(zinc)~1, data=meuse, alpha=c(0, 45, 90, 135))
plot(lzn.dir)
# with global envelopes
lzn.dir.GET <- GET.variogram(object=log(zinc)~1, data=meuse, alpha=c(0, 45, 90, 135))
plot(lzn.dir.GET)
# Use instead gstat objects
g <- gstat(id="ln.zinc", formula=log(zinc)~1, data=meuse)
# or: g <- gstat(id="ln.zinc", formula=log(zinc)~sqrt(dist), data=meuse)
# The variogram
plot(variogram(g))
# The variogram with global envelopes:
g.GET <- GET.variogram(object=g)
plot(g.GET)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.