fit.variogram.model {georob} | R Documentation |
Fitting Model Functions to Sample Variograms
Description
The function fit.variogram.model
fits a variogram model to a sample
variogram by (weighted) non-linear least squares. The function
control.fit.variogram.model
generates a list with steering parameters which
control fit.variogram.model
. There are print
, summary
and lines
methods for summarizing and displaying fitted variogram
models.
Usage
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 class 'fitted.variogram'
print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'fitted.variogram'
summary(object, correlation = FALSE, signif = 0.95, ...)
## S3 method for class '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", ...)
Arguments
sv |
an object of class |
variogram.model |
a character keyword defining the variogram model
to be fitted. Currently, most basic variogram models provided formerly
by the now archived package RandomFields can be fitted (see
Details of |
param |
a named numeric vector with initial values of the variogram
parameters. The following parameter names are allowed (see
Details of
|
fit.param |
a named logical vector (or a function such as
|
aniso |
a named numeric vector with initial values (or a function such as
|
fit.aniso |
a named logical vector (or a function such as
|
variogram.object |
an optional list that defines a possibly nested variogram model. Each component is itself a list with the following components:
Note that the arguments |
max.lag |
a positive numeric defining the maximum lag distance to be used for fitting or plotting variogram models (default all lag classes). |
min.npairs |
a positive integer defining the minimum number of data
pairs required so that a lag class is used for fitting a variogram
model (default |
weighting.method |
a character keyword defining the weights for non-linear least squares. Possible values are:
|
verbose |
a positive integer controlling logging of diagnostic messages to the console during model fitting. |
control |
a list with the components |
maximizer |
a character keyword defining the optimizer for nonlinear
least squares. Possible values are |
hessian |
a logical scalar controlling whether the Hessian should be computed at the nonlinear least squares estimates. |
param.tf |
a function such as |
fwd.tf |
a function such as |
deriv.fwd.tf |
a function such as |
bwd.tf |
a function such as |
nlminb |
a list of arguments passed to |
optim |
a list of arguments passed to |
object , x |
an object of class |
digits |
a positive integer indicating the number of decimal digits to print. |
correlation |
a logical scalar controlling whether the correlation matrix of
the fitted variogram parameters is computed (default |
signif |
a numeric with the confidence level for computing
confidence intervals for variogram parameters (default |
what |
a character keyword with the quantity that should be
displayed (default |
from |
a numeric with the minimal lag distance used in plotting variogram models. |
to |
a numeric with the maximum lag distance used in plotting variogram models (default: largest lag distance of current plot). |
n |
a positive integer specifying the number of equally spaced lag
distances for which semi-variances are evaluated in plotting variogram
models (default |
xy.angle |
a numeric vector with azimuth angles (in degrees,
clockwise positive from north) in |
xz.angle |
a numeric vector with angles in |
col |
a vector with colours of curves to distinguish curves relating
to different azimuth angles in |
pch |
a vector with the plotting symbols added to lines to
distinguish curves relating to different angles in
|
lty |
a vector with the line types for plotting variogram models. |
... |
additional arguments passed to methods. |
Details
The parametrization of geometrically anisotropic variograms is
described in detail in georobPackage
, 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 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 original scale of the parameters. Optionally, summary
reports the correlation matrix of the transformed parameters, also
computed from the Hessian matrix.
Value
The function fit.variogram.model
generates an object of class
fitted.variogram
which is a list with the following components:
sse |
the value of the object function (weighted residual sum of squares) evaluated at the solution. |
variogram.object |
the estimated parameters of a possibly nested variograms model. This is a list that contains for each variogram model structure the following components:
|
param.tf |
a character vector listing the transformations of the variogram parameters used for model fitting. |
fwd.tf |
a list of functions for variogram parameter transformations. |
bwd.tf |
a list of functions for inverse variogram parameter transformations. |
converged |
a logical scalar indicating whether numerical
maximization by |
convergence.code |
a diagnostic integer issued by
|
iter |
a named integer vector of length two with the number of
function and gradient evaluations by |
call |
the matched call. |
residuals |
a numeric vector with the residuals, that is the sample semi-variance minus the fitted values. |
fitted |
a numeric vector with the modelled semi-variances. |
weights |
a numeric vector with the weights used for fitting. |
hessian.tfpa |
a symmetric matrix with the Hessian at the solution
with respect to the transformed variogram and anisotropy parameters
(missing if |
hessian.ntfpa |
a symmetric matrix with the Hessian at the solution
with respect to the non-transformed variogram and anisotropy parameters
(missing if |
The function control.fit.variogram.model
returns a list with
parameters to steer
fit.variogram.model
, see arguments of
the function above for its components.
The method print.fitted.variogram
invisibly returns the fitted
variogram model unchanged.
The method summary.fitted.variogram
returns an object of class
summary.fitted.variogram
which is a list containing a subset of
the components of the fitted variogram object (call
,
residuals
, weights
, converged
,
convergence.code
, iter
, sse
,
variogram.object
), the matrix param.aniso
with the
estimated values of the variogram parameters along with the bounds of the
confidence intervals and optionally the correlation matrix
cor.tf.param
of the estimated transformed parameters. There is a
print
method for objects of class summary.fitted.variogram
which returns invisibly the object unchanged.
The method lines.fitted.variogram
is called for its side effects
and returns the value NULL
invisibly.
Author(s)
Andreas Papritz papritz@retired.ethz.ch.
References
Cressie, N. A. C. (1993) Statistics for Spatial Data, Wiley, New York, doi:10.1002/9781119115151.
See Also
georobPackage
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
.
Examples
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))
plot(r.sv.iso, type = "l")
if(interactive()){
## example is run only in interactive session because cpu times exceeds 5 s
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)
lines(r.irf0.iso, line.col = "red")
}
## 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.))
plot(r.sv.aniso, type = "l")
if(interactive()){
## example is run only in interactive session because cpu times exceeds 5 s
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)
lines(r.irf0.aniso, xy.angle = seq(0, 135, by = 45))
}