Learn R Programming

geostatsp (version 0.9.9)

lgm: Linear Geostatistical Models

Description

Calculate MLE's of model parameters and perform spatial prediction.

Usage

lgm(data, locations, covariates = NULL, formula = NULL, shape = 1, 
    fixShape = TRUE, aniso = FALSE, boxcox = 1, fixBoxcox = TRUE, 
    nugget = 0, fixNugget = FALSE, expPred = FALSE, nuggetInPrediction = TRUE,
    ...)

Arguments

data
A SpatialPointsDataFrame containing the data to be interpolated, or a vector of observed data
covariates
The spatial covariates used in prediction, either a raster stack or list of rasters. Covariates in formula but not in data will be extracted from covariates.
locations
Either a raster, or a single integer giving the number of cells in the X direction which predictions will be made on. If the later the predictions will be a raster of square cells covering the boundin
formula
A model formula for the fixed effects.
shape
Order of the Matern correlation
fixShape
Set to FALSE to estimate the Matern order
aniso
Set to TRUE to use geometric anisotropy.
boxcox
Box-Cox transformation parameter, set to 1 for no transformation.
fixBoxcox
Set to FALSE to estimate the Box-Cox parameter.
nugget
Value for the nugget effect (observation error
fixNugget
Set to FALSE to estimate the nugget effect parameter.
expPred
Should the predictions be exponentiated, defaults to FALSE.
nuggetInPrediction
If TRUE, predict new observations by adding the nugget effect. The prediction variances will be adjusted accordingly, and the predictions on the natural scale for logged or Box Cox transformed data will be affected. Otherwise predict fitt
...
Additional arguments passed to likfitLgm. Starting values can be specified with a vector param of named elements

Value

  • A raster stack is returned with the following layers:
  • fixedEstimated means from the fixed effects portion of the model
  • randomPredicted random effect
  • krigeSdConditional standard deviation of predicted random effect (on the transformed scale if applicable)
  • predictPrediction of the response, sum of predicted fixed and random effects. For Box-Cox or log-transformed data on the natural (untransformed) scale.
  • predict.logIf exp.pred=TRUE, the prediction of the logged process.
  • predict.boxcoxIf a box cox transformation was used, the prediction of the process on the transformed scale.

Details

Calls likfitLgm and krige

See Also

likfitLgm, krige

Examples

Run this code
data("swissRain")
 
swissRes =  lgm(swissRain, locations=20, formula="rain",
	covariates=swissAltitude, boxcox=0.5, fixBoxcox=TRUE, 
	shape=1, fixShape=TRUE,
	aniso=FALSE, nugget=0, fixNugget=TRUE,
	nuggetInPrediction=FALSE
	)
	

swissRes$summary

plot(swissRes$predict[["predict"]], main="predicted rain") 
plot(swissBorder, add=TRUE)



load(url("http://www.filefactory.com/file/frd1mhownd9/n/CHE_adm0_RData"))

library(RColorBrewer)
par(mar=c(0,0,0,3))
plot(gadm) 
plot(mask(projectRaster(
	swissRes$predict[["predict"]],  crs=gadm@proj4string),gadm), 
add=T,alpha=0.6, col=brewer.pal(9, "Blues"))
plot(gadm, add=TRUE)

Run the code above in your browser using DataLab