Learn R Programming

⚠️There's a newer version (0.11.4) of this package.Take me there.

gmGeostats

The goal of gmGeostats is to provide a unified framework for the geostatistical analysis of multivariate data from any statistical scale, e.g. data honoring a ratio scale, or with constraints such as spherical or compositional data.

This R package offers support for geostatistical analysis of multivariate data, in particular data with restrictions, e.g. positive amounts data, compositional data, distributional data, microstructural data, etc. It includes descriptive analysis and modelling for such data, both from a two-point Gaussian perspective and multipoint perspective. The package is devised for supporting 3D, multi-scale and large data sets and grids. This is a building block of the suite of HIF geometallurgical software.

Installation

You can install the released version of gmGeostats from CRAN with:

install.packages("gmGeostats")

Example

Read the package vignette for an extended scheme of the package functionality. The fundamental steps are:

## load the package (NOTE: do not load "compositions" or "gstat" afterwards!)
library(gmGeostats)
#> Welcome to 'gmGeostats', a package for multivariate geostatistical analysis.
#>  Note: use 'fit_lmc' instead of fit.lmc

## read your data, identify coordinates and sets of variables
data("Windarling") # use here some read*(...) function
colnames(Windarling)
#>  [1] "Hole_id"     "Sample.West" "Sample.East" "West"        "East"       
#>  [6] "Easting"     "Northing"    "Lithotype"   "Fe"          "P"          
#> [11] "SiO2"        "Al2O3"       "S"           "Mn"          "CL"         
#> [16] "LOI"
X = Windarling[,c("Easting", "Northing")]
Z = Windarling[,c(9:12,14,16)]

## declare the scale of each set of variables
Zc = compositions::acomp(Z) # other scales will come in the future

## pack the data in a gmSpatialModel object using an appropriate
#     make.** function
gsm = make.gmCompositionalGaussianSpatialModel(
  data = Zc, coords = X, V = "alr", formula = ~1
)

From this point on, what you do depends on which model do you have in mind. Here we briefly cover the case of a Gaussian model, though a multipoint approach can also be tackled with function make.gmCompositionalMPSSpatialModel() providing a training image as model. See the package vignette for details.

A structural analysis can be obtained in the following steps

## empirical structural function
vge = variogram(gsm)

## model specification
vm = gstat::vgm(model="Sph", range=25, nugget=1, psill=1)
# you can use gstat specifications!

## model fitting
gsm.f = fit_lmc(v = vge, g = gsm, model = vm)

## plot
variogramModelPlot(vge, model = gsm.f, col="red")

The resulting variogram model (gsm.f$model in case of a “gstat” object) can the be appended to the spatial model, with

gsm = make.gmCompositionalGaussianSpatialModel(
  data = Zc, coords = X, V = "alr", formula = ~1,
  model = gsm.f$model
)

Other empirical structural functions (e.g. logratio variograms from package “compositions”) and their theoretical counterparts (e.g. “CompLinModCoReg” objects from “compositions” or “LMCAnisCompo” from “gmGeostats”) can also be estimated resp. fitted and given to the argument model of this call to make.gmCompositionalGaussianSpatialModel. Other additional arguments are the mean value in case of simple (co)kriging, or descriptors of the local neighbourhood (see ?make.gmCompositionalGaussianSpatialModel for more information), both using the same parameter names as in ?gstat::gstat for ease of use.

The resulting geostatistical model (including conditioning data and structural model) can then be validated, interpolated and/or simulated. The workflow for each of these tasks is always:

1.- define some method parameters with a tailored function, e.g. LeaveOneOut() for validation, KrigingNeighbourhood() for cokriging (the neighbourgood can also be appended to make.*SpatialModel()-calls) or SequentialSimulation() for sequential Gaussian Simulation

2.- if desired, define some new locations where to interpolate or simulate, using expand.grid(), sp::GridTopology() or alternatives from other packages

3.- call an appropriate analysis function, specifying the model, potential new data, and the parameters created in the preceding steps; e.g. validate(model, pars) for validation, or predict(model, newdata, pars) for interpolation or simulation

More information can be found in the package vignette.

Copy Link

Version

Install

install.packages('gmGeostats')

Monthly Downloads

284

Version

0.11.1

License

CC BY-SA 4.0 | GPL (>= 2)

Maintainer

K Gerald van den Boogaart

Last Published

May 3rd, 2022

Functions in gmGeostats (0.11.1)

EmpiricalStructuralFunctionSpecification-class

Empirical structural function specification
LMCAnisCompo

Create a anisotropic model for regionalized compositions
LeaveOneOut

Specify the leave-one-out strategy for validation of a spatial model
AnisotropyRangeMatrix

Force a matrix to be anisotropy range matrix,
AnisotropyScaling

Convert to anisotropy scaling matrix
GridOrNothing-class

Superclass for grid or nothing
KrigingNeighbourhood

Create a parameter set of local for neighbourhood specification.
DataFrameStack

Create a data frame stack
CholeskyDecomposition

Create a parameter set specifying a LU decomposition simulation algorithm
DSpars

Create a parameter set specifying a direct sampling algorithm
ana

Flow anamorphosis transform Compute a transformation that gaussianizes a certain data set
Windarling

Ore composition of a bench at a mine in Windarling, West Australia.
NfoldCrossValidation

Specify a strategy for validation of a spatial model
as.gmEVario

Convert empirical structural function to gmEVario format
NGSAustralia

National Geochemical Survey of Australia: soil data
as.gmCgram.variogramModelList

Convert theoretical structural functions to gmCgram format
anaForward

Forward gaussian anamorphosis forward transformation to multivariate gaussian scores
ModelStructuralFunctionSpecification-class

Structural function model specification
Maf

Generalised diagonalisations Calculate several generalized diagonalisations out of a data set and its empirical variogram
anis_GSLIBpar2A

Produce anisotropy scaling matrix from angle and anisotropy ratios
as.array.DataFrameStack

Convert a stacked data frame into an array
accuracy

Compute accuracy and precision
as.function.gmCgram

Convert a gmCgram object to an (evaluable) function
anaBackward

Backward gaussian anamorphosis backward transformation to multivariate gaussian scores
as.gstatVariogram

Represent an empirical variogram in "gstatVariogram" format
getStackElement

Set or get the i-th data frame of a data.frame stack
as.logratioVariogram

Recast empirical variogram to format logratioVariogram
gmApply

Apply Functions Over Array or DataFrameStack Margins
gmGaussianMethodParameters-class

parameters for Spatial Gaussian methods of any kind
as.list.DataFrameStack

Convert a stacked data frame into a list of data.frames
as.CompLinModCoReg

Recast a model to the variogram model of package "compositions"
constructMask

Constructs a mask for a grid
dimnames.DataFrameStack

Return the dimnames of a DataFrameStack
as.LMCAnisCompo.gstat

Recast compositional variogram model to format LMCAnisCompo
coloredBiplot.genDiag

Colored biplot for gemeralised diagonalisations Colored biplot method for objects of class genDiag
as.variogramModel

Convert an LMC variogram model to gstat format
as.logratioVariogramAnisotropy

Convert empirical variogram to "logratioVariogramAnisotropy"
SequentialSimulation

Create a parameter set specifying a gaussian sequential simulation algorithm
gmMPSParameters-class

parameters for Multiple-Point Statistics methods
gmGaussianSimulationAlgorithm-class

parameters for Gaussian Simulation methods
gsi.calcCgram

Compute covariance matrix oout of locations
gsi.DS

Workhorse function for direct sampling
gsi.EVario2D

Empirical variogram or covariance function in 2D
as.AnisotropyRangeMatrix

Force a matrix to be anisotropy range matrix,
TurningBands

Create a parameter set specifying a turning bands simulation algorithm
as.AnisotropyScaling

Convert to anisotropy scaling matrix
gmUnconditionalSpatialModel-class

General description of a spatial model
as.gstat

Convert a regionalized data container to gstat
as.gmSpatialModel

Recast spatial object to gmSpatialModel format
gmNeighbourhoodSpecification-class

Neighbourhood description
gmSimulationAlgorithm-class

Parameter specification for a spatial simulation algorithm
getTellus

Download the Tellus survey data set (NI)
gsi.gstatCokriging2compo

Reorganisation of cokriged compositions
gsi.Cokriging

Cokriging of all sorts, internal function
gmValidationStrategy-class

Validation strategy description
precision

Precision calculations
+.gmCgram

Combination of gmCgram variogram structures
has.missings.data.frame

Check presence of missings check presence of missings in a data.frame
gmSpatialDataContainer-class

General description of a spatial data container
gmSpatialMethodParameters-class

Parameter specification for any spatial method
image.logratioVariogramAnisotropy

Plot variogram maps for anisotropic logratio variograms
length.gmCgram

Length, and number of columns or rows
gsi.CondTurningBands

Internal function, conditional turning bands realisations
gsi.EVario3D

Empirical variogram or covariance function in 3D
gsi.orig

extract information about the original data, if available
fit_lmc

Fit an LMC to an empirical variogram
make.gmCompositionalMPSSpatialModel

Construct a Multi-Point gmSpatialModel for regionalized compositions
getMask

Get the mask info out of a spatial data object
setCgram

Generate D-variate variogram models
pwlrmap

Compositional maps, pairwise logratios Matrix of maps showing different combinations of components of a composition, in pairwise logratios
gsi.TurningBands

Internal function, unconditional turning bands realisations
is.anisotropySpecification

Check for any anisotropy class
[[.gmCgram

Subsetting of gmCgram variogram structures
[.logratioVariogramAnisotropy

Subsetting of logratioVariogram objects
write.GSLib

Write a regionalized data set in GSLIB format
gmSpatialModel-class

Conditional spatial model data container
xvErrorMeasures

Cross-validation errror measures
plot.swarmPlot

Plotting method for swarmPlot objects
plot.logratioVariogramAnisotropy

Plot variogram lines of empirical directional logratio variograms
logratioVariogram,acomp-method

Logratio variogram of a compositional data
make.gmMultivariateGaussianSpatialModel

Construct a Gaussian gmSpatialModel for regionalized multivariate data
gsi.produceV

Create a matrix of logcontrasts and name prefix
gmTrainingImage-class

MPS training image class
image.mask

Image method for mask objects
[.DataFrameStack

Extract rows of a DataFrameStack
mean.accuracy

Mean accuracy
ndirections

Number of directions of an empirical variogram
is.isotropic

Check for anisotropy of a theoretical variogram
Predict

Predict method for objects of class 'gmSpatialModel'
noSpatCorr.test

Test for lack of spatial correlation
mean.spatialDecorrelationMeasure

Average measures of spatial decorrelation
plot.gmCgram

Draw cuves for covariance/variogram models
plot.gmEVario

Plot empirical variograms
spectralcolors

Spectral colors palette based on the RColorBrewer::brewer.pal(11,"Spectral")
print.mask

Print method for mask objects
sortDataInGrid

Reorder data in a grid
variogramModelPlot

Quick plotting of empirical and theoretical variograms Quick and dirty plotting of empirical variograms/covariances with or without their models
variogramModelPlot.gstatVariogram

Quick plotting of empirical and theoretical variograms Quick and dirty plotting of empirical variograms/covariances with or without their models
sphTrans

Spherifying transform Compute a transformation that spherifies a certain data set
unmask

Unmask a masked object
[.gmCgram

Subsetting of gmCgram variogram structures
validate

Validate a spatial model
setMask

Set a mask on an object
swath

Swath plots
setGridOrder

Set or get the ordering of a grid
swarmPlot

Plot a swarm of calculated output through a DataFrameStack
spatialDecorrelation

Compute diagonalisation measures
stackDim

Get/set name/index of (non)stacking dimensions
stackDim,Spatial-method

Get name/index of the stacking dimension of a Spatial object
image_cokriged

Plot an image of gridded data
logratioVariogram

Empirical logratio variogram calculation
variogramModelPlot.logratioVariogram

Quick plotting of empirical and theoretical logratio variograms Quick and dirty plotting of empirical logratio variograms with or without their models
make.gmCompositionalGaussianSpatialModel

Construct a Gaussian gmSpatialModel for regionalized compositions
xvErrorMeasures.default

Cross-validation errror measures
logratioVariogram_gmSpatialModel

Variogram method for gmSpatialModel objects
plot.accuracy

Plot method for accuracy curves
pairsmap

Multiple maps Matrix of maps showing different combinations of components of a composition, user defined
predict.LMCAnisCompo

Compute model variogram values Evaluate the variogram model provided at some lag vectors
predict.genDiag

Predict method for generalised diagonalisation objects
spatialGridAcomp

Construct a regionalized composition / reorder compositional simulations
spatialGridRmult

Construct a regionalized multivariate data