Skip to content
Snippets Groups Projects
Commit 89fdbed7 authored by Raimon Tolosana-Delgado's avatar Raimon Tolosana-Delgado
Browse files

gmGeostats v. 0.11.0: consolidation of "predict" methods; dependence of "randomFields" removed

parent 9d1edc94
No related branches found
No related tags found
No related merge requests found
Package: gmGeostats Package: gmGeostats
Version: 0.10.9-9001 Version: 0.11.0
Date: 2021-10-01 Date: 2021-10-17
Title: Geostatistics for Compositional Analysis Title: Geostatistics for Compositional Analysis
Authors@R: c(person(given = "Raimon", Authors@R: c(person(given = "Raimon",
family = "Tolosana-Delgado", family = "Tolosana-Delgado",
...@@ -32,8 +32,7 @@ Suggests: ...@@ -32,8 +32,7 @@ Suggests:
knitr, knitr,
rmarkdown (>= 2.3), rmarkdown (>= 2.3),
magrittr, magrittr,
readxl, readxl
RandomFields
Imports: Imports:
methods, methods,
gstat, gstat,
......
# gmGeostats 0.11.0
* (2021-10-17) dependence from randomFields eliminated
* (2021-10-17) consolidated management of `predict()` methods for S3 and S4 objects, with the help of the internal function `Predict()` (not recommended to use)
# gmGeostats 0.10.9-9001 # gmGeostats 0.10.9-9001
* (2021-09-30) minor bug corrected on the way fit_lmc passes its arguments to surrogate gstat and gmGeostats functions * (2021-09-30) minor bug corrected on the way fit_lmc passes its arguments to surrogate gstat and gmGeostats functions
* (2021-10-01) management of `predict()` methods for S3 and S4 objects, wth the help of the internal function `Predict()` (not recommended to use) * (2021-10-01) management of `predict()` methods for S3 and S4 objects, with the help of the internal function `Predict()` (not recommended to use)
# gmGeostats 0.10.9 # gmGeostats 0.10.9
......
...@@ -22,7 +22,6 @@ This vignette explains how to tweak "gmGeostasts" to declare new datatypes for d ...@@ -22,7 +22,6 @@ This vignette explains how to tweak "gmGeostasts" to declare new datatypes for d
library(compositions) library(compositions)
library(gstat) library(gstat)
library(gmGeostats) library(gmGeostats)
library(RandomFields)
library(magrittr) library(magrittr)
``` ```
...@@ -85,19 +84,20 @@ cdtInv.circular = function(z, orig=compositions:::gsi.orig(x),...){ ...@@ -85,19 +84,20 @@ cdtInv.circular = function(z, orig=compositions:::gsi.orig(x),...){
With these few lines of programming you could already be able to use "gmGeostats" for your data. To show how, we will generate first a univariate, real-valued random field, take it as if it were circular data (in radians), extract some components out of it, and do a geostatistical analysis with the output. With these few lines of programming you could already be able to use "gmGeostats" for your data. To show how, we will generate first a univariate, real-valued random field, take it as if it were circular data (in radians), extract some components out of it, and do a geostatistical analysis with the output.
```{r data_creation, fig.height=7, fig.width=7} ```{r data_creation, fig.height=7, fig.width=7}
# simulate a random function ## model setup
set.seed(333275) set.seed(333275)
model <- RMexp() xdt = data.frame(x=0, y=0, z=0) # one point is necesary
x <- seq(0, 10, 0.1) vg = vgm(model="Exp", psill=1, nugget=0, range=1) # variogram model
z <- RFsimulate(model, x, x, n=1) gs = gstat(id="z", formula=z~1, locations = ~x+y , data=xdt, nmax=10, model=vg)
# extract components ## sample point coordinates
X = coordinates(z) x <- runif(2000, min = 0, max = 10) # values between 0 and 10
Z = z@data Xdt = data.frame(x=x[1:1000], y=x[1001:2000])
# select some of them # simulate random function
tk = sample(1:nrow(X), 1000) Z = predict(gs, newdata=Xdt, nsim=1)
Xdt = X[tk,] # select columns
Zdt = Z[tk,1] Zdt = Z[,3]
Zdtc = circular(Zdt,varname = "theta", conversion = 1) # define and plot data
Zdtc = circular(Zdt, varname = "theta", conversion = 1)
pairsmap(Zdtc, loc=Xdt) pairsmap(Zdtc, loc=Xdt)
``` ```
...@@ -131,6 +131,7 @@ theta.gg = ...@@ -131,6 +131,7 @@ theta.gg =
``` ```
The outcome can then be used for validation, prediction or simulation. Here we do cokriging on the same grid we simulated above The outcome can then be used for validation, prediction or simulation. Here we do cokriging on the same grid we simulated above
```{r} ```{r}
x <- seq(from=0, to=10, by=0.1)
xx = expand.grid(x,x) xx = expand.grid(x,x)
colnames(xx) = colnames(Xdt) colnames(xx) = colnames(Xdt)
ng = KrigingNeighbourhood(nmax = 20, omax=7, maxdist=1) ng = KrigingNeighbourhood(nmax = 20, omax=7, maxdist=1)
...@@ -153,7 +154,7 @@ image_cokriged(theta.prds.back, ivar="theta") ...@@ -153,7 +154,7 @@ image_cokriged(theta.prds.back, ivar="theta")
## An excursion on superclasses ## An excursion on superclasses
"gmGeostats" uses a mixture of S3 and S4 classes to manage the several kinds of objects, S3 classes mostly preferred for simple configuration objects, models and data elements, and S4 classes mostly in use for large compound spatial models and data containers. S4 classes, though being somewhat more complex to handle and slightly slower, have the advantage to allow for multiple dispatch, which this package extensively uses. S4 classes require its fields (called "slots") to strictly belong to a specific class. To handle this condition, and at the same time allow for multiple methods of specification, estimation, fitting and prediction of spatial models and random functions, "gmGeostats" provides a series of abstract classes controlling allowing certain fields to contain certain kinds of objects: "gmGeostats" uses a mixture of S3 and S4 classes to manage the several kinds of objects, S3 classes mostly preferred for simple configuration objects, models and data elements, and S4 classes mostly in use for large compound spatial models and data containers. S4 classes, though being somewhat more complex to handle and slightly slower, have the advantage to allow for multiple dispatch, which this package extensively uses. S4 classes require its fields (called "slots") to strictly belong to a specific class. To handle this condition, and at the same time allow for multiple methods of specification, estimation, fitting and prediction of spatial models and random functions, "gmGeostats" provides a series of abstract classes allowing to control that certain fields do contain only certain kinds of objects:
**gmNeighbourhoodSpecification** contains a description of the neighbourhood of a point during interpolation/simulation. **gmNeighbourhoodSpecification** contains a description of the neighbourhood of a point during interpolation/simulation.
...@@ -167,7 +168,7 @@ image_cokriged(theta.prds.back, ivar="theta") ...@@ -167,7 +168,7 @@ image_cokriged(theta.prds.back, ivar="theta")
**gmTrainingImage** for multipoint statistics (MPS) methods, this abstract class gathers all ways to specify a gridded image. **gmTrainingImage** for multipoint statistics (MPS) methods, this abstract class gathers all ways to specify a gridded image.
**gmUnconditionalSpatialModel** convenience class of the union of "gmTrainingImage" and "gmGaussianModel" (a concrete class containing "ModelStructuralFunctionSpecification" with some extra information), it is thought to contain all specifications of an unconditional random function. **gmUnconditionalSpatialModel** convenience class of the union of "gmTrainingImage" and "gmGaussianModel" (a concrete class containing "ModelStructuralFunctionSpecification" with some extra information), it is thought to contain all future specifications of an unconditional random function, beyond the two members currently contained.
**gmMPSParameters**, analogous to "gmGaussianSimulationAlgorithm" or "gmValidationStrategy", this abstract class contains all specifications of MPS algorithms available. **gmMPSParameters**, analogous to "gmGaussianSimulationAlgorithm" or "gmValidationStrategy", this abstract class contains all specifications of MPS algorithms available.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment