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 function
data1 <- 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 function
data1 <- 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 function
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 <- 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 function
param<-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="")
Run the code above in your browser using DataLab