| GeoSim | R Documentation | 
Simulation of Gaussian and some non Gaussian spatial, spatio-temporal and spatial bivariate random fields. The function return a realization of a random Field for a given covariance model and covariance parameters.Simulation is based on Cholesky decomposition.
GeoSim(coordx, coordy=NULL,coordz=NULL, coordt=NULL, coordx_dyn=NULL, corrmodel, 
      distance="Eucl", grid=FALSE, method="cholesky", 
      model='Gaussian', n=1, param,anisopars=NULL,radius=1, 
      sparse=FALSE,X=NULL,spobj=NULL,nrep=1,progress=TRUE)
| coordx | A numeric ( | 
| coordy | A numeric vector giving 1-dimension of
spatial coordinates; Optional argument, the default is  | 
| coordz | A numeric vector giving 1-dimension of
spatial coordinates;  Optional argument, the default is  | 
| coordt | A numeric vector giving 1-dimension of
temporal coordinates.  Optional argument, the default is  | 
| coordx_dyn | A list of  | 
| corrmodel | String; the name of a correlation model, for the description see the Section Details. | 
| distance | String; the name of the spatial distance. The default
is  | 
| grid | Logical; if  | 
| method | String; the type of matrix decomposition used in the simulation. 
Default is cholesky. The other possible choices is  | 
| model | String; the type of RF and therefore the densities associated to the likelihood
objects.  | 
| n | Numeric; the number of trials for binomial RFs. 
The number of successes in the negative Binomial RFs. Default is  | 
| 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 1. | 
| sparse | Logical; if  | 
| 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 an object of class GeoSim.
An object of class GeoSim is a list containing
at most the following components:
| bivariate | Logical: | 
| coordx | A  | 
| coordy | A  | 
| coordz | A  | 
| coordt | A  | 
| coordx_dyn | A list of dynamical (in time) spatial coordinates; | 
| corrmodel | The correlation model; see  | 
| data | The vector or matrix or array of data, see
 | 
| distance | The type of spatial distance; | 
| method | The method of simulation | 
| model | The type of RF, see  | 
| 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 | 
 | 
| nrep | The number of indipendent replicates; | 
Moreno Bevilacqua, moreno.bevilacqua89@gmail.com,https://sites.google.com/view/moreno-bevilacqua/home, Víctor Morales Oñate, victor.morales@uv.cl, https://sites.google.com/site/moralesonatevictor/, Christian", Caamaño-Carrillo, chcaaman@ubiobio.cl,https://www.researchgate.net/profile/Christian-Caamano
library(GeoModels)
library(mapproj)
################################################################
###
### Example 1. Simulation of a spatial Gaussian RF 
### with Matern and Generalized Wendland correlations
###############################################################
# Define the spatial-coordinates of the points:
x <- runif(500);y <- runif(500)
coords=cbind(x,y)
set.seed(261)
# Simulation of a spatial Gaussian RF with Matern correlation function
data1 <- GeoSim(coordx=coords, corrmodel="Matern", param=list(smooth=0.5,
             mean=0,sill=1,scale=0.4/3,nugget=0))$data
set.seed(261)
data2 <- GeoSim(coordx=coords,  corrmodel="GenWend", param=list(smooth=0,
              power2=4,mean=0,sill=1,scale=0.4,nugget=0))$data
opar=par(no.readonly = TRUE)
par(mfrow=c(1,2))
quilt.plot(coords,data1,main="Matern",xlab="",ylab="")
quilt.plot(coords,data2,main="Wendland",xlab="",ylab="")   
par(opar)
             
################################################################
###
### Example 2. Simulation of a spatial geometric RF 
### with  underlying Wend0 correlation
###
################################################################
# Define the spatial-coordinates of the points:
x <- runif(800);y <- runif(800)
coords <- cbind(x,y)
set.seed(251)
# Simulation of a spatial Binomial RF:
sim <- GeoSim(coordx=coords, corrmodel="Wend0",
             model="BinomialNeg",n=1,sparse=TRUE,
             param=list(nugget=0,mean=0,scale=.2,power2=4))
quilt.plot(coords,sim$data,nlevel=max(sim$data),col=terrain.colors(max(sim$data+1))) 
################################################################
###
### Example 3. Simulation of a spatial Weibull  RF
### with  underlying Matern correlation on a regular grid
###
###############################################################
# Define the spatial-coordinates of the points:
x <- seq(0,1,0.032)
y <- seq(0,1,0.032)
set.seed(261)
# Simulation of a spatial Gaussian RF with Matern correlation function
data1 <- GeoSim(x,y,grid=TRUE, corrmodel="Matern",model="Weibull", 
         param=list(shape=1.2,mean=0,scale=0.3/3,nugget=0,smooth=0.5))$data
image.plot(x,y,data1,main="Weibull RF",xlab="",ylab="")
################################################################
###
### Example 4. Simulation of a spatial t  RF
### with  with  underlying Generalized Wendland correlation 
###
###############################################################
# Define the spatial-coordinates of the points:
x <- seq(0,1,0.03)
y <- seq(0,1,0.03)
set.seed(268)
# Simulation of a spatial Gaussian RF with Matern correlation function
data1 <- GeoSim(x,y,grid=TRUE, corrmodel="GenWend",model="StudentT", sparse=TRUE,
         param=list(df=1/4,mean=0,sill=1,scale=0.3,nugget=0,smooth=1,power2=5))$data
image.plot(x,y,data1,col=terrain.colors(100),main="Student-t RF",xlab="",ylab="")
################################################################
###
### Example 5. Simulation of a sinhasinh RF
###   with  underlying Wend0 correlation.
###
###############################################################
# Define the spatial-coordinates of the points:
x <- runif(500, 0, 2)
y <- runif(500, 0, 2)
coords <- cbind(x,y)
set.seed(261)
corrmodel="Wend0"
# Simulation of a spatial Gaussian RF:
param=list(power2=4,skew=0,tail=1,
             mean=0,sill=1,scale=0.2,nugget=0)  ## gaussian case
data0 <- GeoSim(coordx=coords, corrmodel=corrmodel,
               model="SinhAsinh", param=param,sparse=TRUE)$data
plot(density(data0),xlim=c(-7,7))
param=list(power2=4,skew=0,tail=0.7,
             mean=0,sill=1,scale=0.2,nugget=0) ## heavy tails
data1 <- GeoSim(coordx=coords, corrmodel=corrmodel,
               model="SinhAsinh", param=param,sparse=TRUE)$data
lines(density(data1),lty=2)
param=list(power2=4,skew=0.5,tail=1,
             mean=0,sill=1,scale=0.2,nugget=0)  ## asymmetry
data2 <- GeoSim(coordx=coords, corrmodel=corrmodel,
               model="SinhAsinh", param=param,sparse=TRUE)$data
lines(density(data2),lty=3)
################################################################
###
### Example 6. Simulation of a bivariate Gaussian RF
### with  bivariate Matern correlation model
###
###############################################################
# Define the spatial-coordinates of the points:
x <- runif(500, 0, 2)
y <- runif(500, 0, 2)
coords <- cbind(x,y)
# Simulation of a bivariate spatial Gaussian RF:
# with a separable Bivariate Matern
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 <- GeoSim(coordx=coords,corrmodel="Bi_matern",
              param=param)$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="")
par(opar)
################################################################
###
### Example 7. Simulation of a  spatio temporal Gaussian RF.
### observed on  fixed  location sites with double Matern correlation 
###
###############################################################
coordt=1:5
# Define the spatial-coordinates of the points:
x <- runif(50, 0, 2)
y <- runif(50, 0, 2)
coords <- cbind(x,y)
param<-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 <- GeoSim(coordx=coords, coordt=coordt, corrmodel="Matern_Matern",
                     param=param)$data
dim(data)
################################################################
###
### Example 8. Simulation of a  spatio temporal Gaussian RF.
### observed on  dynamical location sites with double Matern correlation 
###
###############################################################
# Define the dynamical spatial-coordinates of the points:
coordt=1:5
coordx_dyn=list()
maxN=30
set.seed(8)
for(k in 1:length(coordt))
{
NN=sample(1:maxN,size=1)
x <- runif(NN, 0, 1)
y <- runif(NN, 0, 1)
coordx_dyn[[k]]=cbind(x,y)
}
coordx_dyn
param<-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 <- GeoSim(coordx_dyn=coordx_dyn, coordt=coordt, corrmodel="Matern_Matern",
                     param=param)$data
## spatial realization at first temporal instants
data[[1]]
## spatial realization at third temporal instants
data[[3]]
################################################################
###
### Example 9. Simulation of a Gaussian RF 
###  with a Wend0 correlation in the north emisphere of the planet earth
### using geodesic distance
###############################################################
distance="Geod";radius=6371
NN=3000 ## total point on the sphere on lon/lat format
set.seed(80)
coords=cbind(runif(NN,-180,180),runif(NN,0,90))
## Set the wendland parameters
corrmodel <- "Wend0"
param<-list(mean=0,sill=1,nugget=0,scale=1000,power2=3)
# Simulation of a spatial Gaussian RF on the sphere
#set.seed(2)
data <- GeoSim(coordx=coords,corrmodel=corrmodel,sparse=TRUE,
               distance=distance,radius=radius,param=param)$data
#require(globe)
#globe::globeearth(eye=place("newyorkcity"))
#globe::globepoints(loc=coords,pch=20,col =  cm.colors(length(data),alpha=0.4)[rank(data)])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.