Learn R Programming

geostatsp (version 0.4.4)

krige: Spatial prediction, or Kriging

Description

This function uses the krige.control and krige.conv functions in geoR to perform spatial prediction using a fitted model from likfit.

Usage

krige(obj.model, geodata, locations, covariates, locations.mean = locations,
   factor.info = NULL, 
	exp.pred = FALSE, rasterMethod = c("ngb", "bilinear"),
	nugget.in.prediction=TRUE, ...)

Arguments

obj.model
A fitted model produced by likfit
geodata
A SpatialPointsDataFrame containing the data used with likfit.
locations
A raster on which the spatial random effects will be predicted, or an integer specifying the number of cells in the x dimension for a raster with square cells covering geodata.
covariates
The spatial covariates used in prediction, either a raster stack or list of rasters.
locations.mean
A raster on which the fixed effects component of the model is predicted. Defaults to the same raster as used for the random effects. Ignored if covariates is a raster stack.
factor.info
A list of data frames, with first column being levels and second column being labels for covariates which are factors. Useful if the rasters containing categorical covariates are integers corresponding to different categories from those used in g
exp.pred
Should the predictions be exponentiated, defaults to false.
rasterMethod
Method for reprojecting or resampling rasters, either "bilinear" or "ngb". Any covariates which are factors will be reprojected with ngb even if bilinear is specified.
nugget.in.prediction
If TRUE, predict new observations by adding the nugget effect. Otherwise predict fitted values. Only relevant for Box-Cox or log transformed data.
...
Additional arguments, currently none

Value

  • If the prediction locations are identical for the fixed effects and random effects, a single raster stack is returned with the following layers:
  • fixedEstimated means from the fixed effects portion of the model
  • randomPredicted random effect
  • krige.varConditional variance of predicted random effect (on the transformed scale if applicable)
  • predictPrediction of the response, sum of fixed and random effects. If exp.pred is TRUE, gives predictions on the exponentated scale, and half of krige.var is added prior to exponentiating
  • predict.logIf exp.pred=TRUE, the prediction of the logged process.
  • 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.
  • predict.boxcoxIf 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.
  • predictionA raster stack as above, though the random effect prediction is resampled to the same locations as the fixed effects.
  • randomthe predictions and conditional variance of the random effects, on the same raster as locations

Details

This function is essentially a wrapper for krige.conv.

See Also

krige.conv

Examples

Run this code
data(swissRain)
swissRain$lograin = log(swissRain$rain)
swissRain$elevation = extract(swissAltitude, swissRain)
swissFit =  likfit(swissRain, lograin ~ elevation, 
	cov.model="matern", kappa = 2, fix.kappa=TRUE)
swissRaster = raster(extent(swissRain@bbox), ncols=61, nrows=91, 
  crs=swissRain@proj4string)	
swissKrige = krige(swissFit, swissRain, swissRaster, swissAltitude)


swissFit =  likfit(swissRain, lograin ~ elevation, 
	cov.model="matern", kappa = 2, fix.kappa=TRUE,
	lambda=0.5, fix.lambda=TRUE,
	ini.cov.pars= c(0.6, 7000))
swissKrige = krige(obj.model=swissFit, geodata=swissRain, 
	locations=swissRaster, covariates=swissAltitude)


plot(swissKrige$prediction[["predict"]]) 
plot(swissBorder, add=TRUE)

Run the code above in your browser using DataLab