xvalid | R Documentation |
A function to perform model validation by comparing observed and values predicted by kriging. Options include: (i) leaving-one-out cross-validation where each data location is removed from the data set and the variable at this location is predicted using the remaining locations, for a given model. This can be computed for all or a subset of the data locations; (ii) external validation can be performed by using validation locations other than data locations.
xvalid(geodata, coords = geodata$coords, data = geodata$data,
model, reestimate = FALSE, variog.obj = NULL,
output.reestimate = FALSE, locations.xvalid = "all",
data.xvalid = NULL, messages, ...)
geodata |
a list containing element |
coords |
an |
data |
a vector or matrix with data values.
If a matrix is provided, each column is regarded as one variable or realization.
Defaults to |
model |
an object containing information on a fitted
model. Typically an output of |
reestimate |
logical. Indicates whether or not the model parameters should be re-estimated for each point removed from the data-set. |
variog.obj |
on object with the empirical variogram, typically an
output of the function |
output.reestimate |
logical. Only valid if |
locations.xvalid |
there are three possible specifications for
this argument: |
data.xvalid |
data values at the validation locations. Only used if the validation locations are other than the data locations. |
messages |
logical. Indicates whether status messages should be printed on the screen (or output device) while the function is running. |
... |
further arguments to the minimization functions used by
|
The cross-validation uses internally the function krige.conv
to predict at each location.
For models fitted by variofit
the
parameters \kappa
, \psi_A
, \psi_R
and \lambda
are always regarded as fixed when
reestimating the model.
See documentation of the function likfit
for further
details on the model specification and parameters.
An object of the class
"xvalid"
which is a list with the following components:
data |
the original data. |
predicted |
the values predicted by cross-validation. |
krige.var |
the cross-validation prediction variance. |
error |
the differences |
std.error |
the errors divided by the square root of the prediction variances. |
prob |
the cumulative probability at original value under a normal distribution with parameters given by the cross-validation results. |
A method for summary
returns summary statistics for the errors
and standard errors.
If reestimate = TRUE
and output = TRUE
additional
columns are added to the resulting data-frame with the
values of the re-estimated parameters.
Paulo J. Ribeiro Jr. paulojus@ufpr.br,
Peter J. Diggle p.diggle@lancaster.ac.uk.
Further information on the package geoR can be found at:
http://www.leg.ufpr.br/geoR/.
plot.xvalid
for plotting of the results, likfit
,
variofit
for parameter estimation and
krige.conv
for the kriging method used for predictions.
#
# Maximum likelihood estimation
#
s100.ml <- likfit(s100, ini = c(.5, .5), fix.nug = TRUE)
#
# Weighted least squares estimation
#
s100.var <- variog(s100, max.dist = 1)
s100.wls <- variofit(s100.var, ini = c(.5, .5), fix.nug = TRUE)
#
# Now, performing cross-validation without reestimating the model
#
s100.xv.ml <- xvalid(s100, model = s100.ml)
s100.xv.wls <- xvalid(s100, model = s100.wls)
##
## Plotting results
##
par.ori <- par(no.readonly = TRUE)
##
par(mfcol=c(5,2), mar=c(2.3,2.3,.5,.5), mgp=c(1.3, .6, 0))
plot(s100.xv.ml)
par(mfcol=c(5,2))
plot(s100.xv.wls)
##
par(par.ori)
#
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.