Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • geomet/gmGeostats
1 result
Show changes
Commits on Source (2)
Package: gmGeostats
Version: 0.11.1
Date: 2022-05-03
Version: 0.11.3
Date: 2023-04-13
Title: Geostatistics for Compositional Analysis
Authors@R: c(person(given = "Raimon",
family = "Tolosana-Delgado",
......@@ -50,7 +50,7 @@ Description: Support for geostatistical analysis of multivariate data,
The methods mainly follow Tolosana-Delgado, Mueller and van den
Boogaart (2018) <doi:10.1007/s11004-018-9769-3>.
License: CC BY-SA 4.0 | GPL (>=2)
URL: https://gitlab.hzdr.de/geomet/gmGeostats
URL: https://codebase.helmholtz.cloud/geomet/gmGeostats
Copyright: (C) 2020 by Helmholtz-Zentrum Dresden-Rossendorf and Edith Cowan University;
gsi.DS code by Hassan Talebi
RoxygenNote: 7.1.1
......
......@@ -325,3 +325,4 @@ useDynLib(gmGeostats,CMVTurningBands)
useDynLib(gmGeostats,CcalcCgram)
useDynLib(gmGeostats,anaBackwardC)
useDynLib(gmGeostats,anaForwardC)
useDynLib(gmGeostats,getUnitvecR)
# gmGeostats 0.11.3
* (2023-04-04) C routines called as symbols and not name strings; non-ASCII characters removed
# gmGeostats 0.11.2
* (2022-11-22) flag '-lstdc++' removed from makevars.
* (2022-11-15) minor bugs in accuracy calculations corrected. References improved.
* (2022-08-15) bug in turning bands for spherical variogram corrected.
# gmGeostats 0.11.1
* (2022-05-03) minor changes to adapt to more stringent standards for class determination, for variable definition in C code, and for calls to FORTRAN routines from C code involving string arguments.
......
......@@ -145,7 +145,7 @@ anaForward <- function(x,Y,sigma0,sigma1=1+sigma0,steps=30,plt=FALSE,sphere=TRUE
#h=1/steps
#if( plt )
# plot(x[,1:2],pch=".")
erg<-.C("anaForwardC",
erg<-.C(anaForwardC,
dimX=checkInt(dim(x),2),
x=checkDouble(x),
dimY=checkInt(dim(Y),2),
......@@ -228,7 +228,7 @@ anaBackward <- function(x,Y,sigma0,sigma1=1+sigma0,steps=30,plt=FALSE,sphere=TRU
}
Y<-t(st(Y))
x <- t(x)
erg<-.C("anaBackwardC",
erg<-.C(anaBackwardC,
dimX=checkInt(dim(x),2),
x=checkDouble(x),
dimY=checkInt(dim(Y),2),
......
......@@ -5,7 +5,7 @@
#' Computes goodness-of-fit measures (accuracy, precision and joint goodness) adapted or extended from the
#' definition of Deutsch (1997).
#'
#' @param x data container for the predictions (plus cokriging error variances/covariance) or simulations (and eventually for the true values in univariate problems)
#' @param object data container for the predictions (plus cokriging error variances/covariance) or simulations (and eventually for the true values in univariate problems)
#' @param ... generic functionality, currently ignored
#'
#' @return If `outMahalanobis=TRUE` (the primary use), this function returns a two-column dataset of class
......@@ -13,18 +13,18 @@
#' the actual coverage of the intervals of each of these probabilities. If `outMahalanobis=FALSE`, the output
#' is a vector (for prediction) or matrix (for simulation) of Mahalanobis error norms.
#'
#' @details For method "kriging", `x` must contain columns with names including the string "pred" for predictions
#' @details For method "kriging", `object` must contain columns with names including the string "pred" for predictions
#' and "var" for the kriging variance; the observed values can also be included as an extra column with name "observed",
#' or else additionally provided in argument `observed`. For method "cokriging", the columns of `x` must contain
#' or else additionally provided in argument `observed`. For method "cokriging", the columns of `object` must contain
#' predictions, cokriging variances and cokriging covariances in columns including the strings "pred", "var" resp. "cov",
#' and observed values can only be provided via `observed` argument. Note that these are the natural formats when
#' using [gstat::predict.gstat()] and other (co)kriging functions of that package.
#'
#' For univariate and multivariate cokriging results (methods "kriging" and "cokriging"), the coverage values are computed based on the
#' Mahalanobis square error, the (square) distance between prediction and true value, using as the positive definite bilinear form
#' of the distance the variance-covariance cokriging matrix. The rationale is that, under the assumption
#' that the random field is Gaussian, the distribution of this Mahalanobis square error is known
#' to follow a \eqn{\chi^2(\nu)} with degrees of freedom \eqn{\nu} equal to the number of variables. Having this
#' of the distance the variance-covariance cokriging matrix. The rationale is that, under the assumption
#' that the random field is Gaussian, the distribution of this Mahalanobis square error should
#' follow a \eqn{\chi^2(\nu)} with degrees of freedom \eqn{\nu} equal to the number of variables. Having this
#' reference distribution allows us to compute confidence intervals for that Mahalanobis square error, and then
#' count how many of the actually observed errors are included on each one of the intervals (the *coverage*).
#' For a perfect adjustment to the distribution, the plot of coverage vs. nominal confidence (see [plot.accuracy])
......@@ -33,9 +33,9 @@
#' from the standard normal distribution appearing by normalizing the residual with the kriging variance; the result is the
#' same.
#'
#' For method "simulation" and object `x` is a data.frame, the variable names containing the realisations must
#' contain the string "sim", and `observed` must be a vector with as many elements as rows has `x`. If
#' `x` is a [DataFrameStack()], then it is assumed that the stacking dimension is running through the realisations;
#' For method "simulation" and object `object` is a data.frame, the variable names containing the realisations must
#' contain the string "sim", and `observed` must be a vector with as many elements as rows has `object`. If
#' `object` is a [DataFrameStack()], then it is assumed that the stacking dimension is running through the realisations;
#' the true values must still be given in `observed`.
#' In both cases, the method is based on ranks:
#' with them we can calculate which is the frequency of simulations being more extreme than the observed value.
......@@ -43,7 +43,7 @@
#' for each location separately.
#'
#' Method "mahalanobis" ("Mahalanobis" also works) is the analogous for multivariate simulations. It
#' only works for `x` of class [DataFrameStack()], and requires the stacking dimension to run through
#' only works for `object` of class [DataFrameStack()], and requires the stacking dimension to run through
#' the realisations and the other two dimensions to coincide with the dimensions of `observed`, i.e.
#' giving locations by rows and variables by columns. In this case, a covariance matrix will be computed
#' and this will be used to compute the Mahalanobis square error defined above in method "cokriging":
......@@ -59,7 +59,12 @@
#'
#' @export
#' @family accuracy functions
accuracy <- function(x,...) UseMethod("accuracy", x)
#' @references Mueller, Selia and Tolosana-Delgado (2023) Multivariate cross-validation
#' and measures of accuracy and precision.
#' Mathematical Geosciences (under review).
#'
#'
accuracy <- function(object,...) UseMethod("accuracy", object)
......@@ -68,19 +73,20 @@ accuracy <- function(x,...) UseMethod("accuracy", x)
#' @param observed either a vector- or matrix-like object of the true values
#' @param prob sequence of cutoff probabilities to use for the calculations
#' @param method which method was used for generating the predictions/simulations?
#' one of c("kriging", "cokriging", "simulation") for `x` of class "data.frame", or of
#' c("simulation", "mahalanobis", "flow") for `x` of class [DataFrameStack()].
#' one of c("kriging", "cokriging", "simulation") for `object` of class "data.frame", or of
#' c("simulation", "mahalanobis", "flow") for `object` of class [DataFrameStack()].
#' @param outMahalanobis if TRUE, do not do the final accuracy calculations and return the Mahalanobis
#' norms of the residuals; if FALSE do the accuracy calculations
#' @param ivar if `method`="kriging" or "cokriging" you can also specify here one single variable name
#' to consider for univariate accuracy; this variable name must exist both in `x`
#' to consider for univariate accuracy; this variable name must exist both in `object`
#' (including "pred" and "var" prefixes or suffixes in the column names) and in `observed`;
#' this might require renaming the columns of these files!
#' @export
accuracy.data.frame <- function(x, observed=x$observed,
accuracy.data.frame <- function(object, observed=object$observed,
prob = seq(from=0, to=1, by=0.05),
method="kriging", outMahalanobis=FALSE,
ivar, ...){
x = object # after v 0.11.9003, 'accuracy' first argument is renamed to 'object' for compatibility with tidymodels
methods = c("kriging", "cokriging", "simulation")
mm = methods[pmatch(method, methods)]
if(!missing(ivar)){
......@@ -88,7 +94,7 @@ accuracy.data.frame <- function(x, observed=x$observed,
iPred = intersect(grep(ivar, colnames(x)), grep("pred", colnames(x)))
iVar = intersect(grep(ivar, colnames(x)), grep("var", colnames(x)))
if(any(sapply(list(iTrue, iPred, iVar), length)!=1))
stop("accuracy: univariate case by specifying an `ivar` requires the named variable to occur ONCE in `observed` and once in `x`, here prefixed or suffixed with `pred` and `var` to identify kriging predictions and variances")
stop("accuracy: univariate case by specifying an `ivar` requires the named variable to occur ONCE in `observed` and once in `object`, here prefixed or suffixed with `pred` and `var` to identify kriging predictions and variances")
mm = "kriging"
observed = observed[,iTrue]
x = x[, c(iPred, iVar)]
......@@ -125,7 +131,7 @@ accuracy.data.frame <- function(x, observed=x$observed,
if(outMahalanobis)
return(mynorms)
# cases for kriging and cokriging
qqq = stats::qchisq(prob,df=D)
qqq = stats::qchisq(prob,df=D) # TODO: this could be Hotelling's T^2 distributed?
aa = outer(mynorms,qqq,"<=")
a = colMeans(aa)
erg = data.frame(p=prob, accuracy=a)
......@@ -139,19 +145,20 @@ accuracy.data.frame <- function(x, observed=x$observed,
#' @param ivars in multivariate cases, a vector of names of the variables to analyse (or one single variable name)
#' @method accuracy DataFrameStack
#' @export
accuracy.DataFrameStack <- function(x, observed,
ivars = intersect(colnames(observed), dimnames(x)[[noStackDim(x)]]),
accuracy.DataFrameStack <- function(object, observed,
ivars = intersect(colnames(observed), dimnames(object)[[noStackDim(object)]]),
prob = seq(from=0, to=1, by=0.05),
method = ifelse(length(ivars)==1, "simulation", "Mahalanobis"),
outMahalanobis=FALSE, ...){
x = object # after v 0.11.9003, 'accuracy' first argument is renamed to 'object' for compatibility with tidymodels
methods = c("simulation", "Mahalanobis","mahalanobis", "flow")
mm = methods[pmatch(method, methods)]
oneAcc.sim = function(sims, true){
rks = rank(c(true,sims))
rks = rank(c(true,as.matrix(sims)))
2*abs(rks[1]/(1+length(sims))-0.5)
}
oneAcc.assim = function(sims, true){
rks = rank(c(true,sims))
rks = rank(c(true,as.matrix(sims)))
rks[1]/(1+length(sims))
}
......@@ -160,7 +167,7 @@ accuracy.DataFrameStack <- function(x, observed,
warning("accuracy: outMahalanobis=TRUE not valid with method='simulation'")
if(nrow(x)!=length(observed))
if(nrow(x)!=nrow(observed))
stop("accuracy: dimensions of x and observed do not match")
stop("accuracy: dimensions of `object` and `observed` do not match")
sims = as.matrix(gmApply(x, FUN=function(xx)xx[,ivars, drop=FALSE]))
res = sapply(1:nrow(sims), function(i) oneAcc.sim(sims[i,], observed[i, ivars, drop=FALSE]))
aa = outer(res, prob, "<=")
......@@ -406,7 +413,7 @@ xvErrorMeasures.data.frame = function(x, observed=x$observed, output="MSDR1",
preds = sapply(unclass(xreord), cbind)
obs = as.matrix(observed)
resids = preds-obs
if(output=="ME") return(mean(resids, na.rm=TRUE))
if(output=="ME") return(colMeans(resids, na.rm=TRUE))
if(output=="MSE") return(mean(rowSums(resids^2, na.rm=T), na.rm=TRUE))
if(output=="MSDR2"){
myvar = function(j) covs[,j,j]
......
......@@ -36,7 +36,7 @@ logratioVariogram <- function(data, ...) UseMethod("logratioVariogram", data)
#' @param comp an alias for `data`, provided for back-compatibility with compositions::logratioVariogram
logratioVariogram.default <- function(data, loc, ..., comp=data){
res = try(compositions::logratioVariogram(comp=acomp(comp), loc=loc, ...), silent=TRUE)
if(class(res)!="try-error") return(res)
if(!inherits(res, what="try-error", which=FALSE)) return(res)
res = compositions::logratioVariogram(data=acomp(comp), loc=loc, ...)
}
......
......@@ -13,8 +13,8 @@
#' * The samples were complemented with information about their belonging to one of the
#' major crustal blocks (MCB) of Australia.
#' * Easting and Northing coordinates were computed using the Lambert conformal conic projection of
#' Australia (earth ellipsoid GRS80; standard parallels: 18°S and 36ºS latitude; central meridian:
#' 134ºE longitude).
#' Australia (earth ellipsoid GRS80; standard parallels: 18S and 36S latitude; central meridian:
#' 134E longitude).
#'
#'
#'#' @format A tibble, a data set of compound class c("tbl_df", "tbl", "data.frame") with 5259
......@@ -32,7 +32,7 @@
#' \item{REGION}{One of the three geo-regions of the data set: "EAST", "WEST" or "EUCLA"}
#' \item{DUPLICATE CODE}{Marker for duplicate samples, for quality control}
#' \item{SAMPLEID}{ID of the sample}
#' \item{GRAIN SIZE}{Particle size of the soil sample, one of "<2 mm" (coarse) or "<75 µm" (fine)}
#' \item{GRAIN SIZE}{Particle size of the soil sample, one of "<2 mm" (coarse) or "<75 um" (fine)}
#' \item{DEPTH}{Sampling depth, one of: "TOS" (top soil) or "BOS" (bottom soil)}
#' \item{CODE}{A combination of `Grain Size` and `DEPTH`, one of "Tc" "Tf" "Bc" "Bf", standing for TOS coarse, TOS fine, BOS coarse and BOS fine, respectively}
#' \item{`Ag ICP-MS mg/kg 0.03`}{concemtration of Silver in that sample, analysed with inductive coupled plasma mass spectrometry (ICP-MS), with a detection limit of 0.03ppm}
......
This diff is collapsed.
......@@ -131,7 +131,7 @@ Maf = function(x,...) UseMethod("Maf",x)
#' spatial imaging, Stanford University, Palo Alto, USA, 14pp.
#'
#' Tichavsky, P. and Yeredor, A., 2009. Fast approximate joint diagonalization
#' incorporating weight matrices. IEEE Transactions on Signal Processing 57, 878 891.
#' incorporating weight matrices. IEEE Transactions on Signal Processing 57, 878 ??? 891.
#'
#' @family generalised Diagonalisations
#'
......@@ -192,7 +192,7 @@ Maf.data.frame <- function(x, vg, i=2,...){
res = list(sdev=sdevs, loadings = W, center=mn, scale=rep(1, ncol(x)),
n.obs=nrow(x), scores = facscores, C1=C1, C2=C2, eigenvalues = eigenvalues[ord],
invLoadings=Winv)
if(class(x)!="data.frame"){
if(!is(x,"data.frame")){
res$Center = cdtInv(mn)
res$InvLoadings = cdtInv(Winv, orig=x)
res$InvDownLoadings = cdtInv(-Winv, orig=x)
......@@ -447,7 +447,7 @@ predict.genDiag = function (object, newdata=NULL, ...) {
requireNamespace("compositions", quietly=TRUE)
if(is.null(newdata))
newdata = object$scores
if("data.frame" %in% class(newdata))
if(is(newdata, "data.frame"))
newdata = as.matrix(newdata)
Z = newdata %*% unclass(object$invLoadings)
if("Center" %in% names(object)){
......@@ -478,9 +478,9 @@ predict.genDiag = function (object, newdata=NULL, ...) {
#' @importFrom compositions coloredBiplot
#' @method coloredBiplot genDiag
#'
#' @references Mueller, Tolosana-Delgado, Grunsky and McKinley (2021) Biplots for
#' Compositional Data Derived from Generalised Joint Diagonalization Methods.
#' Applied Computational Geosciences (under review)
#' @references Mueller, Tolosana-Delgado, Grunsky and McKinley (2020) Biplots for
#' compositional data derived from generalised joint diagonalization methods.
#' Applied Computational Geosciences 8:100044 \doi{10.1016/j.acags.2020.100044}
#'
#' @examples
#' data("jura", package="gstat")
......
......@@ -50,7 +50,7 @@ gsi.calcCgram <- function(X,Y,vgram,ijEqual=FALSE) {
nY<-nrow(Y)
k <- length(vgram$type)
dimC = c(d,nX,d,nY)
erg<- .C("CcalcCgram",
erg<- .C(CcalcCgram,
dimX=checkInt(dim(X),2),
ldX=checkInt(dim(X)[1],1),
X=checkDouble(X),
......@@ -70,8 +70,9 @@ gsi.calcCgram <- function(X,Y,vgram,ijEqual=FALSE) {
structure(erg$C,dim=c(d*nX,d*nY))
}
#' @useDynLib gmGeostats getUnitvecR
gsiGetUnitVec <- function(dimX,ip) {
erg = .C("getUnitvecR",dimX=checkInt(dimX,1),ip=checkInt(ip,1),unitvec=numeric(dimX))
erg = .C(getUnitvecR,dimX=checkInt(dimX,1),ip=checkInt(ip,1),unitvec=numeric(dimX))
unitvec = erg$unitvec
unitvec
}
......@@ -119,7 +120,7 @@ gsi.TurningBands <- function(X,vgram,nBands,nsim=NULL) {
}
# run!
if( is.null(nsim) ) {
erg<-.C("CMVTurningBands",
erg<-.C(CMVTurningBands,
dimX=checkInt(dim(X),2),
X=checkDouble(X,prod(dim(X))),
dimZ=checkInt(c(d,nrow(X),1),3),
......@@ -137,7 +138,7 @@ gsi.TurningBands <- function(X,vgram,nBands,nsim=NULL) {
} else {
nsim <- checkInt(nsim,1)
stopifnot(nsim>0)
erg<-.C("CMVTurningBands",
erg<-.C(CMVTurningBands,
dimX=checkInt(dim(X),2),
X=checkDouble(X,prod(dim(X))),
dimZ=checkInt(c(d,nrow(X),nsim),3),
......@@ -209,7 +210,7 @@ gsi.CondTurningBands <- function(Xout, Xin, Zin, vgram,
vgram$M = M
m = 3
}
erg <- .C("CCondSim",
erg <- .C(CCondSim,
dimZin=checkInt(dimZin,2),
Zin =checkDouble(Zin),
Cinv =checkDouble(Cinv,length(Zin)^2),
......
......@@ -81,7 +81,7 @@ validate <- function(object, strategy, ...) UseMethod("validate", strategy)
#' @method validate LeaveOneOut
#' @export
validate.LeaveOneOut = function(object, strategy, ...){
if("gstat" %in% class(object)){
if(inherits(object,what="gstat",which=FALSE)){
n = nrow(object$data[[1]]$data)
}else if(is(object, "gmSpatialModel")){
n = nrow(object@data)
......@@ -99,7 +99,7 @@ validate.LeaveOneOut = function(object, strategy, ...){
#' @export
validate.NfoldCrossValidation = function(object, strategy, ...){
# manage "gstat" case
if("gstat" %in% class(object)){
if(is(object,"gstat")){
warning("validate: object provided is of class 'gstat', attempting 'gstat.cv(..., remove.all=TRUE, all.residuals=TRUE)'")
return(gstat::gstat.cv(object, nfold=strategy$nfolds, remove.all = TRUE, all.residuals = TRUE))
}
......
......@@ -246,13 +246,13 @@ variogramModelPlot.gstatVariogram =
model = lapply(noms, function(i) gstat::vgm(model="Sph", psill=0, range=1, nugget=0))
names(model)=noms
}else{
if("variogramModelList" %in% class(model)){
if(is(model, "variogramModelList")){
vrnames = names(model)
vrnames = vrnames[-grep(".", vrnames, fixed=TRUE)]
}else if("gstat" %in% class(model)){
}else if(is(model, "gstat")){
vrnames = names(model$data)
model = model$model
}else if("variogramModel" %in% class(model) ){
}else if(is(model,"variogramModel") ){
vrnames = levels(model$id)[1]
}else{
ggtr = tryCatch(as.variogramModel(model))
......
......@@ -377,7 +377,7 @@ unmask <- function(x,...) UseMethod("unmask", x)
#' a "unmask.DataFrameStack" produces a "unmask.DataFrameStack";
#' a "SpatialPoints" produces a "SpatialPoints"; and finally
#' a "SpatialPixels" produces either a "SpatialPixels" or a "SpatialGrid" (if it is full).
#' Note that only in the case that `class(x)=="SpatialPixels"` is `mask` required,
#' Note that only in the case that `is(x,"SpatialPixels")=TRUE` is `mask` required,
#' for the other methods all arguments have reasonable defaults.
#' @export
unmask.data.frame <- function(x, mask=attr(x,"mask"), fullgrid = attr(mask, "fullgrid"),
......
......@@ -132,7 +132,7 @@ setCgram = function(type, nugget=sill*0, sill, anisRanges, extraPar=0){
#' vm = v1+v2
"+.gmCgram" <- function(x,y) {
y = as.gmCgram(y)
stopifnot(class(y)=="gmCgram",
stopifnot(is(y,"gmCgram"),
dim(x$sill)[-1]==dim(y$sill)[-1],
dim(x$M)[-1]==dim(y$M)[-1])
myfun = function(A,B){
......
......@@ -2,31 +2,54 @@
* Linux: Ubuntu 18.04.4LTS (local)
- R 3.6.3 (production)
- R devel 2022-04-23 r82240 (test)
- R 4.2.3 patched (2023-03-29 r84146) (test)
- R devel (2023-04-02 r84146) (test)
* Windows 7 Enterprise
- R version 4.2.2 (2022-10-31 ucrt) (test)
## R CMD check results
0 errors | 0 warnings | 0 notes
0 ERRORS
0 WARNINGS
1 NOTES (new resubmission after archiving)
## This is a resubmission
## This is a resubmission, after archiving on 2023-04-05
Request from 2023-03-19. All calls to .C() are now explicitly pointing
to symbols instead of function namestrings. Package "gmGeostats" could
not be uploaded before the archiving deadline because the main dependence
"compositions" was showing problems as well.
```
Dear maintainer,
Please see the problems shown on
<https://www.stats.ox.ac.uk/pub/bdr/BLAS/gmGeostats.out>
<https://cran.r-project.org/web/checks/check_results_gmGeostats.html>.
For reproduction details see
<https://www.stats.ox.ac.uk/pub/bdr/BLAS/README.txt> .
The "DLL requires the use of native symbols" errors in the
r-devel-linux-x86_64-debian-gcc check results are from
Please correct before 2022-05-05 to safely retain your package on CRAN.
r83985 | luke | 2023-03-16 02:31:57 +0100 (Thu, 16 Mar 2023) | 3 lines
Enforce R_forceSymbols for namespaces, but for now only if an
environment variable is set.
The CRAN Team
```
... related to the way classes were assessed (now using `inherits(...)`) and the calls of FORTRAN routines from C code that involve string arguments (now following the instructions given in <https://www.stats.ox.ac.uk/pub/bdr/BLAS/README.txt> ).
which makes R_forceSymbols work correctly, for now provided that env var
R_REALLY_FORCE_SYMBOLS is set.
You can conveniently extract the non-symbols in your package's foreign
function calls via tools:::package_native_routine_registration_db(),
e.g.,
R> tools:::package_native_routine_registration_db("/data/rsync/PKGS/tibble")
cname s n
1 .Call tibble_need_coerce 1
but please note that there may be several such calls in your code.
Please correct before 2023-04-02 to safely retain your package on CRAN.
best regards
\ No newline at end of file
Best,
-k
```
\ No newline at end of file
PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS)
PKG_LIBS = $(FLIBS) -lstdc++ $(SHLIB_OPENMP_CFLAGS)
PKG_LIBS = $(FLIBS) $(SHLIB_OPENMP_CFLAGS)
C_OBJS = gmGeostats.o
......
PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS)
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -lstdc++ $(SHLIB_OPENMP_CFLAGS)
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CFLAGS)
C_OBJS = gmGeostats.o
......
......@@ -218,8 +218,14 @@ const double *extra /* extra parameter (unused), for consistency with other cova
* where projs were calculated. Evaluate a wave of random phase at the
* projs points. Return that wave */
int i;
double phase,amp,omega,d1;
omega = norm_rand() * M_SQRT2 / range * M_SQRT_3; /* sqrt(3) needed to produce effective range*/
double phase,amp,omega,d1,o1,o2,o3;
/* omega = norm_rand() * M_SQRT2 / range * M_SQRT_3; /* sqrt(3) needed to produce effective range*/
// chi(3) distributed radial frequency, with random sign
o1 = norm_rand();
o2 = norm_rand();
o3 = norm_rand();
omega = sqrt(o1*o1 + o2*o2 + o3*o3) * sign(o1);
omega = omega * M_SQRT2 / range * M_SQRT_3; /* sqrt(3) needed to produce effective range*/
phase = unif_rand() * M_2PI;
amp = M_SQRT2; /* Lantuejoul (2002), page 191 */
for(i=0;i<n;i++) {
......
......@@ -236,13 +236,13 @@ theta.vg %>% recompute_complex_cov %>% plot
```
This is again a quick and dirty solution, as:
1. by using the plotting capacities of "gstat" for an incompplete object we waste half the space of the plot;
1. by using the plotting capacities of "gstat" for an incomplete object we waste half the space of the plot;
2. actually the current function can only deal with symmetric covariances (because of the way that gstat::variogram estimates the covariance), and
3. hence the imaginary part is identically zero.
### Non-symmetric covariance
Hence, we need to improve the computations slightly. First we need to consider estimates for the whole 360$^o$, so that we can obtain $C_{VU}(h)=C_{UV}(-h)$,
We need to improve the computations slightly. First we need to consider estimates for the whole 360$^o$, so that we can obtain $C_{VU}(h)=C_{UV}(-h)$,
```{r}
# compute variogram for the whole circle, i.e. until 360 deg
theta.cvg = gmGeostats::variogram(
......@@ -342,10 +342,10 @@ Boogaart, K. G. v. d.; Tolosana-Delgado, R. (2013) _Analysing compositional data
Boogaart, K.G. v.d.; Tolosana-Delgado, Raimon; Bren, Matevz (2021). compositions: Compositional Data Analysis. R package version 2.0-2. http://www.stat.boogaart.de/compositions/
De Iaco, S.; Posa, D.; Palma, M. (2013) Complex-Valued Random Fields for Vectorial Data: Estimating and Modeling Aspects. _Mathematical Geosciences_ 45: 557573
De Iaco, S.; Posa, D.; Palma, M. (2013) Complex-Valued Random Fields for Vectorial Data: Estimating and Modeling Aspects. _Mathematical Geosciences_ 45: 557???573
Stevens, S. (1946) On the theory of scales of measurement. _Science_ 103: 677-680
Wackernagel, H. (2003) _Multivariate geostatisticsan introduction with applications_, 3rd edn. Springer, Berlin
Wackernagel, H. (2003) _Multivariate geostatistics???an introduction with applications_, 3rd edn. Springer, Berlin