Learn R Programming

geostatsp (version 0.7.0)

lgm: Linear Geostatistical Models

Description

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

Usage

lgm(data, locations, covariates = NULL, formula = NULL, rough = 1, 
    fixRough = TRUE, aniso = FALSE, boxcox = 1, fixBoxcox = TRUE, 
    nugget = 0, fixNugget = FALSE, expPred = FALSE, nugget.in.prediction = 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.
rough
Order of the Matern correlation
fixRough
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.
nugget.in.prediction
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

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 likfit and krige

See Also

likfit, krige

Examples

Run this code
data("swissRain")
 
swissRes =  lgm(swissRain, locations=20, formula="rain",
	covariates=swissAltitude, boxcox=0.5, fixBoxcox=TRUE, 
	rough=1, fixRough=TRUE,
	aniso=TRUE, nugget=0, fixNugget=TRUE,
	nugget.in.prediction=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"))
theMap = openmap(gadm,zoom=7, type="mapquest")#"osm-transport")
library(RColorBrewer)
par(mar=c(0,0,0,3))
plot(gadm) 
plot(theMap, add=TRUE)
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