diff --git a/DESCRIPTION b/DESCRIPTION index 5fccc0ab3185dce2361eac6d0bb4cbce5caafd95..38685967d116b5b13f53d72da88ee114d0de3183 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: gmGeostats -Version: 0.10.9-9001 -Date: 2021-10-01 +Version: 0.11.0 +Date: 2021-10-17 Title: Geostatistics for Compositional Analysis Authors@R: c(person(given = "Raimon", family = "Tolosana-Delgado", @@ -32,8 +32,7 @@ Suggests: knitr, rmarkdown (>= 2.3), magrittr, - readxl, - RandomFields + readxl Imports: methods, gstat, diff --git a/NEWS.md b/NEWS.md index 446da0c0eb1559d9c38b2934fe394fe253fafcfe..7904e4879919af56afeb169f9e29dbad3ce91dd3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,12 @@ +# 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 * (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 diff --git a/vignettes/register_new_layer_datatype.Rmd b/vignettes/register_new_layer_datatype.Rmd index 9a0385124f530bb80ba106af4376a5b9a2e29d1e..619ba05799734580837b75c07e945d1d86514549 100644 --- a/vignettes/register_new_layer_datatype.Rmd +++ b/vignettes/register_new_layer_datatype.Rmd @@ -22,7 +22,6 @@ This vignette explains how to tweak "gmGeostasts" to declare new datatypes for d library(compositions) library(gstat) library(gmGeostats) -library(RandomFields) library(magrittr) ``` @@ -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. ```{r data_creation, fig.height=7, fig.width=7} -# simulate a random function +## model setup set.seed(333275) -model <- RMexp() -x <- seq(0, 10, 0.1) -z <- RFsimulate(model, x, x, n=1) -# extract components -X = coordinates(z) -Z = z@data -# select some of them -tk = sample(1:nrow(X), 1000) -Xdt = X[tk,] -Zdt = Z[tk,1] -Zdtc = circular(Zdt,varname = "theta", conversion = 1) +xdt = data.frame(x=0, y=0, z=0) # one point is necesary +vg = vgm(model="Exp", psill=1, nugget=0, range=1) # variogram model +gs = gstat(id="z", formula=z~1, locations = ~x+y , data=xdt, nmax=10, model=vg) +## sample point coordinates +x <- runif(2000, min = 0, max = 10) # values between 0 and 10 +Xdt = data.frame(x=x[1:1000], y=x[1001:2000]) +# simulate random function +Z = predict(gs, newdata=Xdt, nsim=1) +# select columns +Zdt = Z[,3] +# define and plot data +Zdtc = circular(Zdt, varname = "theta", conversion = 1) pairsmap(Zdtc, loc=Xdt) ``` @@ -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 ```{r} +x <- seq(from=0, to=10, by=0.1) xx = expand.grid(x,x) colnames(xx) = colnames(Xdt) ng = KrigingNeighbourhood(nmax = 20, omax=7, maxdist=1) @@ -153,7 +154,7 @@ image_cokriged(theta.prds.back, ivar="theta") ## 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. @@ -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. -**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.