Fast simulation of Gaussian and non Gaussian Random Fields.
Fast simulation of Gaussian and non Gaussian Random Fields.
Simulation of Gaussian and some non Gaussian spatial, spatio-temporal and spatial bivariate random fields using two approximate methods of simulation: circulant embeeding and turning band. (see Examples).
UTF-8
coordx: A numeric (dx2)-matrix or (dx3)-matrix Coordinates on a sphere for a fixed radius radius
are passed in lon/lat format expressed in decimal degrees.
coordy: A numeric vector giving 1-dimension of spatial coordinates; Optional argument, the default is NULL.
coordz: A numeric vector giving 1-dimension of spatial coordinates; Optional argument, the default is NULL.
coordt: A numeric vector giving 1-dimension of temporal coordinates. Optional argument, the default is NULL
then a spatial RF is expected.
coordx_dyn: A list of m numeric (dx2)-matrices containing dynamical (in time) spatial coordinates. Optional argument, the default is NULL
corrmodel: String; the name of a correlation model, for the description see the Section Details .
parallel: Logical; if TRUE then the TB method is parallelized
ncores: Numeric; number of cores involved in parallelization.
distance: String; the name of the spatial distance. The default is Eucl, the euclidean distance. See the Section Details of GeoFit.
GPU: Numeric; if NULL (the default) no GPU computation is performed.
grid: Logical; if FALSE (the default) the data are interpreted as spatial or spatial-temporal realisations on a set of non-equispaced spatial sites (irregular grid).
local: Numeric; number of local work-items of the GPU
max.ext: Numeric; The maximum extension of the simulation window (for the spatial CE method).
method: String; the type of approximation method. Default is TB that is the turning band method. The other possible choice is and CE (circular embeeding).
L: Numeric; the number of lines in the turning band method.
model: String; the type of RF and therefore the densities associated to the likelihood objects. Gaussian is the default, see the Section Details .
n: Numeric; the number of trials for binomial RFs. The number of successes in the negative Binomial RFs. Default is 1.
param: A list of parameter values required in the simulation procedure of RFs, see Examples .
anisopars: A list of two elements "angle" and "ratio" i.e. the anisotropy angle and the anisotropy ratio, respectively.
radius: Numeric; a value indicating the radius of the sphere when using the great circle distance. Default value is the radius of the earth in Km (i.e. 6371)
X: Numeric; Matrix of space-time covariates.
spobj: An object of class sp or spacetime
nrep: Numeric; Numbers of indipendent replicates.
progress: Logic; If TRUE then a progress bar is shown.
Returns
Returns an object of class GeoSim. An object of class GeoSim is a list containing at most the following components:
bivariate: Logical:TRUE if the Gaussian RF is bivariate, otherwise FALSE;
coordx: A d-dimensional vector of spatial coordinates;
coordy: A d-dimensional vector of spatial coordinates;
coordt: A t-dimensional vector of temporal coordinates;
coordx_dyn: A list of dynamical (in time) spatial coordinates;
corrmodel: The correlation model; see GeoCovmatrix.
data: The vector or matrix or array of data, see GeoFit;
distance: The type of spatial distance;
method: The method of simulation
model: The type of RF, see GeoFit.
n: The number of trial for Binomial RFs;the number of successes in a negative Binomial RFs;
numcoord: The number of spatial coordinates;
numtime: The number the temporal realisations of the RF;
param: The vector of parameters' estimates;
radius: The radius of the sphere if coordinates are passed in lon/lat format;
spacetime: TRUE if spatio-temporal and FALSE if spatial RF;
nrep: The number of indipendent replicates;
References
T. Gneiting, H. Sevcikova, D. B. Percival, M. Schlather and Y. Jiang (2006) Fast and Exact Simulation of Large Gaussian Lattice Systems in R2: Exploring the Limits Journal of Computational and Graphical Statistics 15 (3)
D. Arroyo, X. Emery (2020) An R Implementation of a Continuous Spectral Algorithm for Simulating Vector Gaussian Random Fields in Euclidean Spaces ACM Transactions on Mathematical Software 47(1)
library(GeoModels)###################################################################### Example 1. Simulation of a large spatial Gaussian RF ### with Matern covariance model### using circulant embeeding method### It works only for regular grid###############################################################set.seed(68)x = seq(0,1,0.005)y = seq(0,1,0.005)param=list(smooth=1.5,mean=0,sill=1,scale=0.2/3,nugget=0)# Simulation of a spatial Gaussian RF with Matern correlation functiondata1 <- GeoSimapprox(coordx=x,coordy=y, grid=TRUE,corrmodel="Matern", model="Gaussian", method="CE",param=param)$data
fields::image.plot( matrix(data1, length(x), length(y), byrow =TRUE))###################################################################### Example 2. Simulation of a large spatial Tukey-h RF ### with GenWend-Matern covariance model### using Turning band method### It works for (ir)regular grid###############################################################set.seed(68)x = runif(50000)y = runif(50000)coords=cbind(x,y)param=list(smooth=0.5,mean=0,sill=1,scale=0.04,nugget=0,tail=0.15,power2=1/4)# Simulation of a spatial Gaussian RF with Matern correlation functiondata1 <- GeoSimapprox(coords, corrmodel="GenWend_Matern", model="Tukeyh", method="TB",param=param)$data
quilt.plot(coords,data1)###################################################################### Example 3. Simulation of a large spacetime Gaussian RF ### with separable matern covariance model### using Circular embeeding method### It works for (large) regular time grid###############################################################set.seed(68)coordt <-(0:100)coords <- cbind( runif(100,0,1), runif(100,0,1))param <- list(mean =0, sill =1, nugget =0.25, scale_s =0.05, scale_t =2, smooth_s =0.5, smooth_t =0.5)# Simulation of a spatial Gaussian RF with Matern correlation functionparam<-list(nugget=0,mean=0,scale_s=0.2/3,scale_t=2/3,sill=1,smooth_s=0.5,smooth_t=0.5)data <- GeoSimapprox(coordx=coords, coordt=coordt, corrmodel="Matern_Matern", model="Gaussian",method="CE",param=param)$data
dim(data)###################################################################### Example 4. Simulation of a large spacetime Gaussian RF ### with separable GenWend covariance model### using Circular embeeding method in time###############################################################set.seed(68)# Simulation of a spatial Gaussian RF with Matern correlation functionparam<-list(nugget=0,mean=0,scale_s=0.2,scale_t=3,sill=1, smooth_s=0,smooth_t=0, power2_s=4,power2_t=4)data <- GeoSimapprox(coordx=coords, coordt=coordt, corrmodel="GenWend_GenWend", model="Gaussian",method="CE",param=param)$data
dim(data)###################################################################### Example 6. Simulation of a large bivariate Gaussian RF### with bivariate Matern correlation model################################################################### Define the spatial-coordinates of the points:#x <- runif(20000, 0, 2)#y <- runif(20000, 0, 2)#coords <- cbind(x,y)# Simulation of a bivariate spatial Gaussian RF:# with a Bivariate Matern#set.seed(12)#param=list(mean_1=4,mean_2=2,smooth_1=0.5,smooth_2=0.5,smooth_12=0.5,# scale_1=0.12,scale_2=0.1,scale_12=0.15,# sill_1=1,sill_2=1,nugget_1=0,nugget_2=0,pcol=0.5)#data <- GeoSimapprox(coordx=coords,corrmodel="Bi_matern",# param=param,method="TB",L=1000)$data#opar=par(no.readonly = TRUE)#par(mfrow=c(1,2))#quilt.plot(coords,data[1,],col=terrain.colors(100),main="1",xlab="",ylab="")#quilt.plot(coords,data[2,],col=terrain.colors(100),main="2",xlab="",ylab="")