Learn R Programming

plotKML (version 0.2-2)

fit.gstatModel-methods: Methods to fit a regression-kriging model

Description

Tries to automatically fit a regression-kriging model for a given set of points and covariates (object of type "SpatialPixelsDataFrame"; 2-dimensional objects only applicable). It runs GLM following the formulaString model and then fits variogram for residuals usign the fit.variogram method from the package gstat. Creates an output object of class gstatModel-class.

Usage

fit.gstatModel(observations, formulaString, covariates, ...)

Arguments

observations
object of type "SpatialPointsDataFrame"
formulaString
object of type "formula" or a character
covariates
object of type "SpatialPixelsDataFrame"
...
other optional arguments that can be passed to glm and/or fit.variogram

Details

Optional arguments are vgmFun --- variogram model type passed from gstat; family --- character string defyning the GLM family (for more info see stats::glm); stepwise --- specifies wether to run step-wise regression on top of GLM to get an optimal subset of predictors. The method by default assumes that the target variable follows a normal distribution family = gaussian. Possible distributions are: [object Object],[object Object],[object Object],[object Object]

References

  • Hengl, T. (2009)http://spatial-analyst.net/book/{A Practical Guide to Geostatistical Mapping}, 2nd Edt. University of Amsterdam, www.lulu.com, 291 p.

See Also

gstatModel-class, stats::glm, gstat::fit.variogram

Examples

Run this code
data(meuse)
coordinates(meuse) <- ~x+y
# load grids:
data(meuse.grid)
coordinates(meuse.grid) <- ~x+y
gridded(meuse.grid) <- TRUE
# fit a model:
omm <- fit.gstatModel(observations = meuse, om~dist, covariates = meuse.grid,
  family = gaussian(log))
show(omm@regModel)
om.sp <- SpatialPointsDataFrame(omm@sp, data = omm@regModel$model)
# plot a variogram:
plot(variogram(om~1, om.sp))

Run the code above in your browser using DataLab