Fitting variograms

Overview

Fitting theoretical variograms to empirical observations is an important modeling step to ensure valid mathematical models of spatial continuity. Given an empirical variogram, the fit function can be used to perform the fit:

GeoStatsFunctions.fit โ€” Method
fit(V, g, algo=WeightedLeastSquares(); range=nothing, sill=nothing, nugget=nothing)

Fit theoretical variogram type V to empirical variogram g using algorithm algo.

Optionally fix range, sill or nugget by passing them as keyword arguments, or set their maximum value with maxrange, maxsill or maxnugget.

Examples

julia> fit(SphericalVariogram, g)
julia> fit(ExponentialVariogram, g)
julia> fit(ExponentialVariogram, g, sill=1.0)
julia> fit(ExponentialVariogram, g, maxsill=1.0)
julia> fit(GaussianVariogram, g, WeightedLeastSquares())
fit(Vs, g, algo=WeightedLeastSquares(); kwargs...)

Fit theoretical variogram types Vs to empirical variogram g using algorithm algo and return the one with minimum error.

Examples

julia> fit([SphericalVariogram, ExponentialVariogram], g)
fit(Variogram, g, algo=WeightedLeastSquares(); kwargs...)

Fit all "fittable" subtypes of Variogram to empirical variogram g using algorithm algo and return the one with minimum error.

Examples

julia> fit(Variogram, g)
julia> fit(Variogram, g, WeightedLeastSquares())

See also GeoStatsFunctions.fittable().

Example

# sinusoidal data
๐’Ÿ = georef((Z=[sin(i/2) + sin(j/2) for i in 1:50, j in 1:50],))

# empirical variogram
g = EmpiricalVariogram(๐’Ÿ, :Z, maxlag = 25.)

Mke.plot(g)

We can fit specific models to the empirical variogram:

ฮณ = GeoStatsFunctions.fit(SineHoleVariogram, g)

Mke.plot(g)
Mke.plot!(ฮณ, maxlag = 25.)
Mke.current_figure()

or let the framework find the model with minimum error:

ฮณ = GeoStatsFunctions.fit(Variogram, g)

Mke.plot(g)
Mke.plot!(ฮณ, maxlag = 25.)
Mke.current_figure()

which should be a SineHoleVariogram given that the synthetic data of this example is sinusoidal.

Optionally, we can specify a weighting function to give different weights to the lags:

ฮณ = GeoStatsFunctions.fit(SineHoleVariogram, g, h -> exp(-h))

Mke.plot(g)
Mke.plot!(ฮณ, maxlag = 25.)
Mke.current_figure()

Methods

Weighted least squares

GeoStatsFunctions.WeightedLeastSquares โ€” Type
WeightedLeastSquares()
WeightedLeastSquares(w)

Fit theoretical variogram using weighted least squares with weighting function w (e.g. h -> 1/h). If no weighting function is provided, bin counts of empirical variogram are normalized and used as weights.