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 and its dependencies
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)

This 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 or SequentialSimulation() for sequential Gaussian Simulation

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

3.- call an appropriate 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

166

Version

0.10-6

License

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

Maintainer

K Gerald van den Boogaart

Last Published

September 16th, 2020

Functions in gmGeostats (0.10-6)

ModelStructuralFunctionSpecification-class

Structural function model specification
LeaveOneOut

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

Superclass for grid or nothing
CholeskyDecomposition

Create a parameter set specifying a LU decomposition simulation algorithm
Maf

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

Create a data frame stack
LMCAnisCompo

Create a anisotropic model for regionalized compositions
DSpars

Create a parameter set specifying a direct sampling algorithm
EmpiricalStructuralFunctionSpecification-class

Empirical structural function specification
KrigingNeighbourhood

Create a parameter set of local for neighbourhood specification.
Windarling

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

Create a parameter set specifying a gaussian sequential simulation algorithm
ana

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

Convert a stacked data frame into an array
anaBackward

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

Recast compositional variogram model to format LMCAnisCompo
as.gstatVariogram

Represent an empirical variogram in "gstatVariogram" format
NfoldCrossValidation

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

Convert a regionalized data container to gstat
NGSAustralia

National Geochemical Survey of Australia: soil data
anaForward

Forward gaussian anamorphosis forward transformation to multivariate gaussian scores
as.list.DataFrameStack

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

Compute accuracy and precision
anis2D.par2A

Produce anisotropy matrix from angle and anisotropy ratios
TurningBands

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

Convert to anisotropy scaling matrix
as.logratioVariogram

Recast empirical variogram to format logratioVariogram
as.gmEVario

Convert empirical structural function to gmEVario format
as.gmSpatialModel

Recast spatial object to gmSpatialModel format
as.function.gmCgram

Convert a gmCgram object to an (evaluable) function
getStackElement

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

Convert theoretical structural functions to gmCgram 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
gmGaussianSimulationAlgorithm-class

parameters for Gaussian Simulation methods
gmSpatialModel-class

Conditional spatial model data container
gmTrainingImage-class

MPS training image class
plot.gmCgram

Draw cuves for covariance/variogram models
plot.accuracy

Plot method for accuracy curves
is.isotropic

Check for anisotropy of a theoretical variogram
gsi.gstatCokriging2compo

Reorganisation of cokriged compositions
precision

Precision calculations
gsi.orig

extract information about the original data, if available
length.gmCgram

Length, and number of columns or rows
predict.LMCAnisCompo

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

Constructs a mask for a grid
as.CompLinModCoReg

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

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

Validation strategy description
gmSimulationAlgorithm-class

Parameter specification for a spatial simulation algorithm
has.missings.data.frame

Check presence of missings check presence of missings in a data.frame
gsi.produceV

Create a matrix of logcontrasts and name prefix
gmUnconditionalSpatialModel-class

General description of a spatial model
gmNeighbourhoodSpecification-class

Neighbourhood description
gmMPSParameters-class

parameters for Multiple-Point Statistics methods
fit_lmc.logratioVariogramAnisotropy

Fit an LMC to an empirical variogram
dimnames.DataFrameStack

Return the dimnames of a DataFrameStack
logratioVariogram,acomp-method

Logratio variogram of a compositional data
gsi.CondTurningBands

Internal function, conditional turning bands realisations
gsi.Cokriging

Cokriging of all sorts, internal function
noSpatCorr.test

Test for lack of spatial correlation
pairsmap

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

Empirical logratio variogram calculation
gmApply

Apply Functions Over Array or DataFrameStack Margins
getTellus

Download the Tellus survey data set (NI)
plot.gmEVario

Plot empirical variograms
gmSpatialDataContainer-class

General description of a spatial data container
gmSpatialMethodParameters-class

Parameter specification for any spatial method
gsi.DS

Workhorse function for direct sampling
make.gmMultivariateGaussianSpatialModel

Construct a Gaussian gmSpatialModel for regionalized multivariate data
plot.logratioVariogramAnisotropy

Plot variogram lines of empirical directional logratio variograms
spatialGridRmult

Construct a regionalized multivariate data
spectralcolors

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

parameters for Spatial Gaussian methods of any kind
setCgram

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

Internal function, unconditional turning bands realisations
setGridOrder

Set or get the ordering of a grid
gsi.calcCgram

Compute covariance matrix oout of locations
stackDim

Get/set name/index of (non)stacking dimensions
mean.accuracy

Mean accuracy
[.DataFrameStack

Extract rows of a DataFrameStack
xvErrorMeasures

Cross-validation errror measures
image.logratioVariogramAnisotropy

Plot variogram maps for anisotropic logratio variograms
[.gmCgram

Subsetting of gmCgram variogram structures
predict.gmSpatialModel

Predict method for objects of class 'gmSpatialModel'
stackDim,Spatial-method

Get name/index of the stacking dimension of a Spatial object
predict.genDiag

Predict method for generalised diagonalisation objects
[[.gmCgram

Subsetting of gmCgram variogram structures
swarmPlot

Plot a swarm of calculated output through a DataFrameStack
[.logratioVariogramAnisotropy

Subsetting of logratioVariogram objects
sphTrans

Spherifying transform Compute a transformation that spherifies a certain data set
gsi.EVario2D

Empirical variogram or covariance function in 2D
image_cokriged

Plot an image of gridded data
variogramModelPlot.gstatVariogram

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

Image method for mask objects
is.anisotropySpecification

Check for any anisotropy class
variogramModelPlot.logratioVariogram

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

Number of directions of an empirical variogram
mean.spatialDecorrelationMeasure

Average measures of spatial decorrelation
setMask

Set a mask on an object
print.mask

Print method for mask objects
pwlrmap

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

Reorder data in a grid
validate

Validate a spatial model
variogramModelPlot

Quick plotting of empirical and theoretical variograms Quick and dirty plotting of empirical variograms/covariances with or without their 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
+.gmCgram

Combination of gmCgram variogram structures
spatialGridAcomp

Construct a regionalized composition / reorder compositional simulations
swath

Swath plots
spatialDecorrelation

Compute diagonalisation measures
logratioVariogram_gmSpatialModel

Variogram method for gmSpatialModel objects
write.GSLib

Write a regionalized data set in GSLIB format
unmask

Unmask a masked object