Learn R Programming

fields (version 6.3)

predict.Krig: Evaluation of Krig spatial process estimate.

Description

Provides predictions from the Krig spatial process estimate at arbitrary points, new data (Y) or other values of the smoothing parameter (lambda) including a GCV estimate.

Usage

## S3 method for class 'Krig':
predict(
object, x = NULL, Z = NULL, drop.Z = FALSE, just.fixed
                 = FALSE, lambda = NA, df = NA, model = NA,
                 eval.correlation.model = TRUE, y = NULL, yM = NULL,
                 verbose = FALSE, ...)
## S3 method for class 'Krig':
predict.derivative(object, x = NULL,  verbose = FALSE,...)

Arguments

object
Fit object from the Krig or Tps function.
x
Matrix of x values on which to evaluate the kriging surface. If omitted, the data x values, i.e. out$x will be used.
Z
Vector/Matrix of additional covariates to be included in fixed part of spatial model
drop.Z
If TRUE only spatial fixed part of model is evaluated. i.e. Z covariates are not used.
just.fixed
Only fixed part of model is evaluated
lambda
Smoothing parameter. If omitted, out$lambda will be used. (See also df and gcv arguments)
df
Effective degrees of freedom for the predicted surface. This can be used in place of lambda ( see the function Krig.df.to.lambda)
model
Generic argument that may be used to pass a different lambda.
eval.correlation.model
If true ( the default) will multiply the predicted function by marginal sd's and add the mean function. This usually what one wants. If false will return predicted surface in the standardized scale. The main use of this option is a call from Krig to find
y
Evaluate the estimate using the new data vector y (in the same order as the old data). This is equivalent to recomputing the Krig object with this new data but is more efficient because many pieces can be reused. Note that the x values are assumed to be t
yM
If not NULL evaluate the estimate using this vector as the replicate mean data. That is, assume the full data has been collapsed into replicate means in the same order as xM. The replicate weights are assumed to be the same as the original data. (weigh
verbose
Print out all kinds of intermediate stuff for debugging
...
Other arguments passed to predict.

Value

  • Vector of predicted responses or a matrix of the partial derivatives.

Details

The main goal in this function is to reuse the Krig object to rapidly evaluate different estimates. Thus there is flexibility in changing the value of lambda and also the independent data without having to recompute the matrices associated with the Krig object. The reason this is possible is that most on the calculations depend on the observed locations not on lambda or the observed data. Note the version for evaluating partial derivatives does not provide the same flexibility as predict.Krig and makes some assumptions about the null model (as a low order polynomial) and can not handle the correlation model form.

See Also

Krig, predict.surface gcv.Krig

Examples

Run this code
Krig(ozone$x,ozone$y, theta=50) ->fit
predict( fit) # gives predicted values at data points

# find the partial derivatives at observation locations
# returned object is a two column matrix. 
# this does not make sense for the exponential covariance
# but can illustrate this with a thin plate spline. 
# 
  fit0<- Tps( ozone$x, ozone$y, m=3)
  look<- predict.derivative.Krig( fit0)


# only the fixed part of the model

  predict( fit, just.fixed=TRUE) 

# in this case the default is a linear spatial drift  (m=2) and there 
# are no additional covariates

grid<- make.surface.grid( list( seq( -40,40,,15), seq( -40,40,,15)))

look<- predict(fit,grid) # evaluate on a grid of points

# some useful graphing functions
out.p<- as.surface( grid, look) # reformat into $x $y $z image-type object

#NOTE: the above steps are the same as using the "wrapper" function 
# predict.surface(fit, grid)-> out.p

contour( out.p)  


# refit with 10 degrees of freedom in surface

look<- predict(fit,grid, df=15)

# refit with random data 

look<- predict( fit, grid, y= rnorm( 20))

Run the code above in your browser using DataLab