Learn R Programming

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

239

Version

0.11.3

License

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

Maintainer

K Gerald van den Boogaart

Last Published

April 18th, 2023

Functions in gmGeostats (0.11.3)

ModelStructuralFunctionSpecification-class

Structural function model specification
NfoldCrossValidation

Specify a strategy for validation of a spatial model
SequentialSimulation

Create a parameter set specifying a gaussian sequential simulation algorithm
ana

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

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

Create a parameter set specifying a turning bands simulation algorithm
Windarling

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

Backward gaussian anamorphosis backward transformation to multivariate gaussian scores
accuracy

Compute accuracy and precision
NGSAustralia

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

Convert a gmCgram object to an (evaluable) function
as.AnisotropyRangeMatrix

Force a matrix to be anisotropy range matrix,
anis_GSLIBpar2A

Produce anisotropy scaling matrix from angle and anisotropy ratios
anaForward

Forward gaussian anamorphosis forward transformation to multivariate gaussian scores
as.gstat

Convert a regionalized data container to gstat
as.gstatVariogram

Represent an empirical variogram in "gstatVariogram" format
as.array.DataFrameStack

Convert a stacked data frame into an array
as.directorVector

Express a direction as a director vector
as.AnisotropyScaling

Convert to anisotropy scaling matrix
as.gmSpatialModel

Recast spatial object to gmSpatialModel format
as.gmEVario.gstatVariogram

Convert empirical structural function to gmEVario format
gmNeighbourhoodSpecification-class

Neighbourhood description
gmGaussianSimulationAlgorithm-class

parameters for Gaussian Simulation methods
constructMask

Constructs a mask for a grid
gmGaussianMethodParameters-class

parameters for Spatial Gaussian methods of any kind
coloredBiplot.genDiag

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

Convert empirical variogram to "logratioVariogramAnisotropy"
gsi.Cokriging

Cokriging of all sorts, internal function
as.variogramModel

Convert an LMC variogram model to gstat format
as.gmCgram.variogramModelList

Convert theoretical structural functions to gmCgram format
as.CompLinModCoReg

Recast a model to the variogram model of package "compositions"
as.LMCAnisCompo.gstat

Recast compositional variogram model to format LMCAnisCompo
gmMPSParameters-class

parameters for Multiple-Point Statistics methods
getMask

Get the mask info out of a spatial data object
gmValidationStrategy-class

Validation strategy description
gmUnconditionalSpatialModel-class

General description of a spatial model
gmTrainingImage-class

MPS training image class
getStackElement

Set or get the i-th data frame of a data.frame stack
gmSimulationAlgorithm-class

Parameter specification for a spatial simulation algorithm
getTellus

Download the Tellus survey data set (NI)
gmSpatialMethodParameters-class

Parameter specification for any spatial method
gmApply

Apply Functions Over Array or DataFrameStack Margins
as.logratioVariogram.gstatVariogram

Recast empirical variogram to format logratioVariogram
dimnames.DataFrameStack

Return the dimnames of a DataFrameStack
as.list.DataFrameStack

Convert a stacked data frame into a list of data.frames
fit_lmc

Fit an LMC to an empirical variogram
gsi.orig

extract information about the original data, if available
gmSpatialModel-class

Conditional spatial model data container
gsi.gstatCokriging2compo

Reorganisation of cokriged compositions
image_cokriged

Plot an image of gridded data
gmSpatialDataContainer-class

General description of a spatial data container
gsi.TurningBands

Internal function, unconditional turning bands realisations
gsi.calcCgram

Compute covariance matrix oout of locations
make.gmMultivariateGaussianSpatialModel

Construct a Gaussian gmSpatialModel for regionalized multivariate data
is.anisotropySpecification

Check for any anisotropy class
gsi.produceV

Create a matrix of logcontrasts and name prefix
image.logratioVariogramAnisotropy

Plot variogram maps for anisotropic logratio variograms
image.mask

Image method for mask objects
pairsmap

Multiple maps Matrix of maps showing different combinations of components of a composition, user defined
noSpatCorr.test

Test for lack of spatial correlation
logratioVariogram,acomp-method

Logratio variogram of a compositional data
logratioVariogram

Empirical logratio variogram calculation
gsi.EVario2D

Empirical variogram or covariance function in 2D
gsi.CondTurningBands

Internal function, conditional turning bands realisations
length.gmCgram

Length, and number of columns or rows
plot.gmEVario

Plot empirical variograms
gsi.DS

Workhorse function for direct sampling
is.isotropic

Check for anisotropy of a theoretical variogram
gsi.EVario3D

Empirical variogram or covariance function in 3D
plot.gmCgram

Draw cuves for covariance/variogram models
plot.accuracy

Plot method for accuracy curves
has.missings.data.frame

Check presence of missings check presence of missings in a data.frame
mean.accuracy

Mean accuracy
Predict

Predict method for objects of class 'gmSpatialModel'
plot.logratioVariogramAnisotropy

Plot variogram lines of empirical directional logratio variograms
mean.spatialDecorrelationMeasure

Average measures of spatial decorrelation
predict.genDiag

Predict method for generalised diagonalisation objects
precision

Precision calculations
predict.LMCAnisCompo

Compute model variogram values Evaluate the variogram model provided at some lag vectors
setCgram

Generate D-variate variogram models
make.gmCompositionalGaussianSpatialModel

Construct a Gaussian gmSpatialModel for regionalized compositions
make.gmCompositionalMPSSpatialModel

Construct a Multi-Point gmSpatialModel for regionalized compositions
plot.swarmPlot

Plotting method for swarmPlot objects
setGridOrder

Set or get the ordering of a grid
sphTrans

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

Reorder data in a grid
[.DataFrameStack

Extract rows of a DataFrameStack
stackDim,Spatial-method

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

Construct a regionalized multivariate data
setMask

Set a mask on an object
ndirections

Number of directions of an empirical variogram
stackDim

Get/set name/index of (non)stacking dimensions
+.gmCgram

Combination of gmCgram variogram structures
print.mask

Print method for mask objects
[.gmCgram

Subsetting of gmCgram variogram structures
spectralcolors

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

Construct a regionalized composition / reorder compositional simulations
spatialDecorrelation

Compute diagonalisation measures
variogramModelPlot.gstatVariogram

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

Quick plotting of empirical and theoretical logratio variograms Quick and dirty plotting of empirical logratio variograms with or without their models
pwlrmap

Compositional maps, pairwise logratios Matrix of maps showing different combinations of components of a composition, in pairwise logratios
variogramModelPlot

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

Validate a spatial model
[.logratioVariogramAnisotropy

Subsetting of logratioVariogram objects
logratioVariogram_gmSpatialModel

Variogram method for gmSpatialModel objects
[[.gmCgram

Subsetting of gmCgram variogram structures
swarmPlot

Plot a swarm of calculated output through a DataFrameStack
unmask

Unmask a masked object
swath

Swath plots
xvErrorMeasures

Cross-validation errror measures
xvErrorMeasures.default

Cross-validation errror measures
write.GSLib

Write a regionalized data set in GSLIB format
CholeskyDecomposition

Create a parameter set specifying a LU decomposition simulation algorithm
DSpars

Create a parameter set specifying a direct sampling algorithm
LMCAnisCompo

Create a anisotropic model for regionalized compositions
LeaveOneOut

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

Superclass for grid or nothing
AnisotropyRangeMatrix

Force a matrix to be anisotropy range matrix,
EmpiricalStructuralFunctionSpecification-class

Empirical structural function specification
DataFrameStack

Create a data frame stack
AnisotropyScaling

Convert to anisotropy scaling matrix
KrigingNeighbourhood

Create a parameter set of local for neighbourhood specification.