Learn R Programming

GSIF (version 0.5-5.1)

gstatModel-class: A class for a geostatistical model

Description

A class containing fitted parameters of a geostatistical model to be used to run predictions by regression-kriging. It comprises regression model (e.g. a GLM), variogram model, and observation locations of sampled values used to fit the model.

Arguments

Slots

regModel:

object of class "ANY"; output of fitting a generalized linear model (GLM) or any similar regression model

svgmModel:

object of class "data.frame"; sample variogram with semivariances and distances

vgmModel:

object of class "data.frame"; the fitted gstat variogram model parameters containing variogram model, nugget, sill, range and the five anisotropy parameters

sp:

object of class "SpatialPointsDataFrame"; observation locations

Methods

predict

signature(obj = "gstatModel"): makes predictions for a set of given predictionLocations (gridded maps) at block support corresponding to the cellsize slot in the object of class "SpatialPixelsDataFrame"; to produce predictions at point support, submit the predictionLocations as "SpatialPointsDataFrame"

validate

signature(obj = "gstatModel"): runs n-fold cross-validation of the existing gstatModel (it re-fits the model using existing formula string and model data, then estimates the mapping error at validation locations)

plot

signature(obj = "gstatModel", ...): plots goodness of fit and variogram model

Details

Any model passed to the regModel slot must come with generic functions such as residuals, fitted.values, summary, formula and predict.

See Also

predict.gstatModel, test.gstatModel, plotKML::SpatialPredictions-class, plotKML::RasterBrickSimulations-class, gstat::gstat, stats::glm

Examples

Run this code
# NOT RUN {
## load observations:
library(plotKML)
library(sp)
library(maptools)
demo(meuse, echo=FALSE)
data(meuse)
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
## load grids:
data(meuse.grid)
coordinates(meuse.grid) <- ~x+y
gridded(meuse.grid) <- TRUE
proj4string(meuse.grid) <- CRS("+init=epsg:28992")
## fit a model:
omm <- fit.gstatModel(meuse, om~dist+ffreq, 
  fit.family=gaussian(link="log"), meuse.grid)
plot(omm)
## produce SpatialPredictions:
om.rk <- predict(omm, predictionLocations = meuse.grid)
plot(om.rk)
## run a proper cross-validation:
rk.cv <- validate(omm)
## RMSE:
sqrt(mean((rk.cv$validation$var1.pred-rk.cv$validation$observed)^2))
# }

Run the code above in your browser using DataLab