RFsim: Simulation of Gaussian, Binary and Max-stable Random Fields

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/Simulation.r

Description

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.

Usage

1
2
3
RFsim(coordx, coordy=NULL, coordt=NULL, corrmodel, distance="Eucl",
      grid=FALSE, model='Gaussian', numblock=NULL, param,
      replicates=1, threshold=NULL)

Arguments

coordx

A numeric (d x 2)-matrix (where d is the number of spatial sites) giving 2-dimensions of spatial coordinates or a numeric d-dimensional vector giving 1-dimension of spatial coordinates.

coordy

A numeric vector giving 1-dimension of spatial coordinates; coordy is interpreted only if coordx is a numeric vector or grid=TRUE otherwise it will be ignored. Optional argument, the default is NULL then coordx is expected to be numeric a (d x 2)-matrix.

coordt

A numeric vector giving 1-dimension of temporal coordinates. At the moment implemented only for the Gaussian case. Optional argument, the default is NULL then a spatial random field is expected.

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 Eucl, the euclidean distance. See the Section Details of FitComposite.

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).

model

String; the type of random field and therefore the densities associated to the likelihood objects. Gaussian is the default, see the Section Details.

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 model is BinaryGauss, see the Section Details.

Details

Note that this function is also interfaced to the R package RandomFields, using fast routines therein developed for the simulation of random fields.

Value

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 Covmatrix.

data

The vector or matrix or array of data, see FitComposite;

distance

The type of spatial distance;

model

The type of random field, see FitComposite.

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

TRUE if spatio-temporal and FALSE if spatial random field;

threshold

The threshold for deriving the binary random field.

Author(s)

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.

References

Padoan, S. A. and Bevilacqua, M. (2015). Analysis of Random Fields Using CompRandFld. Journal of Statistical Software, 63(9), 1–27.

See Also

Covmatrix

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
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)

Example output

Loading required package: sp
Loading required package: RandomFieldsUtils

Attaching package: 'RandomFields'

The following object is masked from 'package:RandomFieldsUtils':

    RFoptions

Loading required package: maps
Loading required package: spam
Loading required package: dotCall64
Loading required package: grid
Spam version 2.2-2 (2019-03-07) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction 
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.

Attaching package: 'spam'

The following objects are masked from 'package:base':

    backsolve, forwardsolve

See https://github.com/NCAR/Fields for
 an extensive vignette, other supplements and source code 
Warning messages:
1: In RandomFields::RFparameters(Storing = TRUE, PrintLevel = 1) :
  The function is obsolete. Use 'RFoptions' instead.
2: In RandomFields::GaussRF(x = initparam$coordx, y = initparam$coordy,  :
  The function is obsolete. Use 'RFsimulate' instead.
            [,1]        [,2]        [,3]        [,4]         [,5]       [,6]
 [1,]  0.9223940  0.30095477  0.40964995  0.91663621  1.931617440  1.6026049
 [2,]  1.6409078  0.32642028  0.21445962  0.45864417  0.377860017  1.4668482
 [3,]  0.7314876  1.10723890  0.07978236  0.61014840 -0.047291793  0.3963501
 [4,]  0.3836722  0.36581006 -0.67844116 -0.18028133 -0.002249197  0.1451865
 [5,] -0.3351690  0.08378569 -0.48840527 -0.15560243  0.968769420  1.6257795
 [6,]  0.1148653  0.32548079 -0.93110371 -0.09962689  0.221159168  0.4808245
 [7,] -0.7273573 -0.71882001 -0.41903596 -0.59467175 -0.600302312 -0.3679111
 [8,] -0.7700930 -0.38159334 -0.50123552 -0.51089887 -0.597197773 -1.1799146
 [9,]  0.0461754  0.21379873  0.71973787 -0.48487066  0.020964399 -0.3270232
[10,] -0.1692514  0.73675199  0.58485622  1.34802440 -0.147042067 -0.2146536
[11,]  2.4904466  2.52227083  1.61567154  0.63179305 -0.015514392  0.8259750
             [,7]       [,8]       [,9]      [,10]     [,11]
 [1,]  1.06404919  1.2124254 0.79459407 1.04054027 0.7369360
 [2,]  0.99207459  1.7757777 1.37140622 1.09491858 0.3740511
 [3,]  0.49380403  0.8407949 0.86398104 0.23143718 0.6993849
 [4,]  0.07859698  1.4913128 1.45786054 0.16451392 1.2432092
 [5,]  1.54919931  1.6371512 2.20387253 0.94538811 0.9217018
 [6,]  1.68774621 -0.3773446 0.77509517 0.16526951 0.4287533
 [7,]  0.29058317  0.5292003 0.09571764 0.01003232 0.7359176
 [8,] -0.67686294  0.5683545 1.04658343 1.32212524 1.5057638
 [9,] -0.05764332  0.7829094 1.55854845 1.97213767 1.7852469
[10,] -0.01513049  0.2478771 0.84146570 1.26912980 0.6758533
[11,]  0.28541850  0.6895920 1.53725236 0.56494878 1.4580636

CompRandFld documentation built on Jan. 10, 2020, 9:08 a.m.