krigeLgm {geostatsp} | R Documentation |
Spatial prediction, or Kriging
Description
Perform spatial prediction, producing a raster of predictions and conditional standard deviations.
Usage
krigeLgm(formula, data, grid, covariates = NULL,
param,
expPred = FALSE, nuggetInPrediction = TRUE,
mc.cores=getOption("mc.cores", 1L))
Arguments
formula |
Either a model formula, or a data frame of linear covariates. |
data |
A |
grid |
Either a |
covariates |
The spatial covariates used in prediction, either a |
param |
A vector of named model parameters, as produced by |
expPred |
Should the predictions be exponentiated, defaults to |
nuggetInPrediction |
If |
mc.cores |
passed to |
Details
Given the model parameters and observed data, conditional means and variances of the spatial random field are computed.
Value
A raster is returned with the following layers:
fixed |
Estimated means from the fixed effects portion of the model |
random |
Predicted random effect |
krige.var |
Conditional variance of predicted random effect (on the transformed scale if applicable) |
predict |
Prediction of the response, sum of fixed and random effects. If exp.pred is TRUE, gives predictions on the exponentiated scale, and half of krige.var is added prior to exponentiating |
predict.log |
If exp.pred=TRUE, the prediction of the logged process. |
predict.boxcox |
If a box cox transformation was used, the prediction of the process on the transformed scale. |
If the prediction locations are different for fixed and random effects (typically coarser for the random effects), a list with two raster stacks is returned.
prediction |
A raster stack as above, though the random effect prediction is resampled to the same locations as the fixed effects. |
random |
the predictions and conditional variance of the random effects, on the same
raster as |
See Also
Examples
data('swissRain')
swissAltitude = unwrap(swissAltitude)
swissRain = unwrap(swissRain)
swissRain$lograin = log(swissRain$rain)
swissRain[[names(swissAltitude)]] = extract(swissAltitude, swissRain, ID=FALSE)
swissFit = likfitLgm(data=swissRain,
formula=lograin~ CHE_alt,
param=c(range=46500, nugget=0.05,shape=1,
anisoAngleDegrees=35, anisoRatio=12),
paramToEstimate = c("range","nugget",
"anisoAngleDegrees", "anisoRatio")
)
myTrend = swissFit$model$formula
myParams = swissFit$param
swissBorder = unwrap(swissBorder)
swissKrige = krigeLgm(
data=swissRain,
formula = myTrend,
covariates = swissAltitude,
param=myParams,
grid = squareRaster(swissBorder, 40), expPred=TRUE)
plot(swissKrige[["predict"]], main="predicted rain")
plot(swissBorder, add=TRUE)