The function fit.variogram.model fits a variogram model to a sample
variogram by (weighted) non-linear least squares. There are print,
summary and
lines methods for summarizing and displaying fitted variogram
models.
fit.variogram.model(sv,
variogram.model = c("RMexp", "RMaskey", "RMbessel", "RMcauchy",
"RMcircular", "RMcubic", "RMdagum", "RMdampedcos", "RMdewijsian",
"RMfbm", "RMgauss", "RMgencauchy", "RMgenfbm", "RMgengneiting",
"RMgneiting", "RMlgd", "RMmatern", "RMpenta", "RMqexp",
"RMspheric", "RMstable", "RMwave", "RMwhittle"),
param, fit.param = default.fit.param()[names(param)],
aniso = default.aniso(), fit.aniso = default.fit.aniso(),
variogram.object = NULL,
max.lag = max(sv[["lag.dist"]]), min.npairs = 30,
weighting.method = c("cressie", "equal", "npairs"),
control = control.fit.variogram.model(),
verbose = 0)control.fit.variogram.model(maximizer = c("nlminb", "optim"),
param.tf = param.transf(), fwd.tf = fwd.transf(),
deriv.fwd.tf = dfwd.transf(), bwd.tf = bwd.transf(),
hessian = TRUE, optim = control.optim(), nlminb = control.nlminb())
# S3 method for fitted.variogram
print(x, digits = max(3, getOption("digits") - 3), ...)
# S3 method for fitted.variogram
summary(object, correlation = FALSE, signif = 0.95, ...)
# S3 method for fitted.variogram
lines(x, what = c("variogram", "covariance", "correlation"),
from = 1.e-6, to, n = 501, xy.angle = 90, xz.angle = 90,
col = 1:length(xy.angle), pch = 1:length(xz.angle), lty = "solid", ...)
an object of class sample.variogram, see
sample.variogram.
a named numeric vector with initial values of the variogram
parameters. The following parameter names are allowed (see
Details of georob and georobIntro for
information about the parametrization of variogram models):
variance: variance (sill \(\sigma^2\)) of the
auto-correlated component of the Gaussian random field
\(B(\mbox{\boldmath$s$\unboldmath})\).
snugget: variance
(spatial nugget \(\sigma^2_{\mathrm{n}}\))
of the seemingly spatially uncorrelated component of
\(B(\mbox{\boldmath$s$\unboldmath})\)
(micro-scale spatial variation; default value snugget = 0).
nugget: variance (nugget \(\tau^2\)) of the
independent errors
\(\varepsilon(\mbox{\boldmath$s$\unboldmath})\).
scale: range parameter (\(\alpha\)) of the variogram.
names of additional variogram parameters such as the
smoothness parameter \(\nu\) of the Whittle-Mat\'ern model (see
RMmodel and param.names).
a named logical vector (or a function such as
default.fit.param that creates this vector) with the same
names as used for param, defining which parameters are adjusted
(TRUE) and which are kept fixed at their initial values
(FALSE) when fitting the model.
a named numeric vector with initial values (or a function such as
default.aniso that creates this vector) for fitting
geometrically anisotropic variogram models. The names of aniso
are matched against the following names (see Details and
georobIntro for information about the parametrization of
variogram models):
f1: ratio \(f_1\) of lengths of second and first
semi-principal axes of an ellipsoidal surface with constant
semi-variance in \(\mathrm{I}\!\mathrm{R}^3\) (default f1 = 1).
f2: ratio \(f_2\) of lengths of third and first
semi-principal axes of the semi-variance ellipsoid (default f2 = 1).
omega: azimuth in degrees of the first semi-principal axis
of the semi-variance ellipsoid (default omega = 90).
phi: 90 degrees minus altitude of the first semi-principal axis
of the semi-variance ellipsoid (default phi = 90).
zeta: angle in degrees between the second semi-principal
axis and the direction of the line defined by the intersection
between the \(x\)-\(y\)-plane and the plane orthogonal to the
first semi-principal axis of the semi-variance ellipsoid through the
origin (default zeta = 0).
a named logical vector (or a function such as
default.fit.aniso that creates this vector) with the same
names as used for aniso, defining which parameters are adjusted
(TRUE) and which are kept fixed at their initial values
(FALSE) when fitting the model.
an optional list that defines a possibly nested variogram model. Each component is itself a list with the following components:
variogram.model: a character keyword defining the variogram model, see respective argument above.
param: a named numeric vector with initial values of the variogram parameters, see respective argument above.
fit.param: a named logical vector defining which parameters are adjusted, see respective argument above.
aniso: a named numeric vector with initial values for fitting geometrically anisotropic variogram models, see respective argument above.
fit.param: a named logical vector defining which anisotropy parameters are adjusted, see respective argument above.
Note that the arguments variogram.model, param,
fit.param, aniso and fit.aniso are ignored when
variogram.object is passed to fit.variogram.model.
a positive numeric defining the maximum lag distance to be used for fitting or plotting variogram models (default all lag classes).
a positive integer defining the minimum number of data
pairs required so that a lag class is used for fitting a variogram
model (default 30).
a character keyword defining the weights for non-linear least squares. Possible values are:
"equal": no weighting ,
"npairs": weighting by number of data pairs in a lag class,
"cressie": “Cressie's weights” (default, see Cressie, 1993,
sec. 2.6.2).
positive integer controlling logging of diagnostic messages to the console during model fitting.
a list with the components maximizer,
param.tf, fwd.tf, bwd.tf, hessian,
optim and nlminb or a function such as
control.fit.variogram.model that generates such a list.
See codecontrol.georob for information on
codemaximizer, param.tf, fwd.tf,
bwd.tf, hessian, optim and nlminb.
logical scalar controlling whether the Hessian should be computed at the nonlinear least squares estimates.
a function such as param.transf, which
returns a named vector of character strings that define the
transformations to be applied to the variogram parameters for model
fitting, see control.georob.
a function such as fwd.transf, which returns
a named list of invertible functions to be used to transform variogram
parameters, see control.georob.
a function such as dfwd.transf, which
returns a named list of functions corresponding to the first derivatives
of fwd.tf, see Details.
a function such as bwd.transf, which returns
the named list of inverse functions corresponding to fwd.tf, see
see control.georob.
a list of arguments passed to nlminb or a function
such as control.nlminb that generates such a list (see
nlminb for allowed arguments).
a list of arguments passed to optim or a function
such as control.optim that generates such a list (see
optim for allowed arguments).
an object of class fitted.variogram.
positive integer indicating the number of decimal digits to print.
logical controlling whether the correlation matrix of
the fitted variogram parameters is computed (default FALSE).
confidence level for computing confidence intervals for
variogram parameters (default 0.95).
the quantity that should be displayed (default "variogram").
numeric, minimal lag distance used in plotting variogram models.
numeric, maximum lag distance used in plotting variogram models (default: largest lag distance of current plot).
positive integer specifying the number of equally spaced lag
distances for which semi-variances are evaluated in plotting variogram
models (default 501).
numeric (vector) with azimuth angles (in degrees, clockwise positive from north) in \(x\)-\(y\)-plane for which semi-variances should be plotted.
numeric (vector) with angles in \(x\)-\(z\)-plane (in degrees, clockwise positive from zenith to south) for which semi-variances should be plotted.
color of curves to distinguish curves relating to different azimuth angles in \(x\)-\(y\)-plane.
type of plotting symbols added to lines to distinguish curves relating to different angles in \(x\)-\(z\)-plane.
line type for plotting variogram models.
additional arguments passed to methods.
The function fit.variogram.model generates an object of class
fitted.variogram which is a list with the following components:
the value of the object function (weighted residual sum of squares) evaluated at the solution.
the estimated parameters of a possibly nested variograms model. This is a list that contains for each variogram model structure the following components:
variogram.model: the name of the fitted parametric variogram
model.
param: a named numeric vector with the (estimated) variogram
parameters.
fit.param: a named logical vector with the flags defining what
variogram parameters were estimated.
isotropic: logical indicating whether an isotropic
variogram was fitted.
aniso: a named numeric vector with the (estimated)
anisotropy parameters.
fit.aniso: a named logical vector with the flags defining what
anisotropy parameters were estimated.
sincos: a list with sin and cos of the
angles \(\omega\), \(\phi\) and \(\zeta\) that define the
orientation of the anisotropy ellipsoid.
rotmat: the matrix
\((\mbox{\boldmath$C$\unboldmath}_1,
\mbox{\boldmath$C$\unboldmath}_2,
\mbox{\boldmath$C$\unboldmath}_3)\) (see
georobIntro).
sclmat: a vector with the elements 1, \(1/f_1\),
\(1/f_2\) (see georobIntro).
a character vector listing the transformations of the variogram parameters used for model fitting.
a list of functions for variogram parameter transformations.
a list of functions for inverse variogram parameter transformations.
logical indicating whether numerical maximization by
optim converged.
a diagnostic integer issued by
optim (component convergence) about convergence.
a named integer vector of length two with the number of
function and gradient evaluations by optim.
the matched call.
a numeric vector with the residuals, that is the sample semi-variance minus the fitted values.
a numeric vector with the modelled semi-variances.
a numeric vector with the weights used for fitting.
a symmetric matrix with the Hessian at
the solution (missing if hessian is false).
a symmetric matrix with the Hessian at the solution
with respect to the transformed variogram and anisotropy parameters
(missing if hessian is false). This Hessian is used by
summary.fitted.variogram to compute confidence intervals
for the estimated parameters.
a symmetric matrix with the Hessian at the solution
with respect to the non-transformed variogram and anisotropy parameters
(missing if hessian is false).
The parametrization of geometrically anisotropic variograms is
described in detail in georobIntro, and the section
Details of georob describes how the parameter
estimates are constrained to permissible ranges. The same
mechanisms are used in fit.variogram.model.
The method summary computes confidence intervals of the estimated
variogram and anisotropy parameters from the Hessian matrix of the residual
sums of squares, based on the asymptotic normal distribution of least
squares estimate estimates. Note that the Hessian matrix with respect to
the transformed variogram and anisotropy parameters is used for
this. Hence the inverse Hessian matrix is the covariance matrix of the
transformed parameters, confidence intervals are first computed for the
transformed parameters and the limits of these intervals are transformed
back to the orginal scale of the parameters. Optionally, summary
reports the correlation matrix of the transformed parameters, also
computed from the Hessian matrix.
Cressie, N. A. C. (1993) Statistics for Spatial Data. New York: John Wiley & Sons.
georobIntro for a description of the model and a brief summary of the algorithms;
georob for (robust) fitting of spatial linear models;
georobObject for a description of the class georob;
profilelogLik for computing profiles of Gaussian likelihoods;
plot.georob for display of RE(ML) variogram estimates;
control.georob for controlling the behaviour of georob;
georobModelBuilding for stepwise building models of class georob;
cv.georob for assessing the goodness of a fit by georob;
georobMethods for further methods for the class georob;
predict.georob for computing robust Kriging predictions;
lgnpp for unbiased back-transformation of Kriging prediction
of log-transformed data;
georobSimulation for simulating realizations of a Gaussian process
from model fitted by georob.
# NOT RUN {
data(wolfcamp)
## fitting an isotropic IRF(0) model
r.sv.iso <- sample.variogram(pressure~1, data = wolfcamp,
locations = ~x + y, lag.dist.def = seq(0, 200, by = 15))
# }
# NOT RUN {
r.irf0.iso <- fit.variogram.model(r.sv.iso, variogram.model = "RMfbm",
param = c(variance = 100, nugget = 1000, scale = 1., alpha = 1.),
fit.param = default.fit.param(scale = FALSE, alpha = TRUE))
summary(r.irf0.iso, correlation = TRUE)
plot(r.sv.iso, type = "l")
lines(r.irf0.iso, line.col = "red")
# }
# NOT RUN {
## fitting an anisotropic IRF(0) model
r.sv.aniso <- sample.variogram(pressure~1, data = wolfcamp,
locations = ~x + y, lag.dist.def = seq(0, 200, by = 15),
xy.angle.def = c(0., 22.5, 67.5, 112.5, 157.5, 180.))
# }
# NOT RUN {
r.irf0.aniso <- fit.variogram.model(r.sv.aniso, variogram.model = "RMfbm",
param = c(variance = 100, nugget = 1000, scale = 1., alpha = 1.5),
fit.param = default.fit.param(scale = FALSE, alpha = TRUE),
aniso = default.aniso(f1 = 0.4, omega = 135.),
fit.aniso = default.fit.aniso(f1 = TRUE, omega = TRUE),
control = control.fit.variogram.model(
maximizer = "optim",
optim = control.optim(
method = "BFGS", hessian = TRUE, control = list(maxit = 5000)
)
))
summary(r.irf0.aniso, correlation = TRUE)
plot(r.sv.aniso, type = "l")
lines(r.irf0.aniso, xy.angle = seq(0, 135, by = 45))
# }
Run the code above in your browser using DataLab