Learn R Programming

gear (version 0.1.5)

predict.geolmStd: Predict method for geostatistical models

Description

predict calculates the predicted values at specified locations. The method can additionally provide the mean square prediction error (mspe) and perform conditional simulation.

Usage

# S3 method for geolmStd
predict(object, newdata, nsim = 0, sp = TRUE, dmethod = "chol", ...)

Arguments

object

An object produced by the geolm function.

newdata

An optional data frame in which to look for the coordinates at which to predict. If omitted, the observed data locations are used.

nsim

A non-negative integer indicating the number of realizations to sample at the specified coordinates using conditional simulation.

sp

A logical value indicating whether to object returned should be of class SpatialPointsDataFrame for easier plotting with the sp package. Default is TRUE.

dmethod

The method used to decompose the covariance matrix for conditional simulation. Valid options are "chol", "eigen", and "svd". The default is "chol".

...

Currently unimplemented.

Value

If sp = TRUE, then a SpatialPointDataFrame from the sp package is returned, with components including the prediction coordinates, the predicted responses pred, the mean square prediction error (mspe), the root mean square prediction error (rmspe), and the conditional realizations, if application (sim.1, sim.2, ...). If sp = FALSE, then a list of class gearKrige is returned, with components pred, mspe, rmspe, and sim, if relevant.

Details

The newdata data frame must include the relevant covariates for the prediction locations, where the covariates are specified on the right side of the ~ in object$formula. newdata must also include the coordinates of the prediction locations, with these columns having the names provided in object$coordnames.

Examples

Run this code
# NOT RUN {
# generate response
y = rnorm(10)
# generate coordinates
x1 = runif(10); x2 = runif(10)

# data frame for observed data
data = data.frame(y, x1, x2)
# newdata must have columns with prediction coordinates
newdata = data.frame(x1 = runif(5), x2 = runif(5))

# specify a standard covariance model
cmod = cmod.std(model = "exponential", psill = 1, 
                r = 1)

# geolm for universal kriging
gearmod_uk = geolm(y ~ x1 + x2, data = data,
                 coordnames = c("x1", "x2"),
                 cmod = cmod)
# prediction for universal kriging, with conditional simulation
pred_uk = predict(gearmod_uk, newdata, nsim = 2)

# geolm for ordinary kriging
gearmod_ok = geolm(y ~ 1, data = data,
                 coordnames = c("x1", "x2"),
                 cmod = cmod)
# prediction for ordinary kriging
pred_ok = predict(gearmod_ok, newdata)

# geolm for simple kriging
gearmod_ok = geolm(y ~ 1, data = data,
                 coordnames = c("x1", "x2"),
                 cmod = cmod, mu = 1)
# prediction for simple kriging
pred_sk = predict(gearmod_ok, newdata)

# }

Run the code above in your browser using DataLab