Last data update: 2014.03.03

R: Fits a 2D or 3D variogram model to spatial data
fit.vgmModel-methodsR Documentation

Fits a 2D or 3D variogram model to spatial data

Description

Fits a 2D or 3D variogram model based on a regression matrix and spatial domain of interest.

Usage

## S4 method for signature 'formula,data.frame,SpatialPixelsDataFrame'
fit.vgmModel(formulaString,
      rmatrix, predictionDomain, vgmFun = "Exp", 
      dimensions = list("2D", "3D", "2D+T", "3D+T"),
      anis = NULL, subsample = nrow(rmatrix), ivgm, cutoff = NULL,
      width, cressie = FALSE, ...)

Arguments

formulaString

object of class "formula" — regression model

rmatrix

object of class "data.frame"; regression matrix produced as a result of spatial overlay

predictionDomain

object of class "SpatialPixelsDataFrame"; spatial domain of interest

vgmFun

character; variogram function ("Exp" by default)

dimensions

character; "3D", "2D", "2D+T", "3D+T" models

anis

vector containing 2, 5 or more anisotropy parameters; see gstat::vgm for more info

subsample

integer; size of the subset

ivgm

vgm; initial variogram model

cutoff

numeric; distance up to which point pairs are included in semivariance estimates

width

numeric; sample variogram bin width

cressie

logical; specifies whether to use cressie robust estimator

...

other optional arguments that can be passed to gstat::fit.variogram

Details

It will try to fit a variogram to multidimensional data. If the data set is large, this process can be time-consuming, hence one way to speed up fitting is to subset the regression matrix using the subsample argument (i.e. randomly subset observations).

Author(s)

Tomislav Hengl

See Also

fit.regModel, fit.gstatModel, gstat::fit.variogram

Examples

library(sp)
library(gstat)

## fit variogram to the Meuse data:
demo(meuse, echo=FALSE)
# produce a regression matrix:
ov <- over(meuse, meuse.grid)
ov <- cbind(data.frame(meuse["om"]), ov)
# fit a model:
v <- fit.vgmModel(om~1, rmatrix=ov, meuse.grid, dimensions="2D")
plot(variogram(om ~ 1, meuse[!is.na(meuse$om),]), v$vgm)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(GSIF)
GSIF version 0.5-2 (2016-06-25)
URL: http://gsif.r-forge.r-project.org/
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GSIF/fit.vgmModel.Rd_%03d_medium.png", width=480, height=480)
> ### Name: fit.vgmModel-methods
> ### Title: Fits a 2D or 3D variogram model to spatial data
> ### Aliases: fit.vgmModel
> ###   fit.vgmModel,formula,data.frame,SpatialPixelsDataFrame-method
> 
> ### ** Examples
> 
> library(sp)
> library(gstat)
> 
> ## fit variogram to the Meuse data:
> demo(meuse, echo=FALSE)
> # produce a regression matrix:
> ov <- over(meuse, meuse.grid)
> ov <- cbind(data.frame(meuse["om"]), ov)
> # fit a model:
> v <- fit.vgmModel(om~1, rmatrix=ov, meuse.grid, dimensions="2D")
> plot(variogram(om ~ 1, meuse[!is.na(meuse$om),]), v$vgm)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>