xvalid {geoR} | R Documentation |
This is a function to perform model validation. Options include 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 as given model. This can be done for all or some of the locations. Alternativelly, other validation locations which are not the same as the original data locations can be used.
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
as described next. Typically an object of the class
"geodata" - a geoR data-set.
If not provided the arguments
coords must be provided instead. |
coords |
an n x 2 matrix containing
coordinates of the n data locations in each row.
Defaults to geodata$coords , if provided. |
data |
a vector or matrix with data values.
If a matrix is provided, each column is regarded as one variable or realization.
Defaults to geodata$data , if provided. |
model |
an object containing information on a fitted
model. Typically an output of likfit ,
variofit . |
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 variog . Only used if
reestimate = TRUE and the object passed to the argument
model is the result of a variogram based estimation, i.e. if
the model was fitted by variofit . |
output.reestimate |
logical. Only valid if reestimate =
TRUE . Specifies whether the re-estimated parameters are returned. |
locations.xvalid |
there are three possible specifications for
this argument: "all" indicates the leaving-on-out
method is used. The second possibility is to use only a sub-set of
the data for cross-validation. For this case a vector should be
provided with numbers indicating at which locations the
cross-validation should be performed. The third option is to perform
validation on a different set of data. For this a matrix with the
coordinates of the validation points should be provided and the the
argument locations.data should also be provided. |
data.xvalid |
data values at the validation locations. Only used if the validation locations are not the same or a subset of the original data coordinates. |
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
likfit , variofit . |
The cross-validation uses the function krige.conv
to predict
at each location.
For models fitted by variofit
the
parameters kappa, psiA, psiR
and lambda are always regarded as fixed.
See documentation of the function likfit
for more
details on the model and its 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 |
difference data - predicted . |
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 data-frame. Each column will contain the
values of the re-estimated parameters.
Paulo J. Ribeiro Jr. Paulo.Ribeiro@est.ufpr.br,
Peter J. Diggle p.diggle@lancaster.ac.uk.
Further information on the package geoR can be found at:
http://www.est.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.
data(s100) # # 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) #