RFsim {CompRandFld} | R Documentation |
Simulation of spatial and spatio-temporal Gaussian, binary and max-stable random fields. The function returns one or more replications of a random field for a given covariance model and covariance parameters.
RFsim(coordx, coordy=NULL, coordt=NULL, corrmodel, distance="Eucl", grid=FALSE, model='Gaussian', numblock=NULL, param, replicates=1, threshold=NULL)
coordx |
A numeric (d x 2)-matrix (where
|
coordy |
A numeric vector giving 1-dimension of
spatial coordinates; |
coordt |
A numeric vector giving 1-dimension of
temporal coordinates. At the moment implemented only for the
Gaussian case. Optional argument, the default is |
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 |
model |
String; the type of random field and therefore the densities associated to the likelihood
objects. |
numblock |
Numeric; the observation size of the underlying random field. Only in case of max-stable random fields. |
param |
A list of parameter values required in the simulation procedure of random fields, see Examples. |
replicates |
Numeric; a positive integer denoting the number of independent and identically distributed (iid) replications of a spatial or spatial-temporal random field. Optional argument, the default value is 1 then a single realisation is considered. |
threshold |
Numeric; a value indicating a threshold for the
binary random field. Optional in the case that |
Note that this function is also interfaced to the R package RandomFields,
using fast routines therein developed for the simulation of random fields, see
for example
GaussRF
,
MaxStableRF
, ect.
Returns an object of class RFsim
.
An object of class RFsim
is a list containing
at most the following components:
coordx |
A d-dimensional vector of spatial coordinates; |
coordy |
A d-dimensional vector of spatial coordinates; |
coordt |
A t-dimensional vector of temporal coordinates; |
corrmodel |
The correlation model; see |
data |
The vector or matrix or array of data, see
|
distance |
The type of spatial distance; |
model |
The type of random field, see |
numcoord |
The number of spatial coordinates; |
numtime |
The number the temporal realisations of the random field; |
param |
The vector of parameters' estimates; |
randseed |
The seed used for the random simulation; |
replicates |
The number of the iid replicatations of the random field; |
spacetime |
|
threshold |
The threshold for deriving the binary random field. |
Simone Padoan, simone.padoan@unibocconi.it, http://faculty.unibocconi.it/simonepadoan; Moreno Bevilacqua, moreno.bevilacqua@uv.cl, https://sites.google.com/a/uv.cl/moreno-bevilacqua/home.
Padoan, S. A. and Bevilacqua, M. (2015). Analysis of Random Fields Using CompRandFld. Journal of Statistical Software, 63(9), 1–27.
Covmatrix
,
GaussRF
,
MaxStableRF
library(CompRandFld) library(RandomFields) library(mapproj) library(fields) ################################################################ ### ### Example 1. Simulation of a Gaussian random field. ### Gaussian random fields with Whittle-Matern correlation. ### One spatial replication. ### ### ############################################################### # Define the spatial-coordinates of the points: x <- runif(500, 0, 2) y <- runif(500, 0, 2) set.seed(261) # Simulation of a spatial Gaussian random field: data <- RFsim(x, y, corrmodel="matern", param=list(smooth=0.5, mean=0,sill=1,scale=0.2,nugget=0))$data ################################################################ ### ### Example 2. Simulation of a binary random field based on ### the latent Gaussian random field with exponential correlation. ### One spatial replication on a regular grid ### ### ############################################################### # Define the spatial-coordinates of the points: x <- seq(0, 1, 0.05) y <- seq(0, 1, 0.05) set.seed(251) # Simulation of a spatial binary random field: sim <- RFsim(x, y, corrmodel="exponential", grid=TRUE, model="BinaryGauss", threshold=0, param=list(nugget=0,mean=0,scale=.1,sill=1)) image(x,y,sim$data,col=terrain.colors(100)) ################################################################ ### ### Example 3. Simulation of a max-stable random ### extremal-t type with exponential correlation. ### One spatial replication on a regular grid ### ### ############################################################### set.seed(341) x <- seq(0, 1, 0.02) y <- seq(0, 1, 0.02) # Simulation of a spatial binary random field: sim <- RFsim(x, y, corrmodel="exponential", grid=TRUE, model="ExtT", numblock=500, param=list(nugget=0,mean=0,scale=.1, sill=1,df=5)) image.plot(x,y,log(sim$data)) ################################################################ ### ### Example 4. Simulation of a Gaussian random field. ### with double exponential correlation. ### One spatio-temporal replication. ### ### ############################################################### # Define the spatial-coordinates of the points: x <- seq(0, 1, 0.1) y <- seq(0, 1, 0.1) # Define the temporal-coordinates: times <- seq(1, 3, 1) # # Simulation of a spatial Gaussian random field: sim <- RFsim(x, y, times, corrmodel="exp_exp", grid=TRUE, param=list(nugget=0,mean=0,scale_s=0.3, scale_t=0.5,sill=1))$data # Spatial simulated data at first temporal instant sim[,,1] ################################################################ ### ### Example 5. Simulation of a Gaussian random field ### with exponential correlation on a portion of the earth surface ### One spatial replication. ### ### ############################################################### lon_region<-c(-40,40) lat_region<-c(-40,40) # lon<-seq(min(lon_region),max(lon_region),2) lat<-seq(min(lat_region),max(lat_region),2) # data<-RFsim(coordx=lon,coordy=lat,corrmodel="exponential", distance="Geod",grid=TRUE,param=list(nugget=0,mean=0 ,scale=8000,sill=1))$data image.plot(lon,lat,data,xlab="Longitude",ylab="Latitude") map(database="world",xlim=lon_region,ylim=lat_region,add=TRUE)