Learn R Programming

⚠️There's a newer version (0.11.3) 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

244

Version

0.11.0

License

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

Maintainer

K Gerald van den Boogaart

Last Published

October 18th, 2021

Functions in gmGeostats (0.11.0)

Maf

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

Create a anisotropic model for regionalized compositions
anaBackward

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

Represent an empirical variogram in "gstatVariogram" format
LeaveOneOut

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

Flow anamorphosis transform Compute a transformation that gaussianizes a certain data set
as.gstat

Convert a regionalized data container to gstat
DataFrameStack

Create a data frame stack
EmpiricalStructuralFunctionSpecification-class

Empirical structural function specification
NGSAustralia

National Geochemical Survey of Australia: soil data
CholeskyDecomposition

Create a parameter set specifying a LU decomposition simulation algorithm
GridOrNothing-class

Superclass for grid or nothing
KrigingNeighbourhood

Create a parameter set of local for neighbourhood specification.
DSpars

Create a parameter set specifying a direct sampling algorithm
TurningBands

Create a parameter set specifying a turning bands simulation algorithm
SequentialSimulation

Create a parameter set specifying a gaussian sequential simulation algorithm
NfoldCrossValidation

Specify a strategy for validation of a spatial model
anis2D.par2A

Produce anisotropy matrix from angle and anisotropy ratios
anaForward

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

Structural function model specification
as.gmEVario

Convert empirical structural function to gmEVario format
as.LMCAnisCompo.gstat

Recast compositional variogram model to format LMCAnisCompo
as.AnisotropyScaling

Convert to anisotropy scaling matrix
as.logratioVariogramAnisotropy

Convert empirical variogram to "logratioVariogramAnisotropy"
dimnames.DataFrameStack

Return the dimnames of a DataFrameStack
as.gmSpatialModel

Recast spatial object to gmSpatialModel format
as.variogramModel

Convert an LMC variogram model to gstat format
coloredBiplot.genDiag

Colored biplot for gemeralised diagonalisations Colored biplot method for objects of class genDiag
gmGaussianMethodParameters-class

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

Convert a stacked data frame into an array
gmValidationStrategy-class

Validation strategy description
gmGaussianSimulationAlgorithm-class

parameters for Gaussian Simulation methods
constructMask

Constructs a mask for a grid
gmSimulationAlgorithm-class

Parameter specification for a spatial simulation algorithm
gmSpatialDataContainer-class

General description of a spatial data container
gmTrainingImage-class

MPS training image class
gmUnconditionalSpatialModel-class

General description of a spatial model
fit_lmc

Fit an LMC to an empirical variogram
image.logratioVariogramAnisotropy

Plot variogram maps for anisotropic logratio variograms
has.missings.data.frame

Check presence of missings check presence of missings in a data.frame
logratioVariogram

Empirical logratio variogram calculation
make.gmCompositionalGaussianSpatialModel

Construct a Gaussian gmSpatialModel for regionalized compositions
gmSpatialMethodParameters-class

Parameter specification for any spatial method
gmSpatialModel-class

Conditional spatial model data container
accuracy

Compute accuracy and precision
as.function.gmCgram

Convert a gmCgram object to an (evaluable) function
Windarling

Ore composition of a bench at a mine in Windarling, West Australia.
as.gmCgram.variogramModelList

Convert theoretical structural functions to gmCgram format
precision

Precision calculations
pwlrmap

Compositional maps, pairwise logratios Matrix of maps showing different combinations of components of a composition, in pairwise logratios
+.gmCgram

Combination of gmCgram variogram structures
setCgram

gmGeostats Variogram models set up a D-variate variogram models
gsi.CondTurningBands

Internal function, conditional turning bands realisations
is.anisotropySpecification

Check for any anisotropy class
gsi.DS

Workhorse function for direct sampling
is.isotropic

Check for anisotropy of a theoretical variogram
as.CompLinModCoReg

Recast a model to the variogram model of package "compositions"
as.list.DataFrameStack

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

Get the mask info out of a spatial data object
[.DataFrameStack

Extract rows of a DataFrameStack
[.gmCgram

Subsetting of gmCgram variogram structures
as.logratioVariogram

Recast empirical variogram to format logratioVariogram
mean.spatialDecorrelationMeasure

Average measures of spatial decorrelation
plot.gmCgram

Draw cuves for covariance/variogram models
mean.accuracy

Mean accuracy
xvErrorMeasures

Cross-validation errror measures
write.GSLib

Write a regionalized data set in GSLIB format
gsi.Cokriging

Cokriging of all sorts, internal function
image.mask

Image method for mask objects
image_cokriged

Plot an image of gridded data
gmNeighbourhoodSpecification-class

Neighbourhood description
gmMPSParameters-class

parameters for Multiple-Point Statistics methods
getStackElement

Set or get the i-th data frame of a data.frame stack
gsi.calcCgram

Compute covariance matrix oout of locations
pairsmap

Multiple maps Matrix of maps showing different combinations of components of a composition, user defined
spectralcolors

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

Plot empirical variograms
sphTrans

Spherifying transform Compute a transformation that spherifies a certain data set
plot.accuracy

Plot method for accuracy curves
getTellus

Download the Tellus survey data set (NI)
[.logratioVariogramAnisotropy

Subsetting of logratioVariogram objects
[[.gmCgram

Subsetting of gmCgram variogram structures
xvErrorMeasures.default

Cross-validation errror measures
gsi.EVario2D

Empirical variogram or covariance function in 2D
gmApply

Apply Functions Over Array or DataFrameStack Margins
gsi.gstatCokriging2compo

Reorganisation of cokriged compositions
spatialGridAcomp

Construct a regionalized composition / reorder compositional simulations
plot.logratioVariogramAnisotropy

Plot variogram lines of empirical directional logratio variograms
spatialGridRmult

Construct a regionalized multivariate data
plot.swarmPlot

Plotting method for swarmPlot objects
gsi.TurningBands

Internal function, unconditional turning bands realisations
stackDim,Spatial-method

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

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

Length, and number of columns or rows
variogramModelPlot.gstatVariogram

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

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

extract information about the original data, if available
logratioVariogram,acomp-method

Logratio variogram of a compositional data
ndirections

Number of directions of an empirical variogram
noSpatCorr.test

Test for lack of spatial correlation
print.mask

Print method for mask objects
Predict

Predict method for objects of class 'gmSpatialModel'
setGridOrder

Set or get the ordering of a grid
gsi.produceV

Create a matrix of logcontrasts and name prefix
make.gmCompositionalMPSSpatialModel

Construct a Multi-Point gmSpatialModel for regionalized compositions
predict.LMCAnisCompo

Compute model variogram values Evaluate the variogram model provided at some lag vectors
make.gmMultivariateGaussianSpatialModel

Construct a Gaussian gmSpatialModel for regionalized multivariate data
setMask

Set a mask on an object
unmask

Unmask a masked object
predict.genDiag

Predict method for generalised diagonalisation objects
validate

Validate a spatial model
spatialDecorrelation

Compute diagonalisation measures
sortDataInGrid

Reorder data in a grid
swarmPlot

Plot a swarm of calculated output through a DataFrameStack
swath

Swath plots
logratioVariogram_gmSpatialModel

Variogram method for gmSpatialModel objects
variogramModelPlot.logratioVariogram

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