Title: | Simulation and Analysis of Random Fields |
---|---|
Description: | Methods for the inference on and the simulation of Gaussian fields are provided. Furthermore, methods for the simulation of extreme value random fields are provided. Main geostatistical parts are based among others on the books by Christian Lantuejoul <doi:10.1007/978-3-662-04808-5>. |
Authors: | Martin Schlather [aut, cre], Alexander Malinowski [aut], Marco Oesting [aut], Daphne Boecker [aut], Kirstin Strokorb [aut], Sebastian Engelke [aut], Johannes Martini [aut], Felix Ballani [aut], Olga Moreva [aut], Jonas Auel[ctr], Peter Menck [ctr], Sebastian Gross [ctr], Ulrike Ober [ctb], Paulo Ribeiro [ctb], Brian D. Ripley [ctb], Richard Singleton [ctb], Ben Pfaff [ctb], R Core Team [ctb] |
Maintainer: | Martin Schlather <[email protected]> |
License: | GPL (>= 3) |
Version: | 3.3.14 |
Built: | 2024-09-06 05:53:20 UTC |
Source: | https://github.com/cran/RandomFields |
The package RandomFields
offers various tools for
model estimation (ML) and inference (tests) for regionalized variables and data analysis,
simulation of different kinds of random fields, including
multivariate, spatial, spatio-temporal, and non-stationary Gaussian random fields,
Poisson fields, binary fields, Chi2 fields, t fields and
max-stable fields.
It can also deal with non-stationarity and anisotropy of these processes and conditional simulation (for Gaussian random fields, currently).
See https://www.wim.uni-mannheim.de/schlather/publications/software for intermediate updates.
The following features are provided by the package:
Bayesian Modelling
See Bayesian Modelling for an introduction to hierarchical modelling.
Coordinate systems
Cartesian, earth and spherical coordinates are recognized, see coordinate systems for details.
A list of valid models is given by spherical models.
Data and example studies: Some data sets and published code are provided to illustrate the syntax and structure of the package functions.
Estimation of parameters (for second-order random fields)
RFfit
: general function for estimating
parameters; (for Gaussian random fields)
RFhurst
: estimation of the Hurst parameter
RFfractaldim
: estimation of the fractal
dimension
RFvariogram
: calculates
the empirical variogram
RFcov
: calculates
the empirical (auto-)covariance function
Graphics
Inference (for Gaussian random fields)
RFcrossvalidate
: cross validation
RFlikelihood
: likelihood
RFratiotest
: likelihood ratio test
Models
For an introduction and general properties, see RMmodels.
For an overview over classes of covariance and variogram models –e.g. for geostatistical purposes– see RM. More sophisticated models and covariance function operators are included.
RFformula
reports a new style of passing a
model since version 3.3.
definite models are evaluated by RFcov
,
RFvariogram
and RFcovmatrix
.
For a quick impression use plot(model)
.
RFlinearpart
returns the linear part of a
model
RFboxcox
deals explicitly with Box-Cox
transformations. In many cases it is performed implicitly.
Prediction (for second-order random fields)
RFinterpolate
: kriging, including imputing
Simulation
RFsimulate
: Simulation
of random fields,
including conditional simulation. For a list of all covariance
functions and variogram models see RM
.
Use plot
for visualisation of the result.
S3 and S4 objects
The functions return S4 objects
based on the package sp,
if spConform=TRUE
.
This is the default.
If spConform=FALSE
,
simple objects as in version 2 are returned.
These simple objects are frequently provided with an S3 class.
This option makes the returning procedure much faster, but
currently does not allow for the comfortable use of
plot
.
plot
,
print
, summary
,
sometimes also str
recognise these S3 and S4
objects
use sp2RF
for an explicit transformation
of sp objects to S4 objects of RandomFields.
Further generic functions are available for fitted models, see ‘Inference’ above.
Xtended features, especially for package programmers
might decide on a large variety of arguments of the
simulation and estimation procedures using the function
RFoptions
may use ‘./configure –with-tcl-config=/usr/lib/tcl8.5/tclConfig.sh –with-tk-config=/usr/lib/tk8.5/tkConfig.sh’ to configure R
A list of major changings from Version 2 to Version 3 can be found in MajorRevisions.
Changings lists some further changings, in particular of argument and argument names.
RandomFields should be rather
stable when running it with parallel.
However RandomFields might crash severely if an error occurs
when running in parallel. When used with parallel,
you might set RFoptions(cores = 1)
. Note that
RFoptions(cores = ...)
with more than 1 core uses another level
of parallelism which will be in competetions with parallel
during runtime.
Current updates are available through https://www.wim.uni-mannheim.de/schlather/publications/software.
Contributions to version 3.0 and following:
Felix Ballani (TU Bergakademie Freiberg; Poisson Polygons, 2014)
Daphne Boecker (Univ. Goettingen; RFgui, 2011)
Katharina Burmeister (Univ. Goettingen; testing, 2012)
Sebastian Engelke (Univ. Goettingen; RFvariogram, 2011-12)
Sebastian Gross (Univ. Goettingen; tilde formulae, 2011)
Alexander Malinowski (Univ. Mannheim; S3, S4 classes 2011-13)
Juliane Manitz (Univ. Goettingen; testing, 2012)
Johannes Martini (Univ. Goettingen; RFvariogram,
2011-12)
Ulrike Ober (Univ. Goettingen; help pages, testing, 2011-12)
Marco Oesting (Univ. Mannheim; Brown-Resnick processes, Kriging, Trend,
2011-13)
Paulo Ribeiro (Unversidade Federal do Parana; code adopted
from geoR, 2014)
Kirstin Strokorb (Univ. Mannheim; help pages, 2011-13)
Contributions to version 2.0 and following:
Peter Menck (Univ. Goettingen; multivariate circulant embedding)
R Core Team, Richard Singleton (fft.c and advice)
Contributions to version 1 and following:
Ben Pfaff, 12167 Airport Rd, DeWitt MI 48820, USA making available
an algorithm for AVL trees (avltr*)
Patrick Brown : comments on Version 3
Paulo Ribeiro : comments on Version 1
Martin Maechler : advice for Version 1
V3.0 has been financially supported by the German Science Foundation (DFG) through the Research Training Group 1953 ‘Statistical Modeling of Complex Systems and Processes — Advanced Nonparametric Approaches’ (2013-2018).
V3.0 has been financially supported by Volkswagen Stiftung within the project ‘WEX-MOP’ (2011-2014).
Alpha versions for V3.0 have been financially supported by the German Science Foundation (DFG) through the Research Training Groups 1644 ‘Scaling problems in Statistics’ and 1023 ‘Identification in Mathematical Models’ (2008-13).
V1.0 has been financially supported by the German Federal Ministry of Research and Technology (BMFT) grant PT BEO 51-0339476C during 2000-03.
V1.0 has been financially supported by the EU TMR network ERB-FMRX-CT96-0095 on “Computational and statistical methods for the analysis of spatial data” in 1999.
The following packages enable further choices for the optimizer
(instead of optim
) in RandomFields:
optimx, soma, GenSA, minqa, pso,
DEoptim, nloptr, RColorBrewer, colorspace
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Singleton, R.C. (1979). In Programs for Digital Signal Processing Ed.: Digital Signal Processing Committee and IEEE Acoustics, Speech, and Signal Processing Committe (1979) IEEE press.
Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package RandomFields. Journal of Statistical Software, 63 (8), 1-25, url = ‘http://www.jstatsoft.org/v63/i08/’
see also the corresponding vignette.
See also RF, RM, RP, RR, RC, R.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # simulate some data first (Gaussian random field with exponential # covariance; 6 realisations) model <- RMexp() x <- seq(0, 10, 0.1) z <- RFsimulate(model, x, x, n=6) ## select some data from the simulated data xy <- coordinates(z) pts <- sample(nrow(xy), min(100, nrow(xy) / 2)) dta <- matrix(nrow=nrow(xy), as.vector(z))[pts, ] dta <- cbind(xy[pts, ], dta) plot(z, dta) ## re-estimate the parameter (true values are 1) estmodel <- RMexp(var=NA, scale=NA) (fit <- RFfit(estmodel, data=dta)) ## show a kriged field based on the estimated parameters kriged <- RFinterpolate(fit, x, x, data=dta) plot(kriged, dta)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # simulate some data first (Gaussian random field with exponential # covariance; 6 realisations) model <- RMexp() x <- seq(0, 10, 0.1) z <- RFsimulate(model, x, x, n=6) ## select some data from the simulated data xy <- coordinates(z) pts <- sample(nrow(xy), min(100, nrow(xy) / 2)) dta <- matrix(nrow=nrow(xy), as.vector(z))[pts, ] dta <- cbind(xy[pts, ], dta) plot(z, dta) ## re-estimate the parameter (true values are 1) estmodel <- RMexp(var=NA, scale=NA) (fit <- RFfit(estmodel, data=dta)) ## show a kriged field based on the estimated parameters kriged <- RFinterpolate(fit, x, x, data=dta) plot(kriged, dta)
These models define particular ways to simulate Brown-Resnick processes.
RPbrmixed(phi, tcf, xi, mu, s, meshsize, vertnumber, optim_mixed, optim_mixed_tol,lambda, areamat, variobound) RPbrorig(phi, tcf, xi, mu, s) RPbrshifted(phi, tcf, xi, mu, s) RPloggaussnormed(variogram, prob, optimize_p, nth, burn.in, rejection)
RPbrmixed(phi, tcf, xi, mu, s, meshsize, vertnumber, optim_mixed, optim_mixed_tol,lambda, areamat, variobound) RPbrorig(phi, tcf, xi, mu, s) RPbrshifted(phi, tcf, xi, mu, s) RPloggaussnormed(variogram, prob, optimize_p, nth, burn.in, rejection)
phi , variogram
|
object of class |
tcf |
the extremal correlation function; either |
xi , mu , s
|
the shape parameter, the location parameter and the scale parameter, respectively, of the generalized extreme value distribution. See Details. |
lambda |
positive constant factor in the intensity of the Poisson
point process used in the M3 representation, cf. Thm. 6 and Remark 7
in Oesting et. al (2012); can be estimated by setting
|
areamat |
vector of values in |
meshsize , vertnumber , optim_mixed , optim_mixed_tol , variobound
|
further arguments
for simulation via the mixed moving maxima (M3) representation; see
|
prob |
to do |
optimize_p |
to do |
nth |
to do |
burn.in |
to do |
rejection |
to do |
The argument xi
is always a number, i.e. is constant
in space. In contrast,
and
might be constant
numerical values or given an
RMmodel
, in particular by an
RMtrend
model.
The functions RPbrorig
, RPbrshifted
and RPbrmixed
simulate a Brown-Resnick process, which is defined by
where the are the points of a Poisson point process on the
positive real half-axis with intensity
,
are iid centered Gaussian processes with
stationary increments and variogram
given by
model
. The functions correspond to the following ways of
simulation:
RPbrorig
simulation using the original definition (method 0 in Oesting et al., 2012)
RPbrshifted
simulation using a random shift (similar to method 1 and 2)
RPbrmixed
simulation using M3 representation (method 4)
The functions return an object of class
RMmodel
.
Advanced options for RPbroriginal
and RPbrshifted
are maxpoints
and max_gauss
, see RFoptions
.
Marco Oesting, [email protected], https://www.isa.uni-stuttgart.de/institut/team/Oesting/; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Oesting, M., Kabluchko, Z. and Schlather M. (2012) Simulation of Brown-Resnick Processes, Extremes, 15, 89-107.
RPbrownresnick
,
RMmodel
,
RPgauss
,
maxstable
,
maxstableAdvanced
.
# RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## currently does not work
# RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## currently does not work
RPbrownresnick
defines a Brown-Resnick process.
RPbrownresnick(phi, tcf, xi, mu, s)
RPbrownresnick(phi, tcf, xi, mu, s)
phi |
specifies the covariance model or variogram, see RMmodel and RMmodelsAdvanced. |
tcf |
the extremal correlation function; either |
xi , mu , s
|
the extreme value index, the location parameter and the scale parameter, respectively, of the generalized extreme value distribution. See Details. |
The argument xi
is always a number, i.e. is constant in space. In contrast,
and
might be constant numerical values or (in future!) be given by an
RMmodel
, in particular by an RMtrend
model.
For , the default values of
and
are
and
, respectively. For
, the default values of
and
are
and
, respectively, so that it defaults to the standard Frechet case if
.
The functions RPbrorig
, RPbrshifted
and RPbrmixed
perform the simulation of a Brown-Resnick process, which is defined by
where the are the points of a Poisson point process on the
positive real half-axis with intensity
,
are iid centered Gaussian processes with
stationary increments and variogram
given by
phi
.
For simulation, internally, one of the methods
RPbrorig
, RPbrshifted
and
RPbrmixed
is chosen automatically.
Advanced options
are maxpoints
and max_gauss
, see
RFoptions
.
Further advanced options related to the
simulation methods RPbrorig
,
RPbrshifted
and RPbrmixed
can be
found in the paragraph ‘Specific method options for Brown-Resnick
Fields’ in RFoptions
.
Marco Oesting, [email protected], https://www.isa.uni-stuttgart.de/institut/team/Oesting/; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Brown, B.M. and Resnick, S.I. (1977). Extreme values of independent stochastic processes. J. Appl. Probab. 14, 732-739.
Buishand, T., de Haan , L. and Zhou, C. (2008). On spatial extremes: With application to a rainfall problem. Ann. Appl. Stat. 2, 624-642.
Kabluchko, Z., Schlather, M. and de Haan, L (2009) Stationary max-stable random fields associated to negative definite functions Ann. Probab. 37, 2042-2065.
Oesting, M., Kabluchko, Z. and Schlather M. (2012) Simulation of Brown-Resnick Processes, Extremes, 15, 89-107.
RPbrorig
,
RPbrshifted
,
RPbrmixed
,
RMmodel
,
RPgauss
,
maxstable
,
maxstableAdvanced
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## for some more sophisticated models see 'maxstableAdvanced'
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## for some more sophisticated models see 'maxstableAdvanced'
This data set contains the calcium content measured in soil samples taken from the 0-20cm layer at 178 locations within a certain study area divided in three sub-areas. The elevation at each location was also recorded.
The first region is typically flooded during the rain season and not used as an experimental area. The calcium levels would represent the natural content in the region. The second region has received fertilisers a while ago and is typically occupied by rice fields. The third region has received fertilisers recently and is frequently used as an experimental area.
data(ca20)
data(ca20)
The object ca20
belongs to the class geodata
and is a list
with the following elements:
coords
a matrix with the coordinates of the soil samples.
data
calcium content measured in .
covariate
a data-frame with the covariates
altitude
a vector with the elevation of each
sampling location, in meters ().
area
a factor indicating the sub area to which the locations belongs.
borders
a matrix with the coordinates defining the borders of the area.
reg1
a matrix with the coordinates of the limits of the sub-area 1.
reg1
a matrix with the coordinates of the limits of the sub-area 2.
reg1
a matrix with the coordinates of the limits of the sub-area 3.
The data was collected by researchers from PESAGRO and EMBRAPA-Solos, Rio de Janeiro, Brasil and provided by Dra. Maria Cristina Neves de Oliveira.
Capeche, C.L.; Macedo, J.R.; Manzatto, H.R.H.; Silva, E.F. (1997) Caracterização pedológica da fazenda Angra - PESAGRO/RIO - Estação experimental de Campos (RJ). (compact disc). In: Congresso BRASILEIRO de Ciência do Solo. 26., Informação, globalização, uso do solo; Rio de Janeiro, 1997. trabalhos. Rio de Janeiro: Embrapa/SBCS.
Oliveira, M.C.N. (2003) Métodos de estimação de parâmetros em modelos geoestatísticos com diferentes estruturas de covariâncias: uma aplicação ao teor de cálcio no solo. Tese de Doutorado, ESALQ/USP/Brasil.
Further information on the package geoR can be found at:
http://www.leg.ufpr.br/geoR/.
Version 3.3
RFempiricalvariogram
, RFempiricalcovariance
and RFempiricalmadogram
became obsolete. Use
RFvariogram
,
RFcov
,
RFmadogram
instead.
RFoptions(grDefault=FALSE)
returns to the old style
of graphical device handling. Otherwise there is no handling.
C code is started to be parallelized.
Some new Multivariate RMmodels
New way of passing models, see RFformula, which
allows connections (formulae) between parameters, e.g. one
parameter value might be twice as large as another parameter
value. Also dummy variables can be RMdeclare
d.
Options getting obsolete (Version 3 and older)
oldstyle
is becoming warn_oldstyle
newstyle
is becoming warn_newstyle
newAniso
is becoming warn_newAniso
ambiguous
is becoming warn_ambiguous
normal_mode
is becoming warn_normal_mode
colour_palette
is becoming warn_colour_palette
Changings in option names
several changes in RFoptions()$graphics
in version 3.1.11
pdfnumber
became in version 3.0.42 filenumber
pdfonefile
became in version 3.0.42 onefile
pdffile
became in version 3.0.42 file
tbmdim
became in version 3.0.41 reduceddim
coord_units
became in version 3.0.39 coordunits
new_coord_units
became in version 3.0.39
new_coordunits
variab_units
became in version 3.0.39 varunits
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
## no examples given
## no examples given
Circulant embedding is a fast simulation method for stationary
(possibly anisotropic) Gaussian random
fields on regular grids based on Fourier transformations. It is guaranteed to be an exact method
for covariance functions with finite support, e.g. the spherical
model. The method is admissible for any dimension apart from memory
restrictions.
The simulation is performed on a torus which represents the bended
grid. To remove wrong dependencies occuring at different borders of the
grid which would be close on the torus, the simulation area is
multiplied by a natural number.
There is also a multivariate version of circulant embedding.
Cut-off embedding is a fast simulation method for stationary,
isotropic Gaussian random fields on square lattices based on
the standard RPcirculant
method,
so that exact simulation is garantueed
for further covariance models, e.g. the RMwhittle
model.
In fact, the circulant embedding is called with the cutoff
hypermodel, see RMcutoff
.
Cutoff
halfens the maximum number of
elements models used to define the covariance function of interest
(from 10 to 5).
Here, multiplicative models are not allowed (yet).
For details see RMcutoff
.
Intrinsic embedding is a fast simulation method for intrinsically stationary,
isotropic Gaussian random fields on square lattices based on
the standard RPcirculant
method,
for further variogram models, e.g. RMfbm
.
Note that the simulated random field is always non-stationary.
In fact, the circulant embedding is called with the Intrinsic
hypermodel, see RMintrinsic
.
Here, multiplicative models are not allowed (yet).
For details see RMintrinsic
.
RPcirculant(phi, boxcox, force, mmin, strategy, maxGB, maxmem, tolIm, tolRe, trials, useprimes, dependent, approx_step, approx_maxgrid) RPcutoff(phi, boxcox, force, mmin, strategy, maxGB, maxmem, tolIm, tolRe, trials, useprimes, dependent, approx_step, approx_maxgrid, diameter, a) RPintrinsic(phi, boxcox, force, mmin, strategy, maxGB, maxmem, tolIm, tolRe, trials, useprimes, dependent, approx_step, approx_maxgrid, diameter, rawR)
RPcirculant(phi, boxcox, force, mmin, strategy, maxGB, maxmem, tolIm, tolRe, trials, useprimes, dependent, approx_step, approx_maxgrid) RPcutoff(phi, boxcox, force, mmin, strategy, maxGB, maxmem, tolIm, tolRe, trials, useprimes, dependent, approx_step, approx_maxgrid, diameter, a) RPintrinsic(phi, boxcox, force, mmin, strategy, maxGB, maxmem, tolIm, tolRe, trials, useprimes, dependent, approx_step, approx_maxgrid, diameter, rawR)
phi |
See |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
force |
Logical. Circulant embedding does not work
if the constructed circulant
matrix has negative eigenvalues. Sometimes it is convenient
to replace all the negative eigenvalues by zero
( |
mmin |
Scalar or vector, integer if positive.
|
strategy |
Logical. In some cases Default: |
maxGB |
Maximal memory used for the circulant matrix in units of
GB.
If this argument is set then Default: 1. |
maxmem |
Integer. maximal number of entries in a row of the circulant matrix. The total amount of memory needed for the internal calculations is 32 (= 4 * sizeof(double)) time as large (factor 2 is needed as complex numbers must be considered for calculating the fft of the covariance matrix; another factor 2 is needed for storing the simulated result). The value of Note that If this argument is set then Default: |
tolIm |
If the modulus of the imaginary part is less than
Default: |
tolRe |
Eigenvalues between Default: |
trials |
Integer.
A larger circulant matrix is likely to make more eigenvalues
non-negative. If at least one of the thresholds Default: |
useprimes |
Logical. If Default: |
dependent |
Logical. If Default: |
approx_step |
Real value. It gives the grid size of the approximating grid in case circulant embedding is used although the points do not lie on a grid. If Default: |
approx_maxgrid |
It defaults to |
diameter |
See |
a |
See |
rawR |
See |
Here, the algorithms by Dietrich and Newsam are implemented.
An object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Circulant Embedding
Chan, G. and Wood, A.T.A. (1997) An Algorithm for Simulating Stationary Gaussian Random Fields. Journal of the Royal Statistical Society: Series C (Applied Statistics), 46, 171–181.
Dietrich, C. R. and G. N. Newsam (1993) A fast and exact method for multidimensional gaussian stochastic simulations. Water Resour. Res. 29(8), 2861–2869.
Dietrich, C. R. and G. N. Newsam (1996) A fast and exact method for multidimensional Gaussian stochastic simulations: Extension to realizations conditioned on direct and indirect measurements Water Resour. Res. 32(6), 1643–1652.
Dietrich, C. R. and Newsam, G. N. (1997) Fast and Exact Simulation of Stationary Gaussian Processes through Circulant Embedding of the Covariance Matrix. SIAM J. Sci. Comput. 18, 1088–1107.
Wood, A. T. A. and Chan, G. (1994)
Simulation of Stationary Gaussian Processes in .
Journal of Computational and Graphical Statistics
3, 409–432.
Cutoff and Intrinsic
Gneiting, T., Sevecikova, H, Percival, D.B., Schlather M., Jiang Y. (2006) Fast and Exact Simulation of Large Gaussian Lattice Systems in $R^2$: Exploring the Limits. J. Comput. Graph. Stat. 15, 483–501.
Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. J. Comput. Graph. Statist. 11, 587–599
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstable(s=1, alpha=1.8) x <- seq(-3,3,0.1) z <- RFsimulate(model=RPcirculant(model), x=x, y=x, n=1) plot(z) model <- RMexp(var=10, s=2) z <- RFsimulate(model=RPcirculant(model), 1:10) plot(z) model <- RMfbm(Aniso=diag(c(1,2)), alpha=1.5) z <- RFsimulate(model, x=1:10, y=1:10) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstable(s=1, alpha=1.8) x <- seq(-3,3,0.1) z <- RFsimulate(model=RPcirculant(model), x=x, y=x, n=1) plot(z) model <- RMexp(var=10, s=2) z <- RFsimulate(model=RPcirculant(model), 1:10) plot(z) model <- RMfbm(Aniso=diag(c(1,2)), alpha=1.5) z <- RFsimulate(model, x=1:10, y=1:10) plot(z)
The random coin method (or dilution method) is a simulation method for
stationary Gaussian random fields. It is based on the following procedure:
For a stationary Poisson point process on
consider the random field
for a function . The covariance of
is
proportional to the convolution
If the intensity of the Poisson point process increases, the
random field approaches a Gaussian random field
with covariance function
.
RPcoins(phi, shape, boxcox, intensity, method) RPaverage(phi, shape, boxcox, intensity, method)
RPcoins(phi, shape, boxcox, intensity, method) RPaverage(phi, shape, boxcox, intensity, method)
phi |
object of class |
shape |
object of class |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
intensity |
positive number, intensity of the underlying Poisson point process. |
method |
integer.
Default is the value |
RPcoins
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Lantuejoul, C. (2002) Geostatistical Simulation: Models and Algorithms. Springer.
Gaussian,
RP,
RPhyperplane
,
RPspectral
,
RPtbm
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
Several constants are provided that might make
the use of some functions easier, e.g. RFgetModelNames
.
RC_TYPE_NAMES = c(
"tail correlation", "positive definite", "variogram", "negative definite",
"point-shape function", "shape function", "trend", "distribution or shape",
"of manifold type", "process", "method for Gauss process",
"normed process (non-negative values with maximum value being 0 or 1)",
"method for Brown-Resnick process",
"Smith", "Schlather", "Poisson", "PoissonGauss",
"distribution family", "interface", "mathematical operator",
"other type")
RC_DOMAIN_NAMES = c("single variable", "kernel",
"framework dependent", "submodel dependent",
"parameter dependent", "<keep copy>", "mismatch")
RC_ISO_NAMES = c("isotropic", "space-isotropic",
"vector-isotropic", "symmetric",
"cartesian system", "gnomonic projection", "orthographic projection",
"spherical isotropic", "spherical symmetric", "spherical system",
"earth isotropic", "earth symmetric", "earth system",
"cylinder system", "non-dimension-reducing", "framework dependent",
"submodel dependent", "parameter dependent",
"<internal keep copy>", "<mismatch>")
RC_MONOTONE_NAMES = c(
"not set", "mismatch in monotonicity", "submodel dependent monotonicity",
"previous model dependent monotonicity",
"parameter dependent monotonicity",
"not monotone", "monotone", "Gneiting-Schaback class",
"normal mixture",
"completely monotone",
"Bernstein")
RC_ISOTROPIC
gives the numerical code for option
"isotropic"
RC_DOUBLEISOTROPIC
gives the numerical code for option
"space-isotropic"
RC_CARTESIAN_COORD
gives the numerical code for option
"cartesian system"
RC_GNOMONIC_PROJ
gives the numerical code for
the gnomonic projection, see also zenit
in RFoptions
.
RC_ORTHOGRAPHIC_PROJ
gives the numerical code for
the orthographic
projection, see also zenit
in RFoptions
.
RC_EARTH_COORDS
gives the numerical code for option
"earth coordinates"
RC_EARTH_ISOTROPIC
gives the numerical code for option
"earth isotropic"
RC_SPHERICAL_COORDS
gives the numerical code for option
"earth coordinates"
RC_OPTIMISER_NAMES
and RC_NLOPTR_NAMES
give the
names for the options optimiser
and algorithm
,
respectively, RFfitoptimiser
.
RC_LIKELIHOOD_NAMES = c("auto", "full", "composite",
"tesselation")
gives the names of the ML variants: (i) internal
choice according to the
number of data, (ii) full likelihood, (iii) (pairwise) composite likelihood,
and (iv) composite likelihood based on a tessellation of the space.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RF, RM, RP, RR, R.,
RFgetModelNames
,
RMmodelgenerator-class,
RMtrafo
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RC_ISO_NAMES RC_ISO_NAMES[RC_ISOTROPIC:RC_CARTESIAN_COORD + 1] ## Not run: RFgetModelNames(isotropy=RC_ISO_NAMES[RC_ISOTROPIC:RC_CARTESIAN_COORD + 1]) ## End(Not run)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RC_ISO_NAMES RC_ISO_NAMES[RC_ISOTROPIC:RC_CARTESIAN_COORD + 1] ## Not run: RFgetModelNames(isotropy=RC_ISO_NAMES[RC_ISOTROPIC:RC_CARTESIAN_COORD + 1]) ## End(Not run)
Generate an object of class RFsp
from conventional objects.
conventional2RFspDataFrame(data, coords=NULL, gridTopology=NULL, n=1, vdim=1, T=NULL, vdim_close_together)
conventional2RFspDataFrame(data, coords=NULL, gridTopology=NULL, n=1, vdim=1, T=NULL, vdim_close_together)
data |
array; of dimension |
coords |
matrix of coordinates |
gridTopology |
3-row-matrix or of class |
n |
number of iid copies of the random field, default is 1 |
vdim |
number of dimensions of the values of the random field, default is 1 |
T |
time component if any. The length of the temporal grid
is needed by |
vdim_close_together |
logical. Currently, only |
Object of class
RFspatialGridDataFrame
,
RFspatialPointsDataFrame
,
RFgridDataFrame
or
RFpointsDataFrame
.
Alexander Malinowski, Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- 1:20 z <- RFsimulate(RMexp(), x, spConform=FALSE) z2 <- conventional2RFspDataFrame(z, coord=x) Print(z, z2)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- 1:20 z <- RFsimulate(RMexp(), x, spConform=FALSE) z2 <- conventional2RFspDataFrame(z, coord=x) Print(z, z2)
Implemented Coordinate Systems.
Cartesian coordinate system
Earth coordinate systems
The earth is considered as an ellipsoid;
The first angle takes values in ,
the second angle takes values in
.
Spherical coordinate systems
The earth is considered as an ellipsoid;
The first angle takes values in ,
the second angle takes values in
.
Earth to cartesian
The 3-dimensional resulting coordinates
are either given in ‘km’ or in ‘miles’.
Gnomonic and orthographic projections
The 2-dimensional resulting coordinates
are either given in ‘km’ or in ‘miles’.
The projection direction is given by the zenit
.
Earth to spherical
In this case the Earth is considered as a ball.
Cartesian systems cannot be transformed to earth or spherical coordinate systems, nor a spherical system to earth coordinates.
coord_system
character.
One of the values "auto"
, "cartesian"
, "earth"
If "auto"
, then the coordinates are considered as
"cartesian"
except the names of the given coordinates
indicate a
different system. Currently, only "longitude"
and
"latidute"
(or abbreviations of them) are excepted
as names for given coordinates
and indicate an earth coordinate systems. See the examples below.
Default: "auto"
coordidx
integer vector of column numbers of the variables in
the data frame. varidx
can be set alternatively to
coordnames
.
This parameter gives the coordinate columns in a data frame
by starting column and ending column or the sequence.
An NA
in the second component means
‘until the end’.
coordnames
vector of characters that can be set
alternatively to coordidx.
This parameter gives the coordinate columns in a data frame by names.
If it is "NA"
, then, depending on the context, either
an error message is returned or it is assumed that the first
columns give the coordinates.
coordunits
any string.
If coordinate_system = "earth"
and longitude and latitude
are transformed to 3d cartesian coordinates, coordunits
determines
whether the radius is given in kilometers ("km"
) or miles
("miles"
).
If empty, then "km"
is chosen.
Default: ""
new_coord_system
One of the values "keep"
, "cartesian"
, "earth"
,
"plane"
.
"keep"
The coord_system
is kept (except an explicit transformation
is given, see RMtrafo
.
Note that some classes of models, e.g. completely monotone
functions and compactly supported covariance models with
range less than are valid models on a sphere.
In this case the models are considered as models on the sphere.
See spherical models for lists.
"cartesian"
If coord_system
is "earth"
the coordinates are transformed
to cartesian coordinates before any model is considered.
"orthographic"
, "genomic"
If coord_system
is "earth"
the locations are projected
to a plane before any
model is considered.
Default: "keep"
new_coordunits
internal and should not be set by the user.
Default: ""
polar_coord
logical.
If FALSE
the spherical coordinates agree with
the earth coordinate parametrization, except that
radians are used for spherical coordinates instead
of degrees for the earth coordinates.
If TRUE
the spherical coordinates signify polar coordinates.
Default : FALSE
varidx
integer vector of length 2.
varidx
can be set alternatively to
varnames
.
This parameter gives the data columns in a data frame, either
by starting column and ending column.
An NA
in the second component means
‘until the end’.
varnames
vector of characters that can be set
alternatively to varidx
. This parameter gives
the data columns in a data frame by names.
if varnames
equals "NA"
then for keywords ‘data’,
‘value’ and ‘variable’ will be searched for keywords.
If none of them are found, depending on the context, either
an error message is returned or it is assumed that the last
columns give the data.
varunits
vector of characters. The default units of the variables.
Default: ""
xyz_notation
logical or NA
. Used by
RMuser
only.
NA
: automatic choice (if possible)
FALSE
: notation (x, y) should not be understood as kernel definition, not as xyz notation
TRUE
: xyz notation used
zenit
two angles of the central projection direction for the gnomonic projection (https://en.wikipedia.org/wiki/Gnomonic_projection, https://de.wikipedia.org/wiki/Gnomonische_Projektion) and the orthographic projection, (https://en.wikipedia.org/wiki/Orthographic_projection_in_cartography, https://de.wikipedia.org/wiki/Orthografische_Azimutalprojektion).
If any(is.na(zenit))
then either the value of either of the components may not be NA
,
whose value will be denoted by .
If then the mean of the locations is calculated;
if
then the mean of the range is calculated.
Default: c(1, NA)
Covariance models in a cartesian system
Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., Space-Time Processes and Challenges Related to Environmental Problems. New York: Springer.
Covariance models on a sphere
Gneiting, T. (2013) Strictly and non-strictly positive definite functions on spheres. Bernoulli, 19, 1327-1349.
Tail correlation function
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
RMtrafo
,
RFearth2cartesian
,
RPdirect
,
models valid on a sphere
,
RFoptions
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again z <- 1:4 x <- cbind(z, 0) y <- cbind(0, z) model <- RMwhittle(nu=0.5) RFcov(model, x, y, grid=FALSE) ## standard is (cartesian) model ## same as above, but explicit: RFcov(model, x, y, grid=FALSE, coord_sys="cartesian") ## model is not valid on a sphere; x,y coordinates are ## transformed from earth coordinates to spherical coordinates RFcov(model, x, y, grid=FALSE, coord_sys="earth") ## now the scale is chosen such that the covariance ## values are comparable to those in the cartesian case RFcov(RMS(model, s= 1 / 180 * pi), x, y, grid=FALSE, coord_sys="earth") ## projection onto a plane first. Then the scale is interpreted ## in the usual, i.e. cartesian, sense, i.e. the model does not ## really make sense RFoptions(zenit = c(2.5, 2.5)) RFcov(model, x, y, grid=FALSE, coord_sys="earth", new_coord_sys="orthographic") ## again, here the scale is chosen to be comparable to the cartesian case ## here the (standard) units are [km] (z1 <- RFcov(RMS(model, s= 6350 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="orthographic")) ## as above, but in miles (z2 <- RFcov(RMS(model, s= 6350 / 1.609344 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="orthographic", new_coordunits="miles")) stopifnot(all.equal(z1, z2)) ## again, projection onto a plane first, but now using the ## gnomonic projection ## here the (standard) units are [km] (z1 <- RFcov(RMS(model, s= 6350 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="gnomonic")) ## as above, but in miles (z2 <- RFcov(RMS(model, s= 6350 / 1.609344 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="gnomonic", new_coordunits="miles")) stopifnot(all.equal(z1, z2, tol=1e-5))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again z <- 1:4 x <- cbind(z, 0) y <- cbind(0, z) model <- RMwhittle(nu=0.5) RFcov(model, x, y, grid=FALSE) ## standard is (cartesian) model ## same as above, but explicit: RFcov(model, x, y, grid=FALSE, coord_sys="cartesian") ## model is not valid on a sphere; x,y coordinates are ## transformed from earth coordinates to spherical coordinates RFcov(model, x, y, grid=FALSE, coord_sys="earth") ## now the scale is chosen such that the covariance ## values are comparable to those in the cartesian case RFcov(RMS(model, s= 1 / 180 * pi), x, y, grid=FALSE, coord_sys="earth") ## projection onto a plane first. Then the scale is interpreted ## in the usual, i.e. cartesian, sense, i.e. the model does not ## really make sense RFoptions(zenit = c(2.5, 2.5)) RFcov(model, x, y, grid=FALSE, coord_sys="earth", new_coord_sys="orthographic") ## again, here the scale is chosen to be comparable to the cartesian case ## here the (standard) units are [km] (z1 <- RFcov(RMS(model, s= 6350 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="orthographic")) ## as above, but in miles (z2 <- RFcov(RMS(model, s= 6350 / 1.609344 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="orthographic", new_coordunits="miles")) stopifnot(all.equal(z1, z2)) ## again, projection onto a plane first, but now using the ## gnomonic projection ## here the (standard) units are [km] (z1 <- RFcov(RMS(model, s= 6350 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="gnomonic")) ## as above, but in miles (z2 <- RFcov(RMS(model, s= 6350 / 1.609344 / 180 * pi), x, y, grid=FALSE, coord_sys="earth", new_coord_sys="gnomonic", new_coordunits="miles")) stopifnot(all.equal(z1, z2, tol=1e-5))
Distribution families to specify random parameters in the model definition.
See Bayesian Modelling for a less technical introduction to hierarchical modelling.
When simulating Gaussian random fields, the random parameters
are drawn only once at the very beginning.
So, if the argument n
in RFsimulate
is greater than 1
then n
simulations conditional
on a single realization of the random parameters are
performed. See the examples below.
There are (simple) multivariate versions and additional versions to the distributions families implemented. Further, any distribution family defined in R can be used, see the examples below.
These functions will allow for Bayesian modelling. (Future project).
RRdeterm |
no scattering |
RRdistr |
families of distributions transferred from R |
RRgauss |
a (multivariate) Gaussian random variable |
RRloc |
modification of location and scale |
RRspheric |
random scale for
the RMball to simulate RMspheric , etc.
|
RRunif |
a (multivariate) uniform random variable |
The allowance of random parameters is a very recent, developing feature of RandomFields.
Future changings of the behaviour are not unlikely.
A further random element is RMsign
, which is an
operator on shape functions. As an exception its name starts with
RM
and not with RR
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RC, RF, RM, RP, Other models
,
RFdistr
,
RMmodelgenerator
, R.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## here, the scale is given by an exponential variable: model <- RMgauss(scale=exp()) for (i in 1:4) { RFoptions(seed = i) # each leads to a simulation with a different scale parameter plot(model) ## random plot(RFsimulate(model, x=seq(0,10,0.1))) readline("press return") } # but here, all 4 simulations have the same (but random) scale: plot(RFsimulate(model, x=seq(0,10,0.1), n=4)) ## hierarchical models are also possible: ## here, the scale is given by an exponential variable whose ## rate is given by a uniform variable model <- RMgauss(scale=exp(rate=unif())) plot(model) plot(RFsimulate(model, x=seq(0,10,0.1))) ## HOWEVER, the next model is deterministic with scale \code{e=2.718282}. model <- RMgauss(scale=exp(1)) plot(model) plot(RFsimulate(model, x=seq(0,10,0.1)))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## here, the scale is given by an exponential variable: model <- RMgauss(scale=exp()) for (i in 1:4) { RFoptions(seed = i) # each leads to a simulation with a different scale parameter plot(model) ## random plot(RFsimulate(model, x=seq(0,10,0.1))) readline("press return") } # but here, all 4 simulations have the same (but random) scale: plot(RFsimulate(model, x=seq(0,10,0.1), n=4)) ## hierarchical models are also possible: ## here, the scale is given by an exponential variable whose ## rate is given by a uniform variable model <- RMgauss(scale=exp(rate=unif())) plot(model) plot(RFsimulate(model, x=seq(0,10,0.1))) ## HOWEVER, the next model is deterministic with scale \code{e=2.718282}. model <- RMgauss(scale=exp(1)) plot(model) plot(RFsimulate(model, x=seq(0,10,0.1)))
RPopitz
defines an extremal t process.
RPopitz(phi, xi, mu, s, alpha)
RPopitz(phi, xi, mu, s, alpha)
phi |
an |
xi , mu , s
|
the extreme value index, the location parameter and the scale parameter, respectively, of the generalized extreme value distribution. See Details. |
alpha |
originally referred to the |
The argument xi
is always a number, i.e. is constant in space. In contrast,
and
might be constant numerical values or (in future!) be given by an
RMmodel
, in particular by an RMtrend
model.
For , the default values of
and
are
and
, respectively. For
, the default values of
and
are
and
, respectively, so that it defaults to the standard Frechet case if
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Davison, A.C., Padoan, S., Ribatet, M. (2012). Statistical modelling of spatial extremes. Stat. Science 27, 161-186.
Opitz, T. (2012) A spectral construction of the extremal t process. arxiv 1207.2296.
RMmodel
,
RPgauss
,
maxstable
,
maxstableAdvanced
.
## sorry, does not work savely yet
## sorry, does not work savely yet
RPschlather
defines an extremal Gaussian process.
RPschlather(phi, tcf, xi, mu, s)
RPschlather(phi, tcf, xi, mu, s)
phi |
an |
tcf |
an |
xi , mu , s
|
the extreme value index, the location parameter and the scale parameter, respectively, of the generalized extreme value distribution. See Details. |
The argument xi
is always a number, i.e. is constant in space. In contrast,
and
might be constant numerical values or (in future!) be given by an
RMmodel
, in particular by an RMtrend
model.
For , the default values of
and
are
and
, respectively. For
, the default values of
and
are
and
, respectively, so that it defaults to the standard Frechet case if
.
The argument phi
can be any random field for
which the expectation of the positive part is known at the origin.
It simulates an Extremal Gaussian process (also
called “Schlather model”), which is defined by
where the are the points of a Poisson point process on the
positive real half-axis with intensity
,
are iid stationary Gaussian processes with a covariance function
given by
phi
, and is chosen such
that
has standard Frechet margins.
phi
must
represent a stationary covariance model.
Advanced options
are maxpoints
and max_gauss
, see
RFoptions
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmodel
,
RPgauss
,
maxstable
,
maxstableAdvanced
.
RFoptions(seed=0, xi=0) ## seed=0: *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## xi=0: any simulated max-stable random field has extreme value index 0 x <- seq(0, 2,0.01) ## standard use of RPschlather (i.e. a standardized Gaussian field) model <- RMgauss() z1 <- RFsimulate(RPschlather(model), x) plot(z1, type="l") ## the following refers to the generalized use of RPschlather, where ## any random field can be used. Note that 'z1' and 'z2' have the same ## margins and the same .Random.seed (and the same simulation method), ## hence the same values model <- RPgauss(RMgauss(var=2)) z2 <- RFsimulate(RPschlather(model), x) plot(z2, type="l") all.equal(z1, z2) # true ## Note that the following definition is incorrect try(RFsimulate(model=RPschlather(RMgauss(var=2)), x=x)) ## check whether the marginal distribution (Gumbel) is indeed correct: model <- RMgauss() z <- RFsimulate(RPschlather(model, xi=0), x, n=100) plot(z) hist(unlist(z@data), 50, freq=FALSE) curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE)
RFoptions(seed=0, xi=0) ## seed=0: *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## xi=0: any simulated max-stable random field has extreme value index 0 x <- seq(0, 2,0.01) ## standard use of RPschlather (i.e. a standardized Gaussian field) model <- RMgauss() z1 <- RFsimulate(RPschlather(model), x) plot(z1, type="l") ## the following refers to the generalized use of RPschlather, where ## any random field can be used. Note that 'z1' and 'z2' have the same ## margins and the same .Random.seed (and the same simulation method), ## hence the same values model <- RPgauss(RMgauss(var=2)) z2 <- RFsimulate(RPschlather(model), x) plot(z2, type="l") all.equal(z1, z2) # true ## Note that the following definition is incorrect try(RFsimulate(model=RPschlather(RMgauss(var=2)), x=x)) ## check whether the marginal distribution (Gumbel) is indeed correct: model <- RMgauss() z <- RFsimulate(RPschlather(model, xi=0), x, n=100) plot(z) hist(unlist(z@data), 50, freq=FALSE) curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE)
Here, some details of RFfit
are given
concerning the fitting of models for Gaussian random fields.
This documentation is far from being complete.
The application of the usual maximum likelihood method and reporting the result is the default.
The weighted least squares methods minimize
over all parametrized models of .
Here,
runs over all
bins of the binned variogram
and
is the centre of bin
.
The following variants of the least squares methods,
passed as sub.methods
in RFfit
are implemented:
'self'
'plain'
for all
.
'sqrt.nr'
equals the number of points
in bin
.
'sd.inv'
equals the standard deviation
of the variogram cloud within bin
.
'internal'
Three subvariants are implemented:
'internal1'
'internal2'
'internal3'
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFfit
, RFfit-class
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## See 'RFfit'.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## See 'RFfit'.
Here, all the methods (models) for simulating Gaussian random fields are listed.
RPcirculant |
simulation by circulant embedding |
RPcutoff |
simulation by a variant of circulant embedding |
RPcoins |
simulation by random coin / shot noise |
RPdirect |
through the square root of the covariance matrix |
RPgauss |
generic model that chooses automatically among the specific methods |
RPhyperplane |
simulation by hyperplane tessellation |
RPintrinsic |
simulation by a variant of circulant embedding |
RPnugget |
simulation of (anisotropic) nugget effects |
RPsequential |
sequential method |
RPspecific |
model specific methods (very advanced) |
RPspectral |
spectral method |
RPtbm |
turning bands |
Assume at locations in
dimensions a
-variate
field has to be simulated.
Let
The following table gives in particular the time and memory needed for the specific simulation method.
grid | |
|
time | memory | comments | |
RPcirculant
|
yes | any | |
|
|
|
no | any | |
|
|
approx_step
|
|
RPcutoff |
see RPcirculant above | |||||
RPcoins |
yes | |
|
|
|
|
no | |
|
|
|
depends on the geometry
|
|
RPdirect
|
any | any | any |
|
|
effort to investigate the covariance matrix, if
matrix_methods is not specified (default) |
|
|
covariance matrix is diagonal | ||||
see spam |
|
covariance matrix is sparse
matrix with non-zeros |
||||
|
|
arbitrary covariance matrix (preparation) | ||||
|
|
arbitrary covariance matrix (simulation) | ||||
RPgauss |
any | any | any | |
|
only the selection
process; if first method tried is successful
|
RPhyperplane |
any | |
|
|
|
scale
|
RPintrinsic |
see RPcirculant above | |||||
RPnugget |
any | any | any |
|
|
|
RPsequential |
any | |
any |
|
|
;
and the number of spatial and temporal locations,
respectively;
back_steps (preparation) |
|
|
(simulation) | ||||
RPspectral |
any | |
|
|
|
: large constant increasing in |
RPtbm |
any | |
|
|
|
:
large constant increasing in ; is the effort needed to
simulate on a line (or plane) |
RPspecific |
only the specific part | |||||
* * RMplus
|
any | any | any | O(v n) | O(v n) | |
* * RMS
|
any | any | any | O(1) | O(v n) | |
* * RMmult
|
any | any | any | O(v n) | O(v n) | |
Assume -variate data are given at
locations in
dimensions.
To interpolate at
locations RandomFields needs
grid | |
|
time | memory | comments |
any | any | any |
|
|
effort to investigate the covariance matrix, if
matrix_methods is not specified (default)
|
|
|
covariance matrix is diagonal | |||
see spam+ O(v^2nk) |
|
covariance matrix is sparse
matrix with non-zeros |
|||
|
|
arbitrary covariance matrix |
Assume -variate data are given at
locations
in
dimensions.
To conditionally simulate at
locations
, the
computing demand equals the
sum of the demand for interpolating and
the demand for simulating on the
locations.
(Grid algorithms for simulating will apply if the
locations
are defined by a grid and the
locations
are a subset of
, a situation typical in image analysis.)
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
Schlather, M. (2010) On some covariance models based on normal scale mixtures. Bernoulli, 16, 780-797.
Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., Space-Time Processes and Challenges Related to Environmental Problems. New York: Springer.
Yaglom, A.M. (1987) Correlation Theory of Stationary and Related Random Functions I, Basic Results. New York: Springer.
Wackernagel, H. (2003) Multivariate Geostatistics. Berlin: Springer, 3nd edition.
RP,
Other models
,
RMmodel
,
RFgetMethodNames
,
RFsimulateAdvanced
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again set.seed(1) x <- runif(90, 0, 500) z <- RFsimulate(RMspheric(), x) z <- RFsimulate(RMspheric(), x, max_variab=10000)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again set.seed(1) x <- runif(90, 0, 500) z <- RFsimulate(RMspheric(), x) z <- RFsimulate(RMspheric(), x, max_variab=10000)
Here, the code of the paper on ‘Fast and Exact Simulation of Large Gaussian Lattice Systems in R2’ is given.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T., Sevcikova, H., Percival, D.B., Schlather, M., Jiang, Y. (2006) Fast and Exact Simulation of Large Gaussian Lattice Systems in R2: Exploring the Limits. J. Comput. Graph. Stat., 15, 483-501.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Figure 1 (pretty time consuming) stabletest <- function(alpha, theta, size=512) { RFoptions(trials=1, tolIm = 1e-8, tolRe=0, force = FALSE, useprimes=TRUE, strategy=0, skipchecks=!FALSE, storing=TRUE) model <- RMcutoff(diameter=theta, a=1, RMstable(alpha=alpha)) RFcov(dist=0, model=model, dim=2, seed=0) r <- RFgetModelInfo(modelname="RMcutoff", level=3)$storage$R_theor x <- seq(0, r, by= r / (size - 1)) * theta err <- try(RFsimulate(x, x, model=RPcirculant(model), n=0)) return(if (class(err) == "try-error") NA else r) } alphas <- seq(1.52, 2.0, 0.02) thetas <- seq(0.05, 3.5, 0.05) m <- matrix(NA, nrow=length(thetas), ncol=length(alphas)) for (it in 1:length(thetas)) { theta <- thetas[it] for (ia in 1:length(alphas)) { alpha <- alphas[ia] cat("alpha=", alpha, "theta=", theta,"\n") m[it, ia] <- stabletest(alpha=alpha, theta=theta) if (is.na(m[it, ia])) break } if (any(is.finite(m))) image(thetas, alphas, m, col=rainbow(100)) }
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Figure 1 (pretty time consuming) stabletest <- function(alpha, theta, size=512) { RFoptions(trials=1, tolIm = 1e-8, tolRe=0, force = FALSE, useprimes=TRUE, strategy=0, skipchecks=!FALSE, storing=TRUE) model <- RMcutoff(diameter=theta, a=1, RMstable(alpha=alpha)) RFcov(dist=0, model=model, dim=2, seed=0) r <- RFgetModelInfo(modelname="RMcutoff", level=3)$storage$R_theor x <- seq(0, r, by= r / (size - 1)) * theta err <- try(RFsimulate(x, x, model=RPcirculant(model), n=0)) return(if (class(err) == "try-error") NA else r) } alphas <- seq(1.52, 2.0, 0.02) thetas <- seq(0.05, 3.5, 0.05) m <- matrix(NA, nrow=length(thetas), ncol=length(alphas)) for (it in 1:length(thetas)) { theta <- thetas[it] for (ia in 1:length(alphas)) { alpha <- alphas[ia] cat("alpha=", alpha, "theta=", theta,"\n") m[it, ia] <- stabletest(alpha=alpha, theta=theta) if (is.na(m[it, ia])) break } if (any(is.finite(m))) image(thetas, alphas, m, col=rainbow(100)) }
RandomFields provides Bayesian modelling to some extend: (i) simulation of hierarchical models at arbitrary depth; (ii) estimation of the parameters of a hierarchical model of depth 1 by means of maximizing the likelihood.
A Bayesian approach can be taken for scalar, real valued model
parameters, e.g. the shape parameter nu
in the
RMmatern model.
A random parameter can be passed through a distribution
of an existing family, e.g. (dnorm
, pnorm
,
qnorm
, rnorm
) or self-defined.
It is passed without the leading letter
d
, p
, q
, r
, but as a function call
e.g norm()
.
This function call may contain arguments that must be
named, e.g. norm(mean=3, sd=5)
.
Usage:
exp()
denotes the exponential distribution family
with rate 1,
exp(3)
is just the scalar and
exp(rate=3)
is the exponential
distribution family with rate .
The family can be passed in three ways:
implicitly, e.g. RMwhittle(nu=exp())
or
explicitly through RRdistr
, e.g.
RMwhittle(nu=RRdistr(exp()))
.
by use of RRmodels
of the package.
The first is more convenient, the second more flexible and slightly safer.
While simulating any depth of hierarchical modelling is possible, estimation is currently restricted to one level of hierarchy.
The effect of the distribution family varies between the different processes:
in max-stable fields and
RPpoisson
, a new realization of the prior
distribution(s) is drawn for each shape function
in all other cases: a realization of the prior(s)
is only drawn once.
This effects, in particular, Gaussian fields with argument
n>1
, where all realizations are based on the same
realization out of the prior distribution(s).
Note that checking the validity of the arguments is rather limited for such complicated models, in general.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmodelsAdvanced. For hierarchical modelling see RR.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## See 'RRmodels' for hierarchical models ## the following model defines the argument nu of the Whittle-Matern ## model to be an exponential random variable with rate 5. model <- ~ 1 + RMwhittle(scale=NA, var=NA, nu=exp(rate=5)) + RMnugget(var=NA) data(soil) fit <- RFfit(model, x=soil$x, y=soil$y, data=soil$moisture, modus="careless") print(fit)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## See 'RRmodels' for hierarchical models ## the following model defines the argument nu of the Whittle-Matern ## model to be an exponential random variable with rate 5. model <- ~ 1 + RMwhittle(scale=NA, var=NA, nu=exp(rate=5)) + RMnugget(var=NA) data(soil) fit <- RFfit(model, x=soil$x, y=soil$y, data=soil$moisture, modus="careless") print(fit)
The Hyperplane method is a simulation method for stationary, isotropic random fields with exponential covariance function. It is based on a tessellation of the space by hyperplanes. Each cell takes a spatially constant value of an i.i.d. random variable. The superposition of several such random fields yields approximatively a Gaussian random field.
RPhyperplane(phi, boxcox, superpos, maxlines, mar_distr, mar_param ,additive)
RPhyperplane(phi, boxcox, superpos, maxlines, mar_distr, mar_param ,additive)
phi |
object of class |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
superpos |
integer. number of superposed hyperplane tessellations.
Default: |
maxlines |
integer. Maximum number of allowed lines. Default: |
mar_distr |
integer. code for the marginal distribution used in the simulation:
This argument should not be changed yet. Default: |
mar_param |
Argument used for the marginal distribution. The argument should not be changed yet. Default: |
additive |
logical.
If Default: |
RPhyperplane
returns an object of class
RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Lantuejoul, C. (2002) Geostatistical Simulation: Models and Algorithms. Springer.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPhyperplane(RMexp(s=2), superpos=1) x <- seq(0, 3, 0.04) z <- RFsimulate(x=x, x, model=model, n=1) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPhyperplane(RMexp(s=2), superpos=1) x <- seq(0, 3, 0.04) z <- RFsimulate(x=x, x, model=model, n=1) plot(z)
Method to simulate the Nugget effect. (Only for advanced users)
RPnugget(phi, boxcox, tol, vdim)
RPnugget(phi, boxcox, tol, vdim)
phi |
object of class |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
tol |
points at a distance less than or equal to Default: |
vdim |
positive integer; the model is treated
Default is that it takes the value of the submodel |
This method only allows RMnugget
as a submodel.
The method also allows for zonal nugget effects. Only there the
argument tol
becomes important.
For the zonal nugget effect, the anisotropy matrix Aniso
should be given in RMnugget
. There, only the
kernel of the
matrix is important.
The
locations at a distance less than or equal to the RFoptions
nugget.tol
are considered as being identical. This strategy applies to
the simulation method and the covariance function itself.
Hence, the covariance function is only positive definite
if nugget.tol=0.0
. However, if the anisotropy matrix
does not have full rank and nugget.tol=0.0
, then the
simulations are likely to be odd.
The value of nugget.tol
should be of order .
Measurement errors are mathematically not distinguishable from spatial
nugget effects as long as measurements are not repeated at the very
same space-time
location. So there is no need to distinguish the spatial nugget
effect from a measurement error.
This is the default, see
allow_duplicated_locations
in RFoptions.
In case several measurement have been taken in single space-time
locations,
measurement errors can be separated from spatial noise.
In this case RMnugget()
models the measurement error (which
corresponds to a non-stationary model in an abstract space) by
default and the
measurement error model cannot be extended beyond the given
locations.
On the other hand RMnugget(Ansio=something)
and
RMnugget(proj=something)
model the spatial nugget effect
(with and without zonal anisotropy in case Aniso
has low and
full rank respectively).
RPnugget
Even for advanced users, there is no need to call
RPnugget
directly, as this is done internally when
the RMnugget is involved in the covariance model.
RPnugget
returns an object of class
RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
Gaussian,
RP,
RPcoins
,
RPhyperplane
,
RPspectral
,
RPtbm
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- 1:2 xy <- as.matrix(expand.grid(x, y)) ## we get 4 locations ## Standard use of the nugget effect model <- RMnugget(var = 100) RFcovmatrix(model, x=xy) as.vector(RFsimulate(model, x=x, y=x, tol=1e-10)) ## zonal nugget effect, which is not along the axes model <- RMnugget(Aniso=matrix(1, nr=2, nc=2)) RFcovmatrix(model, x=xy) as.vector(RFsimulate(model, x=x, y=x, tol=1e-10)) ## All the following examples refer to repeated measurements RFoptions(allow_duplicated_locations = TRUE) (xy <- rbind(xy, xy)) ## now, the 4 locations are repeated twice ## standard situation: the nugget is interpreted as measurement error: model <- RMnugget() RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy)) ## any anisotropy matrix with full rank: spatial nugget effect model <- RMnugget(Aniso=diag(2)) RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy)) ## anisotropy matrix with lower rank: zonal nugget effect model <- RMnugget(Aniso=matrix(c(1, 0, 0, 0), nc=2)) RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy)) ## same as before: zonal nugget effect model <- RMnugget(Aniso=t(c(1,0))) RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- 1:2 xy <- as.matrix(expand.grid(x, y)) ## we get 4 locations ## Standard use of the nugget effect model <- RMnugget(var = 100) RFcovmatrix(model, x=xy) as.vector(RFsimulate(model, x=x, y=x, tol=1e-10)) ## zonal nugget effect, which is not along the axes model <- RMnugget(Aniso=matrix(1, nr=2, nc=2)) RFcovmatrix(model, x=xy) as.vector(RFsimulate(model, x=x, y=x, tol=1e-10)) ## All the following examples refer to repeated measurements RFoptions(allow_duplicated_locations = TRUE) (xy <- rbind(xy, xy)) ## now, the 4 locations are repeated twice ## standard situation: the nugget is interpreted as measurement error: model <- RMnugget() RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy)) ## any anisotropy matrix with full rank: spatial nugget effect model <- RMnugget(Aniso=diag(2)) RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy)) ## anisotropy matrix with lower rank: zonal nugget effect model <- RMnugget(Aniso=matrix(c(1, 0, 0, 0), nc=2)) RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy)) ## same as before: zonal nugget effect model <- RMnugget(Aniso=t(c(1,0))) RFcovmatrix(model, x=xy) as.matrix(RFsimulate(model, x=xy))
These functions are internal and should not be used.
rfGenerateModels(package = "RandomFields", assigning, RFpath ="~/svn/RandomFields/RandomFields", RMmodels.file=paste(RFpath, "R/RMmodels.R", sep="/"), PL = RFoptions()$basic$printlevel) rfGenerateConstants(package="RandomFields", aux.package = "RandomFieldsUtils", RFpath = paste0("~/svn/",package, "/", package), RCauto.file = paste(RFpath, "R/aaa_auto.R", sep="/"), header.source = c(if (length(aux.package) > 0) paste0("../../", aux.package,"/", aux.package, "/src/Auto", aux.package, ".h"), paste0("src/Auto",package,".h")), c.source = paste0("src/Auto", package, ".cc")) rfGenerateTest(package = "RandomFields", files = NULL, RFpath = paste0("~/svn/", package, "/", package)) rfGenerateMaths(package = "RandomFields", files = "/usr/include/tgmath.h", do.cfile = FALSE, ## copy also in ../private/lit Cfile = "QMath", Rfile = "RQmodels", RFpath = paste0("~/svn/",package,"/", package)) checkExamples(exclude = NULL, include=1:length(.fct.list), ask=FALSE, echo=TRUE, halt=FALSE, ignore.all = FALSE, path=package, package = "RandomFields", read.rd.files=TRUE, local = TRUE, libpath = NULL, single.runs = FALSE) ScreenDevice(height, width) FinalizeExample() StartExample(reduced = TRUE, save.seed = TRUE) showManpages(path="/home/schlather/svn/RandomFields/RandomFields/man") plotWithCircles(data, factor=1.0, xlim=range(data[,1])+c(-maxr,maxr), ylim=range(data[,2])+c(-maxr,maxr), col=1, fill=0, ...) maintainers.machine()
rfGenerateModels(package = "RandomFields", assigning, RFpath ="~/svn/RandomFields/RandomFields", RMmodels.file=paste(RFpath, "R/RMmodels.R", sep="/"), PL = RFoptions()$basic$printlevel) rfGenerateConstants(package="RandomFields", aux.package = "RandomFieldsUtils", RFpath = paste0("~/svn/",package, "/", package), RCauto.file = paste(RFpath, "R/aaa_auto.R", sep="/"), header.source = c(if (length(aux.package) > 0) paste0("../../", aux.package,"/", aux.package, "/src/Auto", aux.package, ".h"), paste0("src/Auto",package,".h")), c.source = paste0("src/Auto", package, ".cc")) rfGenerateTest(package = "RandomFields", files = NULL, RFpath = paste0("~/svn/", package, "/", package)) rfGenerateMaths(package = "RandomFields", files = "/usr/include/tgmath.h", do.cfile = FALSE, ## copy also in ../private/lit Cfile = "QMath", Rfile = "RQmodels", RFpath = paste0("~/svn/",package,"/", package)) checkExamples(exclude = NULL, include=1:length(.fct.list), ask=FALSE, echo=TRUE, halt=FALSE, ignore.all = FALSE, path=package, package = "RandomFields", read.rd.files=TRUE, local = TRUE, libpath = NULL, single.runs = FALSE) ScreenDevice(height, width) FinalizeExample() StartExample(reduced = TRUE, save.seed = TRUE) showManpages(path="/home/schlather/svn/RandomFields/RandomFields/man") plotWithCircles(data, factor=1.0, xlim=range(data[,1])+c(-maxr,maxr), ylim=range(data[,2])+c(-maxr,maxr), col=1, fill=0, ...) maintainers.machine()
package , assigning , RFpath , RMmodels.file , PL
|
internal |
aux.package , RCauto.file , header.source , c.source
|
internal |
files |
internal |
Cfile , Rfile , do.cfile
|
internal |
exclude , include , ask , echo , halt , ignore.all , path , read.rd.files , libpath , single.runs
|
internal;
ignore.all refers to the ‘all’ export statement in the
namespace – whether this should be ignored.
If |
height , width
|
window sizes |
data , factor , xlim , ylim , col , fill , ...
|
internal |
reduced , save.seed , local
|
internal |
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## internal functions: no examples given # for (i in dep.packages) cat(maintainer(i), "\n")
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## internal functions: no examples given # for (i in dep.packages) cat(maintainer(i), "\n")
Here, the code of the paper on ‘Analysis, simulation and prediction of multivariate random fields with package RandomFields’ is given.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package RandomFields. Journal of Statistical Software, 63 (8), 1-25, url = ‘http://www.jstatsoft.org/v63/i08/’
## Not run: ########################################### ## SECTION 4: UNCONDITIONAL SIMULATION ## ########################################### RFoptions(seed = 0, height = 4) ## seed=0: *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## height : height of X11 ## always_close_device=FALSE: the pictures are kept on the screen ## Fig. 1: linear model of coregionalization M1 <- c(0.9, 0.6) M2 <- c(sqrt(0.19), 0.8) model <- RMmatrix(M = M1, RMwhittle(nu = 0.3)) + RMmatrix(M = M2, RMwhittle(nu = 2)) x <- y <- seq(-10, 10, 0.2) simu <- RFsimulate(model, x, y) plot(simu) ## Fig. 2: Wackernagel's delay model model <- RMdelay(RMstable(alpha = 1.9, scale = 2), s = c(4, 4)) simu <- RFsimulate(model, x, y) plot(simu, zlim = 'joint') ## Fig. 3: extended Wackernagel's delay model model <- RMdelay(RMstable(alpha = 1.9, scale = 2), s = c(0, 4)) + RMdelay(RMstable(alpha = 1.9, scale = 2), s = c(4, 0)) simu <- RFsimulate(model, x, y) plot(simu, zlim = 'joint') plot(model, dim = 2, xlim = c(-5, 5), main = "Covariance function", cex = 1.5, col = "brown") ## Fig. 4: latent dimension model ## MARGIN.slices has the effect of choosing the third dimension ## as latent dimension ## n.slices has the effect of choosing a bivariate model model <- RMgencauchy(alpha = 1.5, beta = 3) simu <- RFsimulate(model, x, y, z = c(0,1)) plot(simu, MARGIN.slices = 3, n.slices = 2) ## Fig. 5: Gneiting's bivariate Whittle-Matern model model <- RMbiwm(nudiag = c(1, 2), nured = 1, rhored = 1, cdiag = c(1, 5), s = c(1, 1, 2)) simu <- RFsimulate(model, x, y) plot(simu) ## Fig. 6: anisotropic linear model of coregionalization M1 <- c(0.9, 0.6) M2 <- c(sqrt(0.19), 0.8) A1 <- RMangle(angle = pi/4, diag = c(0.1, 0.5)) A2 <- RMangle(angle = 0, diag = c(0.1, 0.5)) model <- RMmatrix(M = M1, RMgengneiting(kappa = 0, mu = 2, Aniso = A1)) + RMmatrix(M = M2, RMgengneiting(kappa = 3, mu = 2, Aniso = A2)) simu <- RFsimulate(model, x, y) plot(simu) ## Fig. 7: random vector field whose paths are curl free ## A 4-variate field is simulated, where the first component ## refers to the potential field, the second and third component ## to the curl free vector field and the forth component to the ## field of sinks and sources model <- RMcurlfree(RMmatern(nu = 5), scale = 4) simu <- RFsimulate(model, x, y) plot(simu, select.variables = list(1, 2 : 3, 4)) plot(model, dim = 2, xlim = c(-3, 3), main = "", cex = 2.3, col="brown") ## Fig. 8: Kolmogorov's model of turbulence ## See the physical literature for its derivation and details x <- y <- seq(-2, 2, len = 20) model <- RMkolmogorov() simu <- RFsimulate(model, x, y, z = 1) plot(simu, select.variables = list(1 : 2), col = c("red")) plot(model, dim = 3, xlim = c(-3, 3), MARGIN = 1 : 2, cex = 2.3, fixed.MARGIN = 1.0, main = "", col = "brown") ########################################### ## SECTION 5: DATA ANALYSIS ## ########################################### ## get the data data("weather") PT <- weather[ , 1 : 2] ## full data set takes more than ## half an hour to be analysed ## transformation of earth coordinates to Euclidean coordinates Dist.mat <- as.vector(RFearth2dist(weather[ , 3 : 4])) All <- TRUE \dontshow{if(RFoptions()$internal$examples_reduced){warning("reduced data set") All <- 1:10 PT <- weather[All , 1 : 2] Dist.mat <- as.vector(RFearth2dist(weather[All , 3 : 4])) }} ################################# ## model definition ## ################################# ## bivariate pure nugget effect: nug <- RMmatrix(M = matrix(nc = 2, c(NA, 0, 0, NA)), RMnugget()) ## parsimonious bivariate Matern model pars.model <- nug + RMbiwm(nudiag = c(NA, NA), scale = NA, cdiag = c(NA, NA), rhored = NA) ## whole bivariate Matern model whole.model <- nug + RMbiwm(nudiag = c(NA, NA), nured = NA, s = rep(NA, 3), cdiag = c(NA, NA), rhored = NA) ################################# ## model fitting and testing ## ################################# ## 'parsimonious model' ## fitting takes a while ( > 10 min) pars <- RFfit(pars.model, distances = Dist.mat, dim = 3, data = PT) print(pars) print(pars, full=TRUE) RFratiotest(pars) #RFcrossvalidate(pars, x = weather[All , 3 : 4], data = PT, full = TRUE) ## 'whole model' ## fitting takes a while ( > 10 min) whole <- RFfit(whole.model, distances = Dist.mat, dim = 3, data = PT) print(whole, full=TRUE) RFratiotest(whole) #RFcrossvalidate(whole, x = weather[All , 3 : 4], data = PT, full = TRUE) ## compare parsimonious and whole RFratiotest(nullmodel = pars, alternative = whole) ################################# ## kriging ## ################################# ## First, the coordinates are projected on a plane a <- colMeans(weather[All , 3 : 4]) * pi / 180 P <- cbind(c(-sin(a[1]), cos(a[1]), 0), c(-cos(a[1]) * sin(a[2]), -sin(a[1]) * sin(a[2]), cos(a[2])), c(cos(a[1]) * cos(a[2]), sin(a[1]) * cos(a[2]), sin(a[2]))) x <- RFearth2cartesian(weather[All , 3 : 4]) plane <- (t(x) %*%P)[ , 1 : 2] ## here, kriging is performed on a rectangular that covers ## the projected points above. The rectangular is approximated ## by a grid of length 200 in each direction. n <- 200 r <- apply(plane, 2, range) dta <- cbind(plane, weather[All , 1 : 2]) z <- RFinterpolate(pars, data = dta, dim = 2, x = seq(r[1, 1], r[2, 1], length = n), y = seq(r[1, 2], r[2, 2], length = n), varunits = c("Pa", "K"), spConform = TRUE) plot(z) ## End(Not run)
## Not run: ########################################### ## SECTION 4: UNCONDITIONAL SIMULATION ## ########################################### RFoptions(seed = 0, height = 4) ## seed=0: *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## height : height of X11 ## always_close_device=FALSE: the pictures are kept on the screen ## Fig. 1: linear model of coregionalization M1 <- c(0.9, 0.6) M2 <- c(sqrt(0.19), 0.8) model <- RMmatrix(M = M1, RMwhittle(nu = 0.3)) + RMmatrix(M = M2, RMwhittle(nu = 2)) x <- y <- seq(-10, 10, 0.2) simu <- RFsimulate(model, x, y) plot(simu) ## Fig. 2: Wackernagel's delay model model <- RMdelay(RMstable(alpha = 1.9, scale = 2), s = c(4, 4)) simu <- RFsimulate(model, x, y) plot(simu, zlim = 'joint') ## Fig. 3: extended Wackernagel's delay model model <- RMdelay(RMstable(alpha = 1.9, scale = 2), s = c(0, 4)) + RMdelay(RMstable(alpha = 1.9, scale = 2), s = c(4, 0)) simu <- RFsimulate(model, x, y) plot(simu, zlim = 'joint') plot(model, dim = 2, xlim = c(-5, 5), main = "Covariance function", cex = 1.5, col = "brown") ## Fig. 4: latent dimension model ## MARGIN.slices has the effect of choosing the third dimension ## as latent dimension ## n.slices has the effect of choosing a bivariate model model <- RMgencauchy(alpha = 1.5, beta = 3) simu <- RFsimulate(model, x, y, z = c(0,1)) plot(simu, MARGIN.slices = 3, n.slices = 2) ## Fig. 5: Gneiting's bivariate Whittle-Matern model model <- RMbiwm(nudiag = c(1, 2), nured = 1, rhored = 1, cdiag = c(1, 5), s = c(1, 1, 2)) simu <- RFsimulate(model, x, y) plot(simu) ## Fig. 6: anisotropic linear model of coregionalization M1 <- c(0.9, 0.6) M2 <- c(sqrt(0.19), 0.8) A1 <- RMangle(angle = pi/4, diag = c(0.1, 0.5)) A2 <- RMangle(angle = 0, diag = c(0.1, 0.5)) model <- RMmatrix(M = M1, RMgengneiting(kappa = 0, mu = 2, Aniso = A1)) + RMmatrix(M = M2, RMgengneiting(kappa = 3, mu = 2, Aniso = A2)) simu <- RFsimulate(model, x, y) plot(simu) ## Fig. 7: random vector field whose paths are curl free ## A 4-variate field is simulated, where the first component ## refers to the potential field, the second and third component ## to the curl free vector field and the forth component to the ## field of sinks and sources model <- RMcurlfree(RMmatern(nu = 5), scale = 4) simu <- RFsimulate(model, x, y) plot(simu, select.variables = list(1, 2 : 3, 4)) plot(model, dim = 2, xlim = c(-3, 3), main = "", cex = 2.3, col="brown") ## Fig. 8: Kolmogorov's model of turbulence ## See the physical literature for its derivation and details x <- y <- seq(-2, 2, len = 20) model <- RMkolmogorov() simu <- RFsimulate(model, x, y, z = 1) plot(simu, select.variables = list(1 : 2), col = c("red")) plot(model, dim = 3, xlim = c(-3, 3), MARGIN = 1 : 2, cex = 2.3, fixed.MARGIN = 1.0, main = "", col = "brown") ########################################### ## SECTION 5: DATA ANALYSIS ## ########################################### ## get the data data("weather") PT <- weather[ , 1 : 2] ## full data set takes more than ## half an hour to be analysed ## transformation of earth coordinates to Euclidean coordinates Dist.mat <- as.vector(RFearth2dist(weather[ , 3 : 4])) All <- TRUE \dontshow{if(RFoptions()$internal$examples_reduced){warning("reduced data set") All <- 1:10 PT <- weather[All , 1 : 2] Dist.mat <- as.vector(RFearth2dist(weather[All , 3 : 4])) }} ################################# ## model definition ## ################################# ## bivariate pure nugget effect: nug <- RMmatrix(M = matrix(nc = 2, c(NA, 0, 0, NA)), RMnugget()) ## parsimonious bivariate Matern model pars.model <- nug + RMbiwm(nudiag = c(NA, NA), scale = NA, cdiag = c(NA, NA), rhored = NA) ## whole bivariate Matern model whole.model <- nug + RMbiwm(nudiag = c(NA, NA), nured = NA, s = rep(NA, 3), cdiag = c(NA, NA), rhored = NA) ################################# ## model fitting and testing ## ################################# ## 'parsimonious model' ## fitting takes a while ( > 10 min) pars <- RFfit(pars.model, distances = Dist.mat, dim = 3, data = PT) print(pars) print(pars, full=TRUE) RFratiotest(pars) #RFcrossvalidate(pars, x = weather[All , 3 : 4], data = PT, full = TRUE) ## 'whole model' ## fitting takes a while ( > 10 min) whole <- RFfit(whole.model, distances = Dist.mat, dim = 3, data = PT) print(whole, full=TRUE) RFratiotest(whole) #RFcrossvalidate(whole, x = weather[All , 3 : 4], data = PT, full = TRUE) ## compare parsimonious and whole RFratiotest(nullmodel = pars, alternative = whole) ################################# ## kriging ## ################################# ## First, the coordinates are projected on a plane a <- colMeans(weather[All , 3 : 4]) * pi / 180 P <- cbind(c(-sin(a[1]), cos(a[1]), 0), c(-cos(a[1]) * sin(a[2]), -sin(a[1]) * sin(a[2]), cos(a[2])), c(cos(a[1]) * cos(a[2]), sin(a[1]) * cos(a[2]), sin(a[2]))) x <- RFearth2cartesian(weather[All , 3 : 4]) plane <- (t(x) %*%P)[ , 1 : 2] ## here, kriging is performed on a rectangular that covers ## the projected points above. The rectangular is approximated ## by a grid of length 200 in each direction. n <- 200 r <- apply(plane, 2, range) dta <- cbind(plane, weather[All , 1 : 2]) z <- RFinterpolate(pars, data = dta, dim = 2, x = seq(r[1, 1], r[2, 1], length = n), y = seq(r[1, 2], r[2, 2], length = n), varunits = c("Pa", "K"), spConform = TRUE) plot(z) ## End(Not run)
This man page documents some major changings in RandomFields.
full (univariate) trend modelling
error in particular in RFfit
corrected
RFfit
runs much faster now
effects of modus operandi
changed for estimating
log Gauss field corrected (has been a log log Gauss field)
RMconstant
is now called RMfixcov
Conditional simulation: several severe typos corrected.
S4 objects
RandomFields is now based on S4 objects using the package sp. The functions accept both sp objects and simple objects as used in version 2. See also above.
Documentation
each model has now its own man page;
classes of models and functions are bundled in several pages:
Covariance models start with RM
, distribution families
with RR
, processes with RP
, user
functions with RF
the man pages of several functions are split into two parts:
(i) a beginners man page which includes a link to
(ii) man pages for advanced users
Interfaces
The interfaces become simpler, at the same time more powerful
than the functions in version 2. E.g., RFsimulate
can perform
unconditional simulation, conditional simulation and random
imputing.
Only those arguments are kept in the functions that are considered as being absolutely necessary. All the other arguments can be included as options.
RFgui
is an instructive interface based on tcl/tk,
replacing the former ShowModels
Inference for Gaussian random fields
RFfit
has undergone a major revision. E.g.:
(i) estimation of random effect models with spatial covariance structure
(ii) automatic estimation of 10 and more arguments in multivariate and/or space-time models
RFvariogram
is now based on an fft algorithm
if the data are on a grid, even allowing for missing values.
RFratiotest
has been added.
Processes
Modelling of maxstable processes has been enhanced, including
(i) the simulation of Brown-Resnick processes
(ii) initial support of tail correlation functions;
Further processes chi2 processes, compound Poisson processes, binary processes added.
Models
the formula notation for linear models may now be defined
Novel, user friendly definition of the covariance models
Multivariate and vector-valued random fields are now fully included
The user may now define his own functions, to some extend.
The trend allows for much more flexibility
Distributions may now be included which will be extended to Bayesian modelling in future.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## S4 vs S3 x <- seq(0, 10, 0.1) model <- RMexp() plot(RFsimulate(model, x)) ## S4 plot(RFsimulate(model, x, spConform=FALSE)) ## no class
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## S4 vs S3 x <- seq(0, 10, 0.1) model <- RMexp() plot(RFsimulate(model, x)) ## S4 plot(RFsimulate(model, x, spConform=FALSE)) ## no class
The functions provide mathematical c functions as RMmodels
RFcalc(model, params, ...) R.minus(x, y, factor) R.plus(x, y, factor) R.div(x, y, factor) R.mult(x, y, factor) R.const(x) R.c(a, b, c, d, e, f, g, h, i, j, l, m, n, o, p, q, ncol, factor) R.p(proj, new, factor) R.is(x, is, y) R.lon() R.lat() R.gamma(x) R.acos(x) R.asin(x) R.atan(x) R.atan2(y, x) R.cos(x) R.sin(x) R.tan(x) R.acosh(x) R.asinh(x) R.atanh(x) R.cosh(x) R.sinh(x) R.tanh(x) R.exp(x) R.log(x) R.expm1(x) R.log1p(x) R.exp2(x) R.log2(x) R.pow(x, y) R.sqrt(x) R.hypot(x, y) R.cbrt(x) R.ceil(x) R.fabs(x) R.floor(x) R.fmod(x, y) R.round(x) R.trunc(x) R.erf(x) R.erfc(x) R.lgamma(x) R.remainder(x, y) R.fdim(x, y) R.fmax(x, y) R.fmin(x, y) ## S4 method for signature 'ANY,RMmodel' e1 %% e2 ## S4 method for signature 'RMmodel,ANY' e1 %% e2 ## S4 method for signature 'RMmodel,character' e1 * e2 ## S4 method for signature 'character,RMmodel' e1 * e2 ## S4 method for signature 'RMmodel,character' e1 + e2 ## S4 method for signature 'RMmodel,factor' e1 + e2 ## S4 method for signature 'RMmodel,list' e1 + e2 ## S4 method for signature 'character,RMmodel' e1 + e2 ## S4 method for signature 'data.frame,RMmodel' e1 + e2 ## S4 method for signature 'factor,RMmodel' e1 + e2 ## S4 method for signature 'RMmodel,character' e1 - e2 ## S4 method for signature 'character,RMmodel' e1 - e2 ## S4 method for signature 'RMmodel,character' e1 / e2 ## S4 method for signature 'character,RMmodel' e1 / e2 ## S4 method for signature 'ANY,RMmodel' e1 ^ e2 ## S4 method for signature 'RMmodel,ANY' e1 ^ e2 ## S4 method for signature 'RMmodel,character' e1 ^ e2 ## S4 method for signature 'character,RMmodel' e1 ^ e2 ## S4 method for signature 'RMmodel' abs(x) ## S4 method for signature 'RMmodel' acosh(x) ## S4 method for signature 'RMmodel' asin(x) ## S4 method for signature 'RMmodel' asinh(x) ## S4 method for signature 'ANY,RMmodel' atan2(y,x) ## S4 method for signature 'RMmodel,ANY' atan2(y,x) ## S4 method for signature 'RMmodel' atan(x) ## S4 method for signature 'RMmodel' atanh(x) ## S4 method for signature 'RMmodel' ceiling(x) ## S4 method for signature 'RMmodel' cos(x) ## S4 method for signature 'RMmodel' cosh(x) ## S4 method for signature 'RMmodel' exp(x) ## S4 method for signature 'RMmodel' expm1(x) ## S4 method for signature 'RMmodel' floor(x) ## S4 method for signature 'RMmodel' lgamma(x) ## S4 method for signature 'RMmodel' log1p(x) ## S4 method for signature 'RMmodel' log2(x) ## S4 method for signature 'RMmodel' log(x) ## S4 method for signature 'RMmodel,missing' round(x,digits) ## S4 method for signature 'RMmodel' sin(x) ## S4 method for signature 'RMmodel' sinh(x) ## S4 method for signature 'RMmodel' sqrt(x) ## S4 method for signature 'RMmodel' tan(x) ## S4 method for signature 'RMmodel' tanh(x) ## S4 method for signature 'RMmodel' trunc(x)
RFcalc(model, params, ...) R.minus(x, y, factor) R.plus(x, y, factor) R.div(x, y, factor) R.mult(x, y, factor) R.const(x) R.c(a, b, c, d, e, f, g, h, i, j, l, m, n, o, p, q, ncol, factor) R.p(proj, new, factor) R.is(x, is, y) R.lon() R.lat() R.gamma(x) R.acos(x) R.asin(x) R.atan(x) R.atan2(y, x) R.cos(x) R.sin(x) R.tan(x) R.acosh(x) R.asinh(x) R.atanh(x) R.cosh(x) R.sinh(x) R.tanh(x) R.exp(x) R.log(x) R.expm1(x) R.log1p(x) R.exp2(x) R.log2(x) R.pow(x, y) R.sqrt(x) R.hypot(x, y) R.cbrt(x) R.ceil(x) R.fabs(x) R.floor(x) R.fmod(x, y) R.round(x) R.trunc(x) R.erf(x) R.erfc(x) R.lgamma(x) R.remainder(x, y) R.fdim(x, y) R.fmax(x, y) R.fmin(x, y) ## S4 method for signature 'ANY,RMmodel' e1 %% e2 ## S4 method for signature 'RMmodel,ANY' e1 %% e2 ## S4 method for signature 'RMmodel,character' e1 * e2 ## S4 method for signature 'character,RMmodel' e1 * e2 ## S4 method for signature 'RMmodel,character' e1 + e2 ## S4 method for signature 'RMmodel,factor' e1 + e2 ## S4 method for signature 'RMmodel,list' e1 + e2 ## S4 method for signature 'character,RMmodel' e1 + e2 ## S4 method for signature 'data.frame,RMmodel' e1 + e2 ## S4 method for signature 'factor,RMmodel' e1 + e2 ## S4 method for signature 'RMmodel,character' e1 - e2 ## S4 method for signature 'character,RMmodel' e1 - e2 ## S4 method for signature 'RMmodel,character' e1 / e2 ## S4 method for signature 'character,RMmodel' e1 / e2 ## S4 method for signature 'ANY,RMmodel' e1 ^ e2 ## S4 method for signature 'RMmodel,ANY' e1 ^ e2 ## S4 method for signature 'RMmodel,character' e1 ^ e2 ## S4 method for signature 'character,RMmodel' e1 ^ e2 ## S4 method for signature 'RMmodel' abs(x) ## S4 method for signature 'RMmodel' acosh(x) ## S4 method for signature 'RMmodel' asin(x) ## S4 method for signature 'RMmodel' asinh(x) ## S4 method for signature 'ANY,RMmodel' atan2(y,x) ## S4 method for signature 'RMmodel,ANY' atan2(y,x) ## S4 method for signature 'RMmodel' atan(x) ## S4 method for signature 'RMmodel' atanh(x) ## S4 method for signature 'RMmodel' ceiling(x) ## S4 method for signature 'RMmodel' cos(x) ## S4 method for signature 'RMmodel' cosh(x) ## S4 method for signature 'RMmodel' exp(x) ## S4 method for signature 'RMmodel' expm1(x) ## S4 method for signature 'RMmodel' floor(x) ## S4 method for signature 'RMmodel' lgamma(x) ## S4 method for signature 'RMmodel' log1p(x) ## S4 method for signature 'RMmodel' log2(x) ## S4 method for signature 'RMmodel' log(x) ## S4 method for signature 'RMmodel,missing' round(x,digits) ## S4 method for signature 'RMmodel' sin(x) ## S4 method for signature 'RMmodel' sinh(x) ## S4 method for signature 'RMmodel' sqrt(x) ## S4 method for signature 'RMmodel' tan(x) ## S4 method for signature 'RMmodel' tanh(x) ## S4 method for signature 'RMmodel' trunc(x)
model , params
|
object of class |
e1 , e2 , x , y , a , b , c , d , e , f , g , h , i , j , l , m , n , o , p , q
|
constant or object of class
|
ncol |
in contrast to c, |
factor |
constant factor multiplied with the function. This is useful when linear models are built |
is |
one of |
proj |
selection of a component of the vector giving the location. Default value is 1. |
new |
coordinate system or other
|
digits |
number of digits. Does not work with a RMmodel |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
adds two values
substracts two values
multiplies two values
devides two values
defines a constant
builds a vector
evaluates equalities and inequalities;
note that TRUE
is returned if the equality or
inequality holds up to a tolerance given by
RFoptions()$nugget$tol
takes a component out of the vector giving the location
longitudinal and latitudinal coordinate, given in the spherical system, i.e. in radians. (earth system is in degrees).
Note that R.round
rounds away from zero.
For the remaining models see the corresponding C functions for their return value. (For any ‘R.model’ type ‘man model’ under Linux.)
Formally, the functions return an object of class
RMmodel
, except for
RFcalc
that returns a scalar.
Neither vectors nor parentheses are allowed.
Instead of R.model
the standard function can be used in case
there is no ambiguity, i.e.,
c(...)
,asin(x)
, atan(x)
, atan2(y, x)
, cos(x)
,
sin(x)
, tan(x)
, acosh(x)
, asinh(x)
,
atanh(x)
, cosh(x)
, sinh(x)
, tanh(x)
,
exp(x)
, log(x)
, expm1(x)
, log2(x)
,
log1p(x)
, exp2(x)
, ^
, sqrt(x)
,
hypot(a,b)
, cbrt(x)
, ceiling(x)
, abs(x)
,
floor(x)
, round(x)
, trunc(x)
,
erf(x)
, erfc(x)
, lgamma(x)
. See the examples
below.
The function RFcalc
is intended for simple calculations only
and it is not excessively tested. Especially, binary
operators should be used with caution.
Note that all the functions here are NOT recognized as being
positive definite (or negative definite), e.g. cos
in
:
please use the functions given in RMmodels
for definite functions (for cos
see RMbessel
)
Using uncapsulated substraction to build up a covariance
function is ambiguous, see the example in RMtrend
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## simple calculation RFcalc(3 + R.sin(pi/4)) ## calculation performed on a field RFfctn(R.p(1) + R.p(2), 1:3, 1:3) RFfctn(10 + R.p(2), 1:3, 1:3) ## calculate the distances between two vectors print(RFfctn(R.p(new="iso"), 1:10, 1:10)) ## simulation of a non-stationary field where ## anisotropy by a transform the coordinates (x_1^2, x_2^1.5) x <- seq(0.1, 6, 0.12) Aniso <- R.c(R.p(1)^2, R.p(2)^1.5) z <- RFsimulate(RMexp(Aniso=Aniso), x, x) ## calculating norms can be abbreviated: x <- seq(-5, 5, 5) #0.1) z2 <- RFsimulate(RMexp() + -40 + exp(0.5 * R.p(new="isotropic")), x, x) z1 <- RFsimulate(RMexp() + -40 + exp(0.5 * sqrt(R.p(1)^2 + R.p(2)^2)), x, x) stopifnot(all.equal(z1, z2)) plot(z1)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## simple calculation RFcalc(3 + R.sin(pi/4)) ## calculation performed on a field RFfctn(R.p(1) + R.p(2), 1:3, 1:3) RFfctn(10 + R.p(2), 1:3, 1:3) ## calculate the distances between two vectors print(RFfctn(R.p(new="iso"), 1:10, 1:10)) ## simulation of a non-stationary field where ## anisotropy by a transform the coordinates (x_1^2, x_2^1.5) x <- seq(0.1, 6, 0.12) Aniso <- R.c(R.p(1)^2, R.p(2)^1.5) z <- RFsimulate(RMexp(Aniso=Aniso), x, x) ## calculating norms can be abbreviated: x <- seq(-5, 5, 5) #0.1) z2 <- RFsimulate(RMexp() + -40 + exp(0.5 * R.p(new="isotropic")), x, x) z1 <- RFsimulate(RMexp() + -40 + exp(0.5 * sqrt(R.p(1)^2 + R.p(2)^2)), x, x) stopifnot(all.equal(z1, z2)) plot(z1)
Here, a list of models and methods for simulating max-stable random fields is given.
See also maxstableAdvanced for more advanced examples.
Models
RPbrownresnick |
Brown-Resnick process
using an automatic choice of the 3 RPbr* methods below |
RPopitz |
extremal t process |
RPschlather |
extremal Gaussian process |
RPsmith |
M3 processes |
Methods
RPbrmixed |
simulation of Brown-Resnick processes using M3 representation |
RPbrorig |
simulation of Brown-Resnick processes using the original definition |
RPbrshifted |
simulation of Brown-Resnick processes using a random shift |
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Kabluchko, Z., Schlather, M. & de Haan, L (2009) Stationary max-stable random fields associated to negative definite functions Ann. Probab. 37, 2042-2065.
Schlather, M. (2002) Models for stationary max-stable random fields. Extremes 5, 33-44.
Smith, R.L. (1990) Max-stable processes and spatial extremes Unpublished Manuscript.
RP,
RMmodel
,
RPgauss
,
RPbernoulli
,
maxstableAdvanced
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ### currently not programmed ## Not run: \dontshow{ ## to do : seq(0, 10, 0.02) oben ist furchtbar langsam. Warum? } ## End(Not run) ## Not run: \dontshow{ model <- RMball() x <- seq(0, 10, 5) # nice for x <- seq(0, 10, 0.02) z <- RFsimulate(RPsmith(model, xi=0), x, n=1000, every=1000) plot(z) hist(unlist(z@data), 150, freq=FALSE) #not correct; to do; sqrt(2) wrong curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE, col=3) } ## End(Not run) model <- RMgauss() x <- seq(0, 10, 0.05) z <- RFsimulate(RPschlather(model, xi=0), x, n=1000) plot(z) hist(unlist(z@data), 50, freq=FALSE) curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE) ## for some more sophisticated models see maxstableAdvanced
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ### currently not programmed ## Not run: \dontshow{ ## to do : seq(0, 10, 0.02) oben ist furchtbar langsam. Warum? } ## End(Not run) ## Not run: \dontshow{ model <- RMball() x <- seq(0, 10, 5) # nice for x <- seq(0, 10, 0.02) z <- RFsimulate(RPsmith(model, xi=0), x, n=1000, every=1000) plot(z) hist(unlist(z@data), 150, freq=FALSE) #not correct; to do; sqrt(2) wrong curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE, col=3) } ## End(Not run) model <- RMgauss() x <- seq(0, 10, 0.05) z <- RFsimulate(RPschlather(model, xi=0), x, n=1000) plot(z) hist(unlist(z@data), 50, freq=FALSE) curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE) ## for some more sophisticated models see maxstableAdvanced
Here, an advanced example is given used to test whether the algorithms work correctly.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Strokorb, K. (2013) Ph.D. thesis.
This part gives the obsolete functions of RandomFields Version 2 that are not maintained anymore.
Covariance(x, y = NULL, model, param = NULL, dim = NULL, Distances, fctcall = c("Cov", "Variogram", "CovMatrix")) CovarianceFct(x, y = NULL, model, param = NULL, dim =NULL, Distances, fctcall = c("Cov", "Variogram", "CovMatrix")) CovMatrix(x, y = NULL, model, param = NULL, dim = NULL, Distances) DeleteAllRegisters() DeleteRegister(nr=0) DoSimulateRF(n = 1, register = 0, paired=FALSE, trend=NULL) InitSimulateRF(x, y = NULL, z = NULL, T=NULL, grid=!missing(gridtriple), model, param, trend, method = NULL, register = 0, gridtriple, distribution=NA) InitGaussRF(x, y = NULL, z = NULL, T=NULL, grid=!missing(gridtriple), model, param, trend=NULL, method = NULL, register = 0, gridtriple) GaussRF(x, y = NULL, z = NULL, T=NULL, grid=!missing(gridtriple), model, param, trend=NULL, method = NULL, n = 1, register = 0, gridtriple, paired=FALSE, PrintLevel=1, Storing=TRUE, ...) Variogram(x, model, param = NULL, dim = NULL, Distances) InitMaxStableRF(x, y = NULL, z = NULL, grid=NULL, model, param, maxstable, method = NULL, register = 0, gridtriple = FALSE) MaxStableRF(x, y = NULL, z = NULL, grid=NULL, model, param, maxstable, method = NULL, n = 1, register = 0, gridtriple = FALSE, ...) EmpiricalVariogram(x, y = NULL, z = NULL, T=NULL, data, grid=NULL, bin, gridtriple = FALSE, phi, theta, deltaT) Kriging(krige.method, x, y=NULL, z=NULL, T=NULL, grid=NULL, gridtriple=FALSE, model, param, given, data, trend=NULL,pch=".", return.variance=FALSE, allowdistanceZero = FALSE, cholesky=FALSE) CondSimu(krige.method, x, y=NULL, z=NULL, T=NULL, grid=NULL, gridtriple=FALSE, model, param, method=NULL, given, data, trend=NULL, n=1, register=0, err.model=NULL, err.param=NULL, err.method=NULL, err.register=1, tol=1E-5, pch=".", paired=FALSE, na.rm=FALSE) RFparameters(...) hurst(x, y = NULL, z = NULL, data, gridtriple = FALSE, sort=TRUE, block.sequ = unique(round(exp(seq(log(min(3000, dim[1] / 5)), log(dim[1]), len=min(100, dim[1]))))), fft.m = c(1, min(1000, (fft.len - 1) / 10)), fft.max.length = Inf, method=c("dfa", "fft", "var"), mode=c("plot", "interactive"), pch=16, cex=0.2, cex.main=0.85, PrintLevel=RFoptions()$basic$printlevel,height=3.5, ...) fractal.dim(x, y = NULL, z = NULL, data, grid=TRUE, gridtriple = FALSE, bin, vario.n=5, sort=TRUE, fft.m = c(65, 86), fft.max.length=Inf, fft.max.regr=150000, fft.shift = 50, method=c("variogram", "fft"), mode=c("plot", "interactive"), pch=16, cex=0.2, cex.main=0.85, PrintLevel = RFoptions()$basic$printlevel, height=3.5, ...) fitvario(x, y=NULL, z=NULL, T=NULL, data, model, param, lower=NULL, upper=NULL, sill=NA, grid=!missing(gridtriple), gridtriple=FALSE, ...)
Covariance(x, y = NULL, model, param = NULL, dim = NULL, Distances, fctcall = c("Cov", "Variogram", "CovMatrix")) CovarianceFct(x, y = NULL, model, param = NULL, dim =NULL, Distances, fctcall = c("Cov", "Variogram", "CovMatrix")) CovMatrix(x, y = NULL, model, param = NULL, dim = NULL, Distances) DeleteAllRegisters() DeleteRegister(nr=0) DoSimulateRF(n = 1, register = 0, paired=FALSE, trend=NULL) InitSimulateRF(x, y = NULL, z = NULL, T=NULL, grid=!missing(gridtriple), model, param, trend, method = NULL, register = 0, gridtriple, distribution=NA) InitGaussRF(x, y = NULL, z = NULL, T=NULL, grid=!missing(gridtriple), model, param, trend=NULL, method = NULL, register = 0, gridtriple) GaussRF(x, y = NULL, z = NULL, T=NULL, grid=!missing(gridtriple), model, param, trend=NULL, method = NULL, n = 1, register = 0, gridtriple, paired=FALSE, PrintLevel=1, Storing=TRUE, ...) Variogram(x, model, param = NULL, dim = NULL, Distances) InitMaxStableRF(x, y = NULL, z = NULL, grid=NULL, model, param, maxstable, method = NULL, register = 0, gridtriple = FALSE) MaxStableRF(x, y = NULL, z = NULL, grid=NULL, model, param, maxstable, method = NULL, n = 1, register = 0, gridtriple = FALSE, ...) EmpiricalVariogram(x, y = NULL, z = NULL, T=NULL, data, grid=NULL, bin, gridtriple = FALSE, phi, theta, deltaT) Kriging(krige.method, x, y=NULL, z=NULL, T=NULL, grid=NULL, gridtriple=FALSE, model, param, given, data, trend=NULL,pch=".", return.variance=FALSE, allowdistanceZero = FALSE, cholesky=FALSE) CondSimu(krige.method, x, y=NULL, z=NULL, T=NULL, grid=NULL, gridtriple=FALSE, model, param, method=NULL, given, data, trend=NULL, n=1, register=0, err.model=NULL, err.param=NULL, err.method=NULL, err.register=1, tol=1E-5, pch=".", paired=FALSE, na.rm=FALSE) RFparameters(...) hurst(x, y = NULL, z = NULL, data, gridtriple = FALSE, sort=TRUE, block.sequ = unique(round(exp(seq(log(min(3000, dim[1] / 5)), log(dim[1]), len=min(100, dim[1]))))), fft.m = c(1, min(1000, (fft.len - 1) / 10)), fft.max.length = Inf, method=c("dfa", "fft", "var"), mode=c("plot", "interactive"), pch=16, cex=0.2, cex.main=0.85, PrintLevel=RFoptions()$basic$printlevel,height=3.5, ...) fractal.dim(x, y = NULL, z = NULL, data, grid=TRUE, gridtriple = FALSE, bin, vario.n=5, sort=TRUE, fft.m = c(65, 86), fft.max.length=Inf, fft.max.regr=150000, fft.shift = 50, method=c("variogram", "fft"), mode=c("plot", "interactive"), pch=16, cex=0.2, cex.main=0.85, PrintLevel = RFoptions()$basic$printlevel, height=3.5, ...) fitvario(x, y=NULL, z=NULL, T=NULL, data, model, param, lower=NULL, upper=NULL, sill=NA, grid=!missing(gridtriple), gridtriple=FALSE, ...)
x , y , model , param , dim , Distances , fctcall , n , register , paired , trend , z , T , grid , method , gridtriple , distribution , PrintLevel , Storing , ... , maxstable , data , bin , phi , theta , deltaT , krige.method , pch , return.variance , allowdistanceZero , cholesky , given , err.model , err.param , err.method , err.register , tol , na.rm , sort , block.sequ , fft.m , fft.max.length , mode , cex , cex.main , height , vario.n , fft.max.regr , fft.shift , lower , upper , sill , nr
|
As the functions are obsolete, all these arguments are not documented anymore. |
See ‘version2’ for details on these obsolete commands.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
The functions that should be used instead are, for instance,
RFcov
, RFcovmatrix
,
RFvariogram
, RFsimulate
,
RFinterpolate
,
RFvariogram
, RFfit
,
RFoptions
, RFhurst
,
RFfractaldim
See ‘version2’ for details on the obsolete commands.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## no examples given, as command is obsolete
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## no examples given, as command is obsolete
Some functions of RandomFields Version 3 have been replaced by more powerful functions
RFempiricalvariogram(...) RFempiricalcovariance(...) RFempiricalmadogram(...)
RFempiricalvariogram(...) RFempiricalcovariance(...) RFempiricalmadogram(...)
... |
See for the recent functions given in the Details |
see RFvariogram
see RFcov
see RFmadogram
see the respective recent function
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFcov
,
RFcovmatrix
,
RFvariogram
.
RFpseudovariogram
,
RFmadogram
,
RFpseudomadogram
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## no examples given, as command is obsolete
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## no examples given, as command is obsolete
Here, auxiliary models are given that are not covariance functions or variograms, but which might be used within the definition of a model.
Distribution families See RR.
Evaluation operators See RF.
Random Fields / Random Processes See RP.
Mathematical functions See R.
Shape functions
Besides any of the covariance functions the following functions can be used as shape functions.
RMangle |
defines an anisotropy matrix by angle and a diagonal matrix |
RMball |
Indicator of a ball of radius
|
RMm2r |
spectral function belonging to a
tail correlation function of the Gneiting class
|
RMm3b |
spectral function belonging to a tail
correlation function of the Gneiting class
|
RMmppplus |
operator to define mixed moving maxima (M3) processes |
RMmps |
spectral functions belonging to a tail
correlation function of the Gneiting class
|
RMpolygon |
Indicator of a typical Poisson polygon |
RMrational |
shape function used in the Bernoulli paper given in the references |
RMrotat |
shape function used in the Bernoulli paper given in the references |
RMsign |
random sign |
RMtruncsupport |
truncates the support of a shape in a Poisson based model |
Special transformations
RMeaxxa |
shape function used in the Bernoulli paper given in the references |
RMetaxxa |
shape function used in the Bernoulli paper given in the references |
RMidmodel |
model identity |
RMid |
identity but interpretation turns from a coordinate to a model value |
RMtrafo |
allows to model the identity within the set of coordinates |
RMrotation |
shape function used in the Bernoulli paper given in the references |
Other models
RMuser |
User defined covariance model |
Alexander Malinowski; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames()
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames()
Here, an overview is given over the papers co-authored by M. Schlather that involve RandomFields.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T., Kleiber, W. and Schlather, M. (2010) Matern cross-covariance functions for multivariate random fields J. Amer. Statist. Assoc. 105, 1167-1177.
See GKS11 for the code.
Gneiting, T., Sevcikova, H., Percival, D.B., Schlather, M., Jiang, Y. (2006) Fast and Exact Simulation of Large Gaussian Lattice Systems in R2: Exploring the Limits. J. Comput. Graph. Stat., 15, 483-501.
See GSPSJ06 for the code.
Scheuerer, M. and Schlather, M. (2012) Covariance Models for Random Vector Fields. Stochastic Models, 82, 433-451.
See SS12 for the code.
Schlather, M. (2002) Models for stationary max-stable random fields. Extremes 5, 33-44.
See S02 for the code.
Schlather, M. (2010) On some covariance models based on normal scale mixtures. Bernoulli, 16, 780-797.
See S10 for the code.
Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package RandomFields. Journal of Statistical Software, 63 (8), 1-25, url = ‘http://www.jstatsoft.org/v63/i08/’,
See ‘multivariate_jss’ for the vignette.
Strokorb, K., Ballani, F. and Schlather, M. (2014) In Preparation.
See SBS14 for the code.
weather, GSPSJ06, SS12, S02, S10, jss14.
# For examples, see the specific papers.
# For examples, see the specific papers.
plot
in package RandomFields
Plot methods are implemented for simulated random fields (objects of
class RFsp
), explicit covariance models
(objects of class RMmodel
),
empirical variograms (objects of class
RFempVariog
) and fitted models
(objects of class RFfit
).
The plot methods not described here are described together with the
class itself, for instance,
RFfit
,
RFempVariog
RMmodel
.
RFplotSimulation(x, y, MARGIN=c(1,2), MARGIN.slices=NULL, n.slices = if (is.null(MARGIN.slices)) 1 else 10, nmax=6, plot.variance = !is.null([email protected]$has.variance) && [email protected]$has.variance, select.variables, zlim, legend=TRUE, MARGIN.movie = NULL, file=NULL, speed = 0.3, height.pixel=300, width.pixel=height.pixel, ..., plotmethod="image") RFplotSimulation1D(x, y, nmax=6, plot.variance=!is.null([email protected]$has.variance) && [email protected]$has.variance, legend=TRUE, ...) ## S4 method for signature 'RFgridDataFrame,missing' plot(x, y, ...) ## S4 method for signature 'RFpointsDataFrame,missing' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame,missing' plot(x, y, ...) ## S4 method for signature 'RFspatialPointsDataFrame,missing' plot(x, y, ...) ## S4 method for signature 'RFgridDataFrame,matrix' plot(x, y, ...) ## S4 method for signature 'RFpointsDataFrame,matrix' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame,matrix' plot(x, y, ...) ## S4 method for signature 'RFspatialPointsDataFrame,matrix' plot(x, y, ...) ## S4 method for signature 'RFgridDataFrame,data.frame' plot(x, y, ...) ## S4 method for signature 'RFpointsDataFrame,data.frame' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame,data.frame' plot(x, y, ...) ## S4 method for signature 'RFspatialPointsDataFrame,data.frame' plot(x, y, ...) ## S4 method for signature 'RFgridDataFrame,RFgridDataFrame' plot(x, y, ...) ## S4 method for signature 'RFgridDataFrame,RFpointsDataFrame' plot(x, y, ...) ## S4 method for signature 'RFpointsDataFrame,RFgridDataFrame' plot(x, y, ...) ## S4 method for signature 'RFpointsDataFrame,RFpointsDataFrame' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame,RFspatialGridDataFrame' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame,RFspatialPointsDataFrame' plot(x, y, ...) ## S4 method for signature 'RFspatialPointsDataFrame,RFspatialGridDataFrame' plot(x, y, ...) ## S4 method for signature 'RFspatialPointsDataFrame,RFspatialPointsDataFrame' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame' persp(x, ..., zlab="") ## S3 method for class 'RFspatialGridDataFrame' contour(x, ...)
RFplotSimulation(x, y, MARGIN=c(1,2), MARGIN.slices=NULL, n.slices = if (is.null(MARGIN.slices)) 1 else 10, nmax=6, plot.variance = !is.null(x@.RFparams$has.variance) && x@.RFparams$has.variance, select.variables, zlim, legend=TRUE, MARGIN.movie = NULL, file=NULL, speed = 0.3, height.pixel=300, width.pixel=height.pixel, ..., plotmethod="image") RFplotSimulation1D(x, y, nmax=6, plot.variance=!is.null(x@.RFparams$has.variance) && x@.RFparams$has.variance, legend=TRUE, ...) ## S4 method for signature 'RFgridDataFrame,missing' plot(x, y, ...) ## S4 method for signature 'RFpointsDataFrame,missing' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame,missing' plot(x, y, ...) ## S4 method for signature 'RFspatialPointsDataFrame,missing' plot(x, y, ...) ## S4 method for signature 'RFgridDataFrame,matrix' plot(x, y, ...) ## S4 method for signature 'RFpointsDataFrame,matrix' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame,matrix' plot(x, y, ...) ## S4 method for signature 'RFspatialPointsDataFrame,matrix' plot(x, y, ...) ## S4 method for signature 'RFgridDataFrame,data.frame' plot(x, y, ...) ## S4 method for signature 'RFpointsDataFrame,data.frame' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame,data.frame' plot(x, y, ...) ## S4 method for signature 'RFspatialPointsDataFrame,data.frame' plot(x, y, ...) ## S4 method for signature 'RFgridDataFrame,RFgridDataFrame' plot(x, y, ...) ## S4 method for signature 'RFgridDataFrame,RFpointsDataFrame' plot(x, y, ...) ## S4 method for signature 'RFpointsDataFrame,RFgridDataFrame' plot(x, y, ...) ## S4 method for signature 'RFpointsDataFrame,RFpointsDataFrame' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame,RFspatialGridDataFrame' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame,RFspatialPointsDataFrame' plot(x, y, ...) ## S4 method for signature 'RFspatialPointsDataFrame,RFspatialGridDataFrame' plot(x, y, ...) ## S4 method for signature 'RFspatialPointsDataFrame,RFspatialPointsDataFrame' plot(x, y, ...) ## S4 method for signature 'RFspatialGridDataFrame' persp(x, ..., zlab="") ## S3 method for class 'RFspatialGridDataFrame' contour(x, ...)
x |
object of class |
y |
ignored in most methods; in case of
|
MARGIN |
vector of two; two integer values giving the coordinate dimensions w.r.t. whether the field or the covariance model is to be plotted; in all other directions, the first index is taken |
MARGIN.slices |
integer value; if |
n.slices |
integer value.
The number of slices to be plotted; if
|
nmax |
the maximal number of the |
MARGIN.movie |
integer. If given a sequence of figures is shown for this direction. This option is in an experimental stage. It works only for grids. |
file , speed , height.pixel , width.pixel
|
In case |
... |
arguments to be passed to methods; mainly graphical
arguments, or further models in case of class |
plot.variance |
logical, whether variances should be plotted if available |
select.variables |
vector of integers or list of vectors.
The argument is only of interest for multivariate models.
Here,
|
legend |
logical, whether a legend should be plotted |
zlim |
vector of length 2 with the usual meaning.
In case of multivariate random fields, |
plotmethod |
string or function. Internal. |
zlab |
character. See |
Internally, ...
are passed to image
and
plot.default
, respectively; if, by default, multiple colors,
xlabs or ylabs are used, also vectors of suitable length can be
passed as col
, xlab
and ylab
, respectively.
One exception is the use of ...
in plot
for class
CLASS_CLIST
.
Here, further models might be passed. All models must have names
starting with model
. If '.'
is following in the name,
the part of the name after the dot is shown in the legend. Otherwise
the name is ignored and a standardized name derived from the model
definition is shown in the legend. Note that for the first argument
a name cannot be specified.
signature(x = "RFspatialGridDataFrame", y =
"missing")
Generates nice image plots of simulation results for
simulation on a grid and space-time-dimension . If
space-time-dimension
, plots are on 2-dimensional
subspaces.
Handles multivariate random fields (
.RFparams$vdim>1
) as well as
repeated iid simulations (.RFparams$vdim>n
).
signature(x = "RFspatialGridDataFrame", y =
"RFspatialPointsDataFrame")
Similar to method for y="missing"
, but additionally adds the
points of y
. Requires MARGIN.slices=NULL
and
all.equal([email protected], [email protected])
.
signature(x = "RFspatialGridDataFrame", y =
"matrix")
Similar to method for y="missing"
, but additionally adds the
points of y
. Requires MARGIN.slices=NULL
and
all.equal([email protected], [email protected])
.
signature(x = "RFspatialPointsDataFrame", y =
"RFspatialGridDataFrame")
Throws an error. Probably x
and y
have been interchanged.
signature(x = "RFspatialPointsDataFrame", y =
"missing")
Similar to method for class
RFspatialGridDataFrame
, but for non-gridded simulation results.
Instead of a grid, only existing points are plotted with colors indicating
the value of the random field at the respective location. Handles
multivariate random fields (.RFparams$vdim>1
) as well as
repeated iid simulations (.RFparams$vdim>n
).
signature(x = "RFspatialPointsDataFrame", y =
"RFspatialPointsDataFrame")
Similar to method for y="missing"
, but additionally adds the
points of y
. Requires
all.equal([email protected], [email protected])
.
signature(x = "RFgridDataFrame", y = "missing")
Generates
plots of simulation results for space-time-dimension .
Handles different values for the number of repetitions as well as
multivariate responses.
signature(x = "RFpointsDataFrame", y = "missing")
Similar
to method for class RFgridDataFrame
, but for non-gridded data.
Alexander Malinowski, Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## define the model: model <- RMtrend(mean=0.5) + # mean RMstable(alpha=1, var=4, scale=10) + # see help("RMstable") ## for additional arguments RMnugget(var=1) # nugget ############################################################# ## Plot of covariance structure plot(model) plot(model, xlim=c(0, 30)) plot(model, xlim=c(0, 30), fct.type="Variogram") plot(model, xlim=c(-10, 20), fct.type="Variogram", dim=2) image(model, xlim=c(-10, 20), fct.type="Variogram") persp(model, xlim=c(-10, 20), fct.type="Variogram") ############################################################# ## Plot of simulation results ## define the locations: from <- 0 step <- .1 len <- 50 # nicer if len=100 %ok x1D <- GridTopology(from, step, len) x2D <- GridTopology(rep(from, 2), rep(step, 2), rep(len, 2)) x3D <- GridTopology(rep(from, 3), rep(step, 3), rep(len, 3)) ## 1-dimensional sim1D <- RFsimulate(model = model, x=x1D, n=6) plot(sim1D, nmax=4) ## 2-dimensional sim2D <- RFsimulate(model = model, x=x2D, n=6) plot(sim2D, nmax=4) plot(sim2D, nmax=4, col=terrain.colors(64), main="My simulation", xlab="my_xlab") ## 3-dimensional model <- RMmatern(nu=1.5, var=4, scale=2) sim3D <- RFsimulate(model = model, x=x3D) plot(sim3D, MARGIN=c(2,3), MARGIN.slices=1, n.slices=4) ############################################################# ## empirical variogram plots x <- seq(0, 10, 0.05) bin <- seq(from=0, by=.2, to=3) model <- RMexp() X <- RFsimulate(model, x=cbind(x)) ev1 <- RFvariogram(data=X, bin=bin) plot(ev1) model <- RMexp(Aniso = cbind(c(10,0), c(0,1))) X <- RFsimulate(model, x=cbind(x,x)) ev2 <- RFvariogram(data=X, bin=bin, phi=3) plot(ev2, model=list(exp = model)) ############################################################# ## plot Kriging results model <- RMwhittle(nu=1.2, scale=2) n <- 200 x <- runif(n, max=step*len/2) y <- runif(n, max=step*len/2) # 200 points in 2 dimensional space sim <- RFsimulate(model, x=x, y=y) interpolate <- RFinterpolate(model, x=x2D, data=sim) plot(interpolate) plot(interpolate, sim) ############################################################# ## plotting vector-valued results model <- RMdivfree(RMgauss(), scale=4) x <- y <- seq(-10,10, 0.5) simulated <- RFsimulate(model, x=x, y=y, n=1) plot(simulated) plot(simulated, select.variables=list(1, 1:3, 4)) ############################################################# ## options for the zlim argument model <- RMdelay(RMstable(alpha=1.9, scale=2), s=c(0, 4)) + RMdelay(RMstable(alpha=1.9, scale=2), s=c(4, 0)) simu <- RFsimulate(model, x, y) plot(simu, zlim=list(data=cbind(c(-6,2), c(-2,1)), var=c(5,6))) plot(simu, zlim=cbind(c(-6,2), c(-2,1))) plot(simu, zlim=c(-6,2)) plot(simu, zlim="joint")
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## define the model: model <- RMtrend(mean=0.5) + # mean RMstable(alpha=1, var=4, scale=10) + # see help("RMstable") ## for additional arguments RMnugget(var=1) # nugget ############################################################# ## Plot of covariance structure plot(model) plot(model, xlim=c(0, 30)) plot(model, xlim=c(0, 30), fct.type="Variogram") plot(model, xlim=c(-10, 20), fct.type="Variogram", dim=2) image(model, xlim=c(-10, 20), fct.type="Variogram") persp(model, xlim=c(-10, 20), fct.type="Variogram") ############################################################# ## Plot of simulation results ## define the locations: from <- 0 step <- .1 len <- 50 # nicer if len=100 %ok x1D <- GridTopology(from, step, len) x2D <- GridTopology(rep(from, 2), rep(step, 2), rep(len, 2)) x3D <- GridTopology(rep(from, 3), rep(step, 3), rep(len, 3)) ## 1-dimensional sim1D <- RFsimulate(model = model, x=x1D, n=6) plot(sim1D, nmax=4) ## 2-dimensional sim2D <- RFsimulate(model = model, x=x2D, n=6) plot(sim2D, nmax=4) plot(sim2D, nmax=4, col=terrain.colors(64), main="My simulation", xlab="my_xlab") ## 3-dimensional model <- RMmatern(nu=1.5, var=4, scale=2) sim3D <- RFsimulate(model = model, x=x3D) plot(sim3D, MARGIN=c(2,3), MARGIN.slices=1, n.slices=4) ############################################################# ## empirical variogram plots x <- seq(0, 10, 0.05) bin <- seq(from=0, by=.2, to=3) model <- RMexp() X <- RFsimulate(model, x=cbind(x)) ev1 <- RFvariogram(data=X, bin=bin) plot(ev1) model <- RMexp(Aniso = cbind(c(10,0), c(0,1))) X <- RFsimulate(model, x=cbind(x,x)) ev2 <- RFvariogram(data=X, bin=bin, phi=3) plot(ev2, model=list(exp = model)) ############################################################# ## plot Kriging results model <- RMwhittle(nu=1.2, scale=2) n <- 200 x <- runif(n, max=step*len/2) y <- runif(n, max=step*len/2) # 200 points in 2 dimensional space sim <- RFsimulate(model, x=x, y=y) interpolate <- RFinterpolate(model, x=x2D, data=sim) plot(interpolate) plot(interpolate, sim) ############################################################# ## plotting vector-valued results model <- RMdivfree(RMgauss(), scale=4) x <- y <- seq(-10,10, 0.5) simulated <- RFsimulate(model, x=x, y=y, n=1) plot(simulated) plot(simulated, select.variables=list(1, 1:3, 4)) ############################################################# ## options for the zlim argument model <- RMdelay(RMstable(alpha=1.9, scale=2), s=c(0, 4)) + RMdelay(RMstable(alpha=1.9, scale=2), s=c(4, 0)) simu <- RFsimulate(model, x, y) plot(simu, zlim=list(data=cbind(c(-6,2), c(-2,1)), var=c(5,6))) plot(simu, zlim=cbind(c(-6,2), c(-2,1))) plot(simu, zlim=c(-6,2)) plot(simu, zlim="joint")
PrintModelList
prints the list of currently implemented models
including the corresponding simulation methods.
PrintModelList(operators=FALSE, internal=FALSE, newstyle=TRUE)
PrintModelList(operators=FALSE, internal=FALSE, newstyle=TRUE)
operators |
logical. Flag whether operators should also be considered. |
internal |
logical. Flag whether internal models should also be considered. In case of |
newstyle |
logical. If |
See RMmodel for a description of the models and their use.
PrintModelList
prints a table of the currently implemented covariance
functions and the matching methods.
PrintModelList
returns NULL
.
From version 3.0 on, the command PrintModelList()
is replaced by the call
RFgetModelNames(internal=FALSE)
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again PrintModelList()
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again PrintModelList()
RMmodel
RFboxcox
performs the Box-Cox transformation:
RFboxcox(data, boxcox, vdim = 1, inverse=FALSE, ignore.na=FALSE)
RFboxcox(data, boxcox, vdim = 1, inverse=FALSE, ignore.na=FALSE)
data |
matrix or list of matrices. |
boxcox |
the one or two parameters |
vdim |
the multivariate dimensionality of the field; |
inverse |
logical. Whether the inverse transformation should be performed. |
ignore.na |
logical. If |
The Box-Cox transfomation boxcox
can be set
globally through RFoptions
. If it is set globally the
transformation applies in the Gaussian case to
RFfit
,
RFsimulate
,
RFinterpolate
,
RFvariogram
.
Always first, the Box-Cox transformation is applied to the data.
Then the command is performed. The result is back-transformed before
returned.
If the first value of the transformation is Inf
no
transformation is performed (and is identical to boxcox = c(1,0)
).
If boxcox
has length 1, then the transformation parameter
is set to
, which is the standard case.
RFboxcox
returns a list
of three components, Y
, X
, vdim
returning
the deterministic trend, the design matrix, and the multivariability,
respectively.
If set
is positive, Y
and X
contain
the values for the set
-th set of coordinates.
Else, Y
and X
are both lists containing
the values for all the sets.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
For the likelihood correction see
Konishi, S., and Kitagawa, G. (2008) Information criteria and statistical modeling. Springer Science & Business Media. Section 4.9.
Bayesian,
RMmodel
,
RFsimulate
,
RFlikelihood
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again data(soil) str(soil) soil <- RFspatialPointsDataFrame( coords = soil[ , c("x.coord", "y.coord")], data = soil[ , c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] model <- ~1 + RMplus(RMwhittle(scale=NA, var=NA, nu=NA), RMnugget(var=NA)) ## main Parameter in the Box Cox transformation to be estimated print(fit <- RFfit(model, data=dta, boxcox=NA))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again data(soil) str(soil) soil <- RFspatialPointsDataFrame( coords = soil[ , c("x.coord", "y.coord")], data = soil[ , c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] model <- ~1 + RMplus(RMwhittle(scale=NA, var=NA, nu=NA), RMnugget(var=NA)) ## main Parameter in the Box Cox transformation to be estimated print(fit <- RFfit(model, data=dta, boxcox=NA))
Calculates both the empirical and the theoretical (cross-)covariance function.
RFcov(model, x, y = NULL, z = NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL)
RFcov(model, x, y = NULL, z = NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
data |
matrix, data.frame or object of class |
bin |
a vector giving the borders of the bins; If not specified an array describing the empirical (pseudo-)(cross-) covariance function in every direction is returned. |
phi |
an integer defining the number of sectors one half of the X/Y plane shall be divided into. If not specified, either an array is returned (if bin missing) or isotropy is assumed (if bin specified). |
theta |
an integer defining the number of sectors one half of the X/Z plane shall be divided into. Use only for dimension |
deltaT |
vector of length 2, specifying the temporal bins. The internal bin vector becomes |
distances , dim
|
another alternative for the argument |
vdim |
the number of variables of a multivariate data set. If not given and |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
RFcov
computes the empirical
cross-covariance function for given (multivariate) spatial data.
The empirical
(cross-)covariance function of two random fields and
is given by
where ,
denotes the number of pairs of data points with distancevector
and where
and
denotes the mean of data points with distancevector
.
The spatial coordinates x
, y
, z
should be vectors. For random fields of
spatial dimension write all vectors as columns of matrix x. In
this case do neither use y, nor z and write the columns in
gridtriple
notation.
If the data is spatially located on a grid a fast algorithm based on
the fast Fourier transformed (fft) will be used.
As advanced option the calculation method can also be changed for grid
data (see RFoptions
.)
It is also possible to use RFcov
to calculate
the pseudocovariance function (see RFoptions
).
RFcov
returns objects of class
RFempVariog
.
Jonas Auel; Sebastian Engelke; Johannes Martini; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
Stein, M. L. (1999) Interpolation of Spatial Data. New York: Springer-Verlag
RFvariogram
,
RFmadogram
,
RMstable
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 1 ## use n <- 2 for better results ## isotropic model model <- RMexp() x <- seq(0, 10, 0.02) z <- RFsimulate(model, x=x, n=n) emp.vario <- RFcov(data=z) plot(emp.vario, model=model) ## anisotropic model model <- RMexp(Aniso=cbind(c(2,1), c(1,1))) x <- seq(0, 10, 0.05) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFcov(data=z, phi=4) plot(emp.vario, model=model) ## space-time model model <- RMnsst(phi=RMexp(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.05) T <- c(0, 0.1, 100) z <- RFsimulate(x=x, T=T, model=model, n=n) emp.vario <- RFcov(data=z, deltaT=c(10, 1)) plot(emp.vario, model=model, nmax.T=3) ## multivariate model model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFcov(data=z) plot(emp.vario, model=model) ## multivariate and anisotropic model model <- RMbiwm(A=matrix(c(1,1,1,2), nc=2), nudiag=c(0.5,2), s=c(3, 1, 2), c=c(1, 0, 1)) x <- seq(0, 20, 0.1) dta <- RFsimulate(model, x, x, n=n) ev <- RFcov(data=dta, phi=4) plot(ev, model=model, boundaries=FALSE)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 1 ## use n <- 2 for better results ## isotropic model model <- RMexp() x <- seq(0, 10, 0.02) z <- RFsimulate(model, x=x, n=n) emp.vario <- RFcov(data=z) plot(emp.vario, model=model) ## anisotropic model model <- RMexp(Aniso=cbind(c(2,1), c(1,1))) x <- seq(0, 10, 0.05) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFcov(data=z, phi=4) plot(emp.vario, model=model) ## space-time model model <- RMnsst(phi=RMexp(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.05) T <- c(0, 0.1, 100) z <- RFsimulate(x=x, T=T, model=model, n=n) emp.vario <- RFcov(data=z, deltaT=c(10, 1)) plot(emp.vario, model=model, nmax.T=3) ## multivariate model model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFcov(data=z) plot(emp.vario, model=model) ## multivariate and anisotropic model model <- RMbiwm(A=matrix(c(1,1,1,2), nc=2), nudiag=c(0.5,2), s=c(3, 1, 2), c=c(1, 0, 1)) x <- seq(0, 20, 0.1) dta <- RFsimulate(model, x, x, n=n) ev <- RFcov(data=dta, phi=4) plot(ev, model=model, boundaries=FALSE)
RFcovmatrix
returns the covariance matrix for a set of points;
RFcovmatrix(model, x, y = NULL, z = NULL, T = NULL, grid, params, distances, dim,...)
RFcovmatrix(model, x, y = NULL, z = NULL, T = NULL, grid, params, distances, dim,...)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
distances , dim
|
another alternative for the argument |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
RFcovmatrix
returns a covariance matrix. Here, a matrix of coordinates (x
) or a vector or a matrix of distances
is expected.
RFcovmatrix
also allows for variogram models. Then the negative of the
variogram matrix is returned.
RFcovmatrix
returns a covariance matrix.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmodel
,
RFsimulate
,
RFfit
,
RFfctn
,
RFcalc
,
RFcov
,
RFpseudovariogram
,
RFvariogram
.
################################################## # Example: get covariance matrix C(x_i,x_j) # at given locations x_i, i=1,...,n # # here for an isotropic stationary covariance model # yields a 4 times 4 covariance matrix of the form # C(0) C(5) C(3) C(2.5) # C(5) C(0) C(4) C(2.5) # C(3) C(4) C(0) C(2.5) # C(2.5) C(2.5) C(2.5) C(0) model <- RMexp() # the covariance function C(x,y)=C(r) of this model # depends only on the distance r between x and y RFcovmatrix(model=model, distances=c(5,3,2.5,4,2.5,2.5), dim=4)
################################################## # Example: get covariance matrix C(x_i,x_j) # at given locations x_i, i=1,...,n # # here for an isotropic stationary covariance model # yields a 4 times 4 covariance matrix of the form # C(0) C(5) C(3) C(2.5) # C(5) C(0) C(4) C(2.5) # C(3) C(4) C(0) C(2.5) # C(2.5) C(2.5) C(2.5) C(0) model <- RMexp() # the covariance function C(x,y)=C(r) of this model # depends only on the distance r between x and y RFcovmatrix(model=model, distances=c(5,3,2.5,4,2.5,2.5), dim=4)
The function estimates arbitrary parameters of a random field specification with various methods. Currently, the models to be fitted can be
The fitting of max-stable random fields and others has not been implemented yet.
RFcrossvalidate(model, x, y=NULL, z=NULL, T=NULL, grid=NULL, data, params, lower=NULL, upper=NULL, method="ml", users.guess=NULL, distances=NULL, dim, optim.control=NULL, transform=NULL, full = FALSE, ...)
RFcrossvalidate(model, x, y=NULL, z=NULL, T=NULL, grid=NULL, data, params, lower=NULL, upper=NULL, method="ml", users.guess=NULL, distances=NULL, dim, optim.control=NULL, transform=NULL, full = FALSE, ...)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
data |
matrix, data.frame or object of class |
lower |
list or vector. Lower bounds for the parameters. If |
upper |
list or vector. Upper bounds for the parameters. See |
method |
Single method to be used for estimating, either
one of the |
users.guess |
User's guess of the parameters. All the parameters must be given using the same rules as for |
distances , dim
|
another alternative for the argument |
optim.control |
control list for |
transform |
obsolete for users; use |
full |
logical.
If |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
An object of the class
"RFcrossvalidate"
which is
a list with the following components, cf. xvalid
in the
package geoR :
data |
the original data. |
predicted |
the values predicted by cross-validation. |
krige.var |
the cross-validation prediction variance. |
error |
the differences |
std.error |
the errors divided by the square root of the prediction variances. |
p |
In contrast to geoR the p-value is returned, i.e. the probability that a difference with absolute value larger than the absolute value of the actual difference is observed. A method for If |
prints the summary
gives a summary
An important option is cross_refit
that determines
whether the model is refitted for each location left out.
Default is FALSE
. See also RFoptions
.
This function does not depend on the value of
RFoptions
()$PracticalRange
.
The function RFcrossvalidate
always uses the standard specification
of the covariance model as given in RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Ribeiro, P.J., Jr. and Diggle, P.J (2014) R package geoR.
Burnham, K. P. and Anderson, D. R. (2002) Model selection and Multi-Model Inference: A Practical Information-Theoretic Approach. 2nd edition. New York: Springer.
RFratiotest
RFfit
RMmodel
,
RandomFields
,
weather
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## currently disabled!
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## currently disabled!
Through RRdistr
distribution families can be passed to RandomFields to create distributions available
in the RMmodel
definitions.
RFddistr(model, x, params, dim=1, ...) RFpdistr(model, q, params, dim=1, ...) RFqdistr(model, p, params, dim=1, ...) RFrdistr(model, n, params, dim=1, ...) RFdistr(model, x, q, p, n, params, dim=1, ...)
RFddistr(model, x, params, dim=1, ...) RFpdistr(model, q, params, dim=1, ...) RFqdistr(model, p, params, dim=1, ...) RFrdistr(model, n, params, dim=1, ...) RFdistr(model, x, q, p, n, params, dim=1, ...)
model , params
|
an |
x |
the location where the density is evaluated |
q |
the location where the probability function is evaluated |
p |
the value where the quantile function is evaluated |
n |
the number of random values to be drawn |
dim |
the dimension of the vector to be drawn |
... |
for advanced use:
further options and control arguments for the simulation
that are passed to and processed by |
RFdistr
is the generic function for the 4 functions
belonging to a distribution.
as described in the arguments
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## a very toy example to understand the use model <- RRdistr(norm()) v <- 0.5 Print(RFdistr(model=model, x=v), dnorm(x=v)) Print(RFdistr(model=model, q=v), pnorm(q=v)) Print(RFdistr(model=model, p=v), qnorm(p=v)) n <- 10 r <- RFdistr(model=model, n=n, seed=0) set.seed(0); Print(r, rnorm(n=n)) ## note that a conditional covariance function given the ## random parameters is given here: model <- RMgauss(scale=exp()) for (i in 1:3) { RFoptions(seed = i + 10) readline(paste("Model no.", i, ": press return", sep="")) plot(model) readline(paste("Simulation no.", i, ": press return", sep="")) plot(RFsimulate(model, x=seq(0,10,0.1))) }
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## a very toy example to understand the use model <- RRdistr(norm()) v <- 0.5 Print(RFdistr(model=model, x=v), dnorm(x=v)) Print(RFdistr(model=model, q=v), pnorm(q=v)) Print(RFdistr(model=model, p=v), qnorm(p=v)) n <- 10 r <- RFdistr(model=model, n=n, seed=0) set.seed(0); Print(r, rnorm(n=n)) ## note that a conditional covariance function given the ## random parameters is given here: model <- RMgauss(scale=exp()) for (i in 1:3) { RFoptions(seed = i + 10) readline(paste("Model no.", i, ": press return", sep="")) plot(model) readline(paste("Simulation no.", i, ": press return", sep="")) plot(RFsimulate(model, x=seq(0,10,0.1))) }
RFempVariog
Class for RandomFields' representation of empirical variograms
RFplotEmpVariogram(x, model = NULL, nmax.phi = NA, nmax.theta = NA, nmax.T = NA, plot.nbin = TRUE, plot.sd=FALSE, method = "ml", variogram=TRUE, boundaries = TRUE, ...) ## S4 method for signature 'RFempVariog,missing' plot(x, y, ...) ## S4 method for signature 'RFempVariog' persp(x, ...)
RFplotEmpVariogram(x, model = NULL, nmax.phi = NA, nmax.theta = NA, nmax.T = NA, plot.nbin = TRUE, plot.sd=FALSE, method = "ml", variogram=TRUE, boundaries = TRUE, ...) ## S4 method for signature 'RFempVariog,missing' plot(x, y, ...) ## S4 method for signature 'RFempVariog' persp(x, ...)
x |
object of class
|
y |
unused |
model |
object of class |
nmax.phi |
even integer; only for |
.
nmax.theta |
integer; only for |
nmax.T |
integer; only for |
plot.nbin |
logical; only for |
plot.sd |
logical; only for |
method |
character. Currently restricted to |
variogram |
logical; This argument should currently not be set
by the user. If |
boundaries |
logical; only for |
... |
arguments to be passed to methods; mainly graphical arguments. |
centers
:the bin centres of the spatial distances
empirical
:value of the empirical variogram
var
:the empirical (overall) variance in the data
sd
:standard deviation of the variogram cloud within each bin
n.bin
:number of bins
phi.centers
:centres of the bins with respect to the (first) angle (for anisotropic empirical variograms only)
theta.centers
:centres of the bins with respect to the second angle (for anisotropic empirical variograms in 3D only)
T
:the bin centres of the time axis
vdim
:the multivariate dimension
coordunits
:string giving the units of the coordinates,
see also option coordunits
of RFoptions
.
varunits
:string giving the units of the variables,
see also option varunits
of RFoptions
.
call
:language object; the function call by which the object was generated
method
:integer; variogram (0), covariance (2), madogram (4)
signature(x = "RFempVariog")
: gives a plot of the
empirical variogram, for more details see
plot-method
.
signature(x = "RFempVariog", y = "missing")
Gives nice
plots of the empirical variogram; handles binning in up to three
space-dimensions and a time-dimension, where the empirical variogram
is plotted along lines which are directed according to the
angle-centers given in [email protected]
and
[email protected]
; arbitrary theoretical model curves
can be added to the plot by using the argument model
.
If no bins are given, i.e. (x@bin=NULL
),
image
-plots are generated.
signature(x = "RFempVariog")
:
converts into other formats, only implemented for target class
list
.
signature(x = "RFfit")
: returns the structure
of x
signature(obj =
"RFempVariog")
: generates nice persp
plots
signature(x = "RFfit")
: identical with
show
-method
provides a summary
print
returns also an invisible list that is convenient to access.
Alexander Malinowski, Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
# see 'RFvariogram'
# see 'RFvariogram'
RFfctn
returns the values of a shape function.
RFfctn(model, x, y = NULL, z = NULL, T = NULL, grid, params, distances, dim,...)
RFfctn(model, x, y = NULL, z = NULL, T = NULL, grid, params, distances, dim,...)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
distances , dim
|
another alternative for the argument |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
RFcovmatrix
also allows for variogram models. Then the negative of the
variogram matrix is returned.
RFfctn
returns a vector.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmodel
,
RFsimulate
,
RFfit
,
RFcalc
,
RFcov
,
RFcovmatrix
,
RFpseudovariogram
,
RFvariogram
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() - 1 RFfctn(model, 1:10)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() - 1 RFfctn(model, 1:10)
The function estimates arbitrary parameters of a random field specification with various methods. Currently, the models to be fitted can be
The fitting of max-stable random fields and others has not been implemented yet.
RFfit(model, x, y = NULL, z = NULL, T = NULL, grid=NULL, data, lower = NULL, upper = NULL, methods, sub.methods, optim.control = NULL, users.guess = NULL, distances = NULL, dim, transform = NULL, params=NULL, ...)
RFfit(model, x, y = NULL, z = NULL, T = NULL, grid=NULL, data, lower = NULL, upper = NULL, methods, sub.methods, optim.control = NULL, users.guess = NULL, distances = NULL, dim, transform = NULL, params=NULL, ...)
model , params
|
object of class All parameters that are set to Type |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
data |
matrix, data.frame or object of class |
lower |
list or vector. Lower bounds for the parameters. If |
upper |
list or vector. Upper bounds for the parameters. See |
methods |
Main methods to be used for estimating. If several methods are given, estimation will be performed with each method and the results reported. |
sub.methods |
variants of the least squares fit of the variogram. variants of the maximum likelihood fit of the covariance function.. See Details. |
users.guess |
User's guess of the parameters. All the parameters must be given using the same rules as for |
distances , dim
|
another alternative for the argument |
optim.control |
control list for |
transform |
obsolete for users; use |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
For details on the simulation methods see
If x
-coordinates are not given, the function will check
data
for NA
s and will perform imputing.
The function has many more options to tune the optimizer,
see RFoptions
for details.
If the model defines a Gaussian random field, the options
for methods
and submethods
are currently
"ml"
and c("self", "plain", "sqrt.nr", "sd.inv", "internal")
,
respectively.
The result depends on the logical value of
spConform
.
If TRUE
, an S4 object is created. In case the model indicates
a Gaussian random field, an
RFfit object is created.
If spConform=FALSE
, a list is returned.
In case the model indicates
a Gaussian random field, the details are given in fitgauss.
An important optional argument is boxcox
which indicates
a Box-Cox transformation; see boxcox
in RFoptions
and RFboxcox
for details.
Instead of optim
, other optimisers can be used,
see RFfitOptimiser.
Several advanced options can be found in sections ‘General
options’ and ‘fit’ of RFoptions
.
In particular, boxcox
, boxcox_lb
, boxcox_ub
allow Box-Cox transformation.
This function does not depend on the value of
RFoptions
()$PracticalRange
.
The function RFfit
always uses the standard specification
of the covariance model as given in RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Burnham, K. P. and Anderson, D. R. (2002) Model selection and Multi-Model Inference: A Practical Information-Theoretic Approach. 2nd edition. New York: Springer.
RFfitOptimiser
,
RFlikelihood
,
RFratiotest
,
RMmodel
,
RandomFields
,
weather
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(modus_operandi="sloppy") ######################################################### ## simulate some data first ## points <- 100 x <- runif(points, 0, 3) y <- runif(points, 0, 3) ## random points in square [0, 3]^2 model <- RMgencauchy(alpha=1, beta=2) d <- RFsimulate(model, x=x, y=y, grid=FALSE, n=100) #1000 ######################################################### ## estimation; 'NA' means: "to be estimated" ## estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=2) + RMtrend(mean=NA) RFfit(estmodel, data=d) ######################################################### ## coupling alpha and beta ## estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=NA) + RMtrend(NA) RFfit(estmodel, data=d, transform = NA) ## just for information trafo <- function(a) c(a[1], rep(a[2], 2)) fit <- RFfit(estmodel, data=d, transform = list(c(TRUE, TRUE, FALSE), trafo)) print(fit) print(fit, full=TRUE)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(modus_operandi="sloppy") ######################################################### ## simulate some data first ## points <- 100 x <- runif(points, 0, 3) y <- runif(points, 0, 3) ## random points in square [0, 3]^2 model <- RMgencauchy(alpha=1, beta=2) d <- RFsimulate(model, x=x, y=y, grid=FALSE, n=100) #1000 ######################################################### ## estimation; 'NA' means: "to be estimated" ## estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=2) + RMtrend(mean=NA) RFfit(estmodel, data=d) ######################################################### ## coupling alpha and beta ## estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=NA) + RMtrend(NA) RFfit(estmodel, data=d, transform = NA) ## just for information trafo <- function(a) c(a[1], rep(a[2], 2)) fit <- RFfit(estmodel, data=d, transform = list(c(TRUE, TRUE, FALSE), trafo)) print(fit) print(fit, full=TRUE)
RFfit
Class for RandomFields' representation of model estimation results
## S4 method for signature 'RFfit' residuals(object, ..., method="ml", full=FALSE) ## S4 method for signature 'RFfit' summary(object, ..., method="ml") ## S4 method for signature 'RFfit,missing' plot(x, y, ...) ## S3 method for class 'RFfit' contour(x, ...) ## S3 method for class 'RFempVariog' contour(x, ...) RFhessian(model)
## S4 method for signature 'RFfit' residuals(object, ..., method="ml", full=FALSE) ## S4 method for signature 'RFfit' summary(object, ..., method="ml") ## S4 method for signature 'RFfit,missing' plot(x, y, ...) ## S3 method for class 'RFfit' contour(x, ...) ## S3 method for class 'RFempVariog' contour(x, ...) RFhessian(model)
object |
see the generic function; |
... |
|
method |
character; only for |
full |
logical.
if |
x |
object of class |
y |
unused |
model |
|
for the definition of plot
see RFplotEmpVariogram
.
Objects are created by the function
RFfit
autostart
:RMmodelFit; contains the estimation results for the method 'autostart' including a likelihood value, a constant trend and the residuals
boxcox
:logical; whether the parameter of a Box Cox tranformation has been estimated
coordunits
:string giving the units of the coordinates,
see also option coordunits
of RFoptions
.
deleted
:integer vector. Positions of the parameters that have been deleted to get the set of variables, used in the optimization.
ev
:list; list of objects of class
RFempVariog
,
contains the empirical variogram estimates of the data
fixed
:list of two vectors. The fist gives the position where the parameters are set to zero. The second gives the position where the parameters are set to one.
internal1
:RMmodelFit; analog to slot 'autostart'
internal2
:RMmodelFit; analog to slot 'autostart'
internal3
:RMmodelFit; analog to slot 'autostart'
lowerbounds
:RMmodel; covariance model in which each parameter value gives the lower bound for the respective parameter
ml
:RMmodelFit; analog to slot 'autostart'
modelinfo
:table with information on the parameters: name, boundaries, type of parameter
n.covariates
:number of covariates
n.param
:number of parameters (given by the user)
n.variab
:number of variables (used internally);
n.variab
is always less than or equal to n.param
number.of.data
:the number of data values passed to RFfit
that are
not NA
or NaN
number.of.parameters
:total number of parameters of the model that had to be estimated including variances, scales, co-variables, etc.
p.proj
:vector of integers. The original position of those parameters that are used in the submodel
plain
:RMmodelFit; analog to slot 'autostart'
report
:If not empty, it indicates that this model should be reported and gives a standard name of the model.
Various functions, e.g. print.RMmodelFit
, use
this information if their argument full
equals TRUE
.
self
:RMmodelFit; analog to slot 'autostart'
sd.inv
:RMmodelFit; analog to slot 'autostart'
sqrt.nr
:RMmodelFit; analog to slot 'autostart'
submodels
:list. Sequence (in some cases even nested sequence) of models that is used to determine an initial value in
table
:matrix; summary of estimation results of different methods
transform
:function;
true.tsdim
:time space dimension of the (original!) data, even for submodels that consider parts of separable models.
true.vdim
:multivariability of the (original!) data, even for submodels that consider independent models for the multivariate components.
upperbounds
:RMmodel; see slot 'lowerbounds'
users.guess
:RMmodelFit; analog to slot 'autostart'
ml
:RMmodelFit; analog to slot 'autostart'; with maximum likelihood method
v.proj
:vector of integers. The components selected in one of the submodels
varunits
:string giving the units of the variables,
see also option varunits
of RFoptions
.
x.proj
:logical or integer. If logical, it means that no separable model is considered there. If integer, then it gives the considered directions of a separable model.
Z
:standardized list of information on the data
signature(x = "RFfit")
: gives a plot of the
empirical variogram together with the fitted model, for more details see
plot-method
.
signature(x = "RFfit")
: returns the structure
of x
signature(obj =
"RFfit")
: generates persp
plots
signature(x = "RFfit")
: identical with
show
-method, additional argument is max.level
signature(x = "RFfit")
: enables accessing
the slots via the "["
-operator, e.g. x["ml"]
signature(x = "RFfit")
:
converts into other formats, only implemented for target class
RFempVariog
performs a likelihood ratio test base on a chisq approximation
provides a summary
provides an object of class "logLik"
provides the AIC and BIC information, respectively
signature(x = "RFfit", y = "missing")
Combines the plot of
the empirical variogram with the estimated covariance or variogram
model (theoretical) curves; further models can be added via the
argument model
.
AICc.RFfit(object, ..., method="ml", full=FALSE)
AICc.RF_fit(object, ..., method="ml", full=TRUE)
Alexander Malinowski; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
AICc:
Hurvich, C.M. and Tsai, C.-L. (1989) Regression and Time Series Model Selection in Small Samples Biometrika, 76, 297-307.
RFfit
,
RFvariogram
,
RMmodel-class
,
RMmodelFit-class
,
plot-method
.
# see RFfit
# see RFfit
See RFfit
for a detailed description of
the fitting procedure.
Two parameters, see also RFoptions
can be passed to RFfit
that allow
for choosing an optimiser different from optim
:
optimiser
takes one of the values
"optim"
, "optimx"
, "soma"
, "nloptr"
,
"GenSA"
, "minqa"
, "pso"
or "DEoptim"
,
see the corresponding packages for a description.
If optimiser="nloptr"
, then the additional parameter
algorithm
must be given which takes the values
"NLOPT_GN_DIRECT"
,
"NLOPT_GN_DIRECT_L"
,
"NLOPT_GN_DIRECT_L_RAND"
,
"NLOPT_GN_DIRECT_NOSCAL"
,
"NLOPT_GN_DIRECT_L_NOSCAL"
,
"NLOPT_GN_DIRECT_L_RAND_NOSCAL"
,
"NLOPT_GN_ORIG_DIRECT"
,
"NLOPT_GN_ORIG_DIRECT_L"
,
"NLOPT_LN_PRAXIS"
,
"NLOPT_GN_CRS2_LM"
,
"NLOPT_LN_COBYLA"
,
"NLOPT_LN_NELDERMEAD"
,
"NLOPT_LN_SBPLX"
,
"NLOPT_LN_BOBYQA"
,
"NLOPT_GN_ISRES"
,
see nloptr for a description.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Not run: ## Here some alternative optimisers to 'optim' are considered. ## All but the \pkg{nloptr} algorithms are largely slower than 'optim'. ## Only a few of them return results as good as 'optim'. data(soil) str(soil) soil <- RFspatialPointsDataFrame( coords = soil[ , c("x.coord", "y.coord")], data = soil[ , c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] \dontshow{if (RFoptions()$internal$examples_red) { warning("data have been reduced !") All <- 1:7 rm(soil) data(soil) soil <- RFspatialPointsDataFrame( coords = soil[All, c("x.coord", "y.coord")], data = soil[All, c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] }} model <- ~1 + RMwhittle(scale=NA, var=NA, nu=NA) + RMnugget(var=NA) \dontshow{if (RFoptions()$internal$examples_red){model<-~1+RMwhittle(scale=NA,var=NA,nu=1/2)}} ## standard optimiser 'optim' print(system.time(fit <- RFfit(model, data=dta))) print(fit) opt <- "optimx" # 30 sec; better result print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) \dontshow{\dontrun{ opt <- "soma" # 450 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) }} opt <- "minqa" # 330 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) opt <- "nloptr" algorithm <- RC_NLOPTR_NAMES \dontshow{if(!interactive()) algorithm <- RC_NLOPTR_NAMES[1]} for (i in 1:length(algorithm)) { print(algorithm[i]) print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt, algorithm=algorithm[i])))) print(fit2) } if (interactive()) { ## the following two optimisers are too slow to be run on CRAN. opt <- "pso" # 600 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) opt <- "GenSA" # 10^4 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) } ## End(Not run)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Not run: ## Here some alternative optimisers to 'optim' are considered. ## All but the \pkg{nloptr} algorithms are largely slower than 'optim'. ## Only a few of them return results as good as 'optim'. data(soil) str(soil) soil <- RFspatialPointsDataFrame( coords = soil[ , c("x.coord", "y.coord")], data = soil[ , c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] \dontshow{if (RFoptions()$internal$examples_red) { warning("data have been reduced !") All <- 1:7 rm(soil) data(soil) soil <- RFspatialPointsDataFrame( coords = soil[All, c("x.coord", "y.coord")], data = soil[All, c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] }} model <- ~1 + RMwhittle(scale=NA, var=NA, nu=NA) + RMnugget(var=NA) \dontshow{if (RFoptions()$internal$examples_red){model<-~1+RMwhittle(scale=NA,var=NA,nu=1/2)}} ## standard optimiser 'optim' print(system.time(fit <- RFfit(model, data=dta))) print(fit) opt <- "optimx" # 30 sec; better result print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) \dontshow{\dontrun{ opt <- "soma" # 450 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) }} opt <- "minqa" # 330 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) opt <- "nloptr" algorithm <- RC_NLOPTR_NAMES \dontshow{if(!interactive()) algorithm <- RC_NLOPTR_NAMES[1]} for (i in 1:length(algorithm)) { print(algorithm[i]) print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt, algorithm=algorithm[i])))) print(fit2) } if (interactive()) { ## the following two optimisers are too slow to be run on CRAN. opt <- "pso" # 600 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) opt <- "GenSA" # 10^4 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) } ## End(Not run)
It is described how to create a formula, which, for example, can be used as an argument of RFsimulate
and
RFfit
to simulate and to fit data according to the
model described by the formula.
In general, the created formula serves two purposes:
to describe models in the “Linear Mixed Models”-framework
to define models for random fields including trend surfaces from a geostatistical point of view.
Thereby, fixed effects and trend surfaces can be adressed via
the expression RMfixed
and the function
RMtrend
. In simple cases, the trend can also
be given in a very simple, see the examples below.
The covariance structures of the zero-mean
multivariate normally distributed
random field
components are adressed by objects of class RMmodel
, which
allow for a very flexible covariance specification.
See RFformulaAdvanced for rather complicated model definitions.
The formula should be of the type
or
respectively.
Thereby:
response
optional; name of response variable
fixed effects/trend:
optional, should be a sum (using +
)
of components either of the form X@RMfixed(beta)
or
RMtrend(...)
with being a design matrix
and
being a vector of coefficients (see
RMfixed
and RMtrend
).
Note that a fixed effect of the form is interpreted as
X@RMfixed(beta=NA)
by default (and is estimated
provided that the formula is used in
RFfit
).
error term/nugget effect
optional, should be of the form RMnugget(...)
.
RMnugget
describes a vector
of iid Gaussian random variables.
Note that in formula constants are interpreted as part of a linear
model, i.e. the corresponding parameter has to be estimated
(e.g. ~ 1 + ...
) whereas in models not given as formula the
parameters to be estimated must be given explicitly.
(additional) argument names should always start with a capital
letter. Small initial letters are reserved for RFoptions
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and P. Delfiner (1999) Geostatistics. Modeling Spatial Uncertainty. New York, Chichester: John Wiley & Sons.
McCulloch, C. E., Searle, S. R. and Neuhaus, J. M. (2008) Generalized, linear, and mixed models. Hoboken, NJ: John Wiley & Sons.
Ruppert, D. and Wand, M. P. and Carroll, R. J. (2003) Semiparametric regression. Cambridge: Cambridge University Press.
RMmodel
,
RFsimulate
,
RFfit
,
RandomFields
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(modus_operandi="sloppy") ############################################################## # # Example : Simulation and fitting of a two-dimensional # Gaussian random field with exponential covariance function # ############################################################### V <- 10 S <- 0.3 M <- 3 model <- RMexp(var=V, scale=S) + M x <- y <- seq(1, 3, 0.1) simulated <- RFsimulate(model = model, x=x, y=y) plot(simulated) # an alternative code to the above code: model <- ~ Mean + RMexp(var=Var, scale=Sc) simulated2 <- RFsimulate(model = model,x=x, y=y, Var=V, Sc=S, Mean=M) plot(simulated2) # a third way of specifying the model using the argument 'param' # the initials of the variables do not be captical letters model <- ~ M + RMexp(var=var, scale=sc) simulated3 <- RFsimulate(model = model,x=x, y=y, param=list(var=V, sc=S, M=M)) plot(simulated3) # Estimate parameters of underlying covariance function via # maximum likelihood model.na <- ~ NA + RMexp(var=NA, scale=NA) fitted <- RFfit(model=model.na, data=simulated) # compare sample mean of data with ML estimate, which is very similar: mean(simulated@data[,1]) fitted
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(modus_operandi="sloppy") ############################################################## # # Example : Simulation and fitting of a two-dimensional # Gaussian random field with exponential covariance function # ############################################################### V <- 10 S <- 0.3 M <- 3 model <- RMexp(var=V, scale=S) + M x <- y <- seq(1, 3, 0.1) simulated <- RFsimulate(model = model, x=x, y=y) plot(simulated) # an alternative code to the above code: model <- ~ Mean + RMexp(var=Var, scale=Sc) simulated2 <- RFsimulate(model = model,x=x, y=y, Var=V, Sc=S, Mean=M) plot(simulated2) # a third way of specifying the model using the argument 'param' # the initials of the variables do not be captical letters model <- ~ M + RMexp(var=var, scale=sc) simulated3 <- RFsimulate(model = model,x=x, y=y, param=list(var=V, sc=S, M=M)) plot(simulated3) # Estimate parameters of underlying covariance function via # maximum likelihood model.na <- ~ NA + RMexp(var=NA, scale=NA) fitted <- RFfit(model=model.na, data=simulated) # compare sample mean of data with ML estimate, which is very similar: mean(simulated@data[,1]) fitted
Here examples for much more advanced formula are given
NaN
, in contrast to NA
, signifies a unknown parameter
that can be calculated from other (unknown) parameters.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ################################################################# ### the following definitions are needed in all the examples ### ################################################################# V <- 10 S <- 0.3 M <- 3 x <- y <- seq(1, 3, 0.1) ################################################################# ### Example 1: simple example ### ################################################################# ## the following to definitions of a model and call of RFsimulate ## give the same result: model <- RMexp(var=V, scale=S) + M z1 <- RFsimulate(model = model, x=x, y=y) plot(z1) model <- ~ M + RMexp(var=var, scale=sc) p <- list(var=V, sc=S, M=M) z2 <- RFsimulate(model = model,x=x, y=y, param=p) plot(z2) ################################################################# ### Example 2: formulae within the parameter list ### ################################################################# ## free parameters (above 'var' and 'sc') can be used ## even within the definition of the list of 'param'eters model <- ~ RMexp(var=var, sc=sc) + RMnugget(var=nugg) p <- list(var=V, nugg= ~ var * abs(cos(sc)), sc=S) ## ordering does not matter! z1 <- RFsimulate(model, x, y, params=p) plot(z1) RFgetModel(RFsimulate) ## note that V * abs(cos(S) equals 9.553365 ## so the above is equivalent to model <- ~ RMexp(var=var, sc=sc) + RMnugget(var=var * abs(cos(sc))) z2 <- RFsimulate(model, x, y, params=list(var=V, sc=S)) plot(z2) ################################################################# ### Example 3: formulae for fitting (i.e. including NAs) ### ################################################################# ## first generate some data model <- ~ RMexp(var=var, sc=sc) + RMnugget(var=nugg) p <- list(var=V, nugg= ~ var * abs(cos(sc)), sc=S) z <- RFsimulate(model, x, y, params=p, n=10) ## estimate the parameters p.fit <- list(sc = NA, var=NA, nugg=NA) print(f <- RFfit(model, data=z, params=p.fit)) ## estimation with a given boundaries for the scale p.fit <- list(sc = NA, var=NA, nugg=NA) lower <- list(sc=0.01) upper <- list(sc=0.02) print(f <- RFfit(model, data=z, params=p.fit, lower = lower, upper = upper)) ################################################################# ### Example 4 (cont'd Ex 3): formulae with dummy variables ### ################################################################# V <- 10 S <- 0.3 M <- 3 x <- y <- seq(1, 3, 0.1) model <- ~ RMexp(sc=sc1, var=var) + RMgauss(var=var2, sc=sc2) + RMdeclare(u) ## introduces dummy variable 'u' p.fit <- list(sc1 = NA, var=NA, var2=~2 * u, sc2 = NA, u=NA) lower <- list(sc1=20, u=5) upper <- list(sc2=1.5, sc1=100, u=15) print(f <- RFfit(model, data=z, params=p.fit, lower = lower, upper = upper ))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ################################################################# ### the following definitions are needed in all the examples ### ################################################################# V <- 10 S <- 0.3 M <- 3 x <- y <- seq(1, 3, 0.1) ################################################################# ### Example 1: simple example ### ################################################################# ## the following to definitions of a model and call of RFsimulate ## give the same result: model <- RMexp(var=V, scale=S) + M z1 <- RFsimulate(model = model, x=x, y=y) plot(z1) model <- ~ M + RMexp(var=var, scale=sc) p <- list(var=V, sc=S, M=M) z2 <- RFsimulate(model = model,x=x, y=y, param=p) plot(z2) ################################################################# ### Example 2: formulae within the parameter list ### ################################################################# ## free parameters (above 'var' and 'sc') can be used ## even within the definition of the list of 'param'eters model <- ~ RMexp(var=var, sc=sc) + RMnugget(var=nugg) p <- list(var=V, nugg= ~ var * abs(cos(sc)), sc=S) ## ordering does not matter! z1 <- RFsimulate(model, x, y, params=p) plot(z1) RFgetModel(RFsimulate) ## note that V * abs(cos(S) equals 9.553365 ## so the above is equivalent to model <- ~ RMexp(var=var, sc=sc) + RMnugget(var=var * abs(cos(sc))) z2 <- RFsimulate(model, x, y, params=list(var=V, sc=S)) plot(z2) ################################################################# ### Example 3: formulae for fitting (i.e. including NAs) ### ################################################################# ## first generate some data model <- ~ RMexp(var=var, sc=sc) + RMnugget(var=nugg) p <- list(var=V, nugg= ~ var * abs(cos(sc)), sc=S) z <- RFsimulate(model, x, y, params=p, n=10) ## estimate the parameters p.fit <- list(sc = NA, var=NA, nugg=NA) print(f <- RFfit(model, data=z, params=p.fit)) ## estimation with a given boundaries for the scale p.fit <- list(sc = NA, var=NA, nugg=NA) lower <- list(sc=0.01) upper <- list(sc=0.02) print(f <- RFfit(model, data=z, params=p.fit, lower = lower, upper = upper)) ################################################################# ### Example 4 (cont'd Ex 3): formulae with dummy variables ### ################################################################# V <- 10 S <- 0.3 M <- 3 x <- y <- seq(1, 3, 0.1) model <- ~ RMexp(sc=sc1, var=var) + RMgauss(var=var2, sc=sc2) + RMdeclare(u) ## introduces dummy variable 'u' p.fit <- list(sc1 = NA, var=NA, var2=~2 * u, sc2 = NA, u=NA) lower <- list(sc1=20, u=5) upper <- list(sc2=1.5, sc1=100, u=15) print(f <- RFfit(model, data=z, params=p.fit, lower = lower, upper = upper ))
The function estimates the fractal dimension of a process
RFfractaldim(x, y = NULL, z = NULL, data, grid, bin=NULL, vario.n=5, sort=TRUE, fft.m = c(65, 86), ## in % of range of l.lambda fft.max.length=Inf, fft.max.regr=150000, fft.shift = 50, # in %; 50:WOSA; 100: no overlapping method=c("variogram", "fft"), mode = if (interactive ()) c("plot", "interactive") else "nographics", pch=16, cex=0.2, cex.main=0.85, printlevel = RFoptions()$basic$printlevel, height=3.5, ...)
RFfractaldim(x, y = NULL, z = NULL, data, grid, bin=NULL, vario.n=5, sort=TRUE, fft.m = c(65, 86), ## in % of range of l.lambda fft.max.length=Inf, fft.max.regr=150000, fft.shift = 50, # in %; 50:WOSA; 100: no overlapping method=c("variogram", "fft"), mode = if (interactive ()) c("plot", "interactive") else "nographics", pch=16, cex=0.2, cex.main=0.85, printlevel = RFoptions()$basic$printlevel, height=3.5, ...)
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
data |
the values measured; it can also be an sp object |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
bin |
sequence of bin boundaries for the empirical variogram |
vario.n |
first |
sort |
If |
fft.m |
numeric vector of two components; interval of frequencies for which the regression should be calculated; the interval is given in percent of the range of the frequencies in log scale. |
fft.max.length |
The first dimension of the data is cut into pieces
of length |
fft.max.regr |
If the |
fft.shift |
This argument is given in percent [of
|
method |
list of implemented methods to calculate the fractal dimension; see Details |
mode |
character. A vector with components
Usually only one mode is given. Two modes may make sense
in the combination |
pch |
vector or scalar; sign by which data are plotted. |
cex |
vector or scalar; size of |
cex.main |
The size of the title in the regression plots. |
printlevel |
integer. If |
height |
height of the graphics window |
... |
graphical arguments |
The function calculates the fractal dimension by various methods:
variogram method
Fourier transform
The function returns a list with elements
vario
,
fft
corresponding to
the 2 methods given in the Details.
Each of the elements is itself a list that contains the following elements.
x |
the x-coordinates used for the regression fit |
y |
the y-coordinates used for the regression fit |
regr |
the return list of the |
sm |
smoothed curve through the (x,y) points |
x.u |
|
y.u |
|
regr.u |
|
D |
the fractal dimension |
D.u |
|
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
variogram method
Constantine, A.G. and Hall, P. (1994) Characterizing surface smoothness via estimation of effective fractal dimension. J. R. Statist. Soc. Ser. B 56, 97-113.
fft
Chan, Hall and Poskitt (1995)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.001) z <- RFsimulate(RMexp(), x) RFfractaldim(data=z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.001) z <- RFsimulate(RMexp(), x) RFfractaldim(data=z)
Here, all the RF_name_
commands are listed.
RMmodels
The user's RMmodel
is supplemented internally by
operators that are tacitely assumed, e.g. RPgauss
.
Further completions of the user's model determine what should be
done with the model, e.g. calculation of the covariance
(RFcov
).
The following list gives those RFfunctions
that have
an internal representation as completion to the user's model.
RFcalc |
performs some simple calculations
based on R.models
|
RFcov |
assigns to a covariance model the covariance values at given locations |
RFcovmatrix |
assigns to a covariance model the matrix of covariance values at given locations |
RFdistr |
generic function assigning to a distribution family various values of the distribution |
RFfctn |
assigns to a model the
value of the function at given locations. In case of a covariance
model RFfctn is identical to RFcov .
|
RFlikelihood |
assigns to a model and a dataset the (log)likelihood value. |
RFlinearpart |
assigns to a model and a set of coordinates the linear part of the model, i.e. the deterministic trend and the design matrix. |
RFpseudovariogram |
assigns to a model the values of the pseudo variogram at given locations |
RFsimulate |
assigns to a model a realisation of the corresponding random field |
RFvariogram |
assigns to a model the values of the (cross-)variogram at given locations |
RFcrossvalidate |
cross validation for Gaussian fields |
RFvariogram |
empirical variogram |
RFfit |
(maximum likelihood) fitting of the parameters |
RFinterpolate |
'kriging' and 'imputing'
|
RFratiotest |
likelihood ratio test for Gaussian fields |
RFgui |
educational tool for |
* manual selection of a covariance model | |
* manual fitting to the empirical variogram | |
RFfractaldim |
determination of the fractal dimension |
RFhurst |
determination of the Hurst effect (long range dependence) |
RFearth2cartesian |
transformation of earth coordinates to cartesian coordinates |
RFearth2dist |
transformation of earth coordinates to Euclidean distances |
RFgetMethodNames |
currently implemented list of simulation methods |
RFgetModel |
returns the model used in a RFfunction , with some
more details
|
RFgetModelInfo |
similar to RFgetModel , but with detailed
information on the implementation
|
RFgetModelNames |
lists the implemented models |
RFoptions |
options of package RandomFields |
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RC, RM, RP,
RR, R.,
RMmodelgenerator
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again z <- RFsimulate(model=RMexp(), 1:10) RFgetModel(RFsimulate, show.call = TRUE) # user's definition RFgetModel(RFsimulate, show.call = FALSE) # main internal part
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again z <- RFsimulate(model=RMexp(), 1:10) RFgetModel(RFsimulate, show.call = TRUE) # user's definition RFgetModel(RFsimulate, show.call = FALSE) # main internal part
RFgetMethodNames
prints and returns a list of currently
implemented methods for simulating Gaussian random fields
and max stable random fields
RFgetMethodNames()
RFgetMethodNames()
By default, RFsimulate
automatically chooses an appropriate
method for simulation. The method can also be set explicitly by the
user via RFoptions
, in particular by passing
gauss.method=_a valid method string_
as an additional argument
to RFsimulate
or by globally changing the options via
RFoptions(gauss.method=_a valid method string_)
.
The following methods are available:
(random spatial) Averages
– details soon
Boolean functions.
See marked point processes.
circulant embedding
.
Introduced by Dietrich & Newsam (1993) and Wood and Chan (1994).
Circulant embedding is a fast simulation method based on Fourier transformations. It is garantueed to be an exact method for covariance functions with finite support, e.g. the spherical model.
See also cutoff embedding
and intrinsic embedding
for
variants of the method.
cutoff embedding
.
Modified circulant embedding method so that exact simulation is guaranteed
for further covariance models, e.g. the whittle matern model.
In fact, the circulant embedding is called with the cutoff
hypermodel, see RMmodel
, and there.
cutoff embedding
halfens the maximum number of
elements models used to define the covariance function of interest
(from 10 to 5).
Here, multiplicative models are not allowed (yet).
direct matrix decomposition
.
This method is based on the well-known method for simulating
any multivariate Gaussian distribution, using the square root of the
covariance matrix. The method is pretty slow and limited to
about 8000 points, i.e. a 20x20x20 grid in three dimensions.
This implementation can use the Cholesky decomposition and
the singular value decomposition.
It allows for arbitrary points and arbitrary grids.
hyperplane method
.
The method is based on a tessellation of the space by
hyperplanes. Each cell takes a spatially constant value
of an i.i.d. random variables. The superposition of several
such random fields yields approximatively a Gaussian random field.
intrinsic embedding
.
Modified circulant embedding so that exact simulation is guaranteed
for further variogram models, e.g. the fractal brownian one.
Note that the simulated random field is always non-stationary.
In fact, the circulant embedding is called with the Stein
hypermodel, see RMmodel
, and there.
Here, multiplicative models are not allowed (yet).
Marked point processes.
Some methods are based on marked point process
where the marks
are deterministic or i.i.d. random functions on
.
add.MPP
(Random coins).
Here the functions are elements
of the intersection
of the Hilbert spaces
and
.
A random field Z is obtained by adding the marks:
In this package, only stationary Poisson point fields
are allowed
as underlying unmarked point processes.
Thus, if the marks
are all indicator functions, we obtain
a Poisson random field. If the intensity of the Poisson
process is high we obtain an approximative Gaussian random
field by the central limit theorem - this is the
add.mpp
method.
max.MPP
(Boolean functions).
If the random functions are multiplied by suitable,
independent random values, and then the maximum is
taken, a max-stable random field with unit Frechet margins
is obtained - this is the max.mpp
method.
nugget
.
The method allows for generating a random field of
independent Gaussian random variables.
This method is called automatically if the nugget
effect is positive except the method "circulant embedding"
or "direct"
has been explicitly chosen.
The method has been extended to zonal anisotropies, see
also argument nugget.tol
in RFoptions
.
particular
method
– details missing –
Random coins.
See marked point processes.
sequential
This method is programmed for spatio-temporal models
where the field is modelled sequentially in the time direction
conditioned on the previous instances.
For
the method has its limits for about 1000 spatial
points. It is an approximative method. The larger
the
better.
It also works for certain grids where the last dimension should
contain the highest number of grid points.
spectral TBM
(Spectral turning bands).
The principle of spectral TBM
does not differ from the other
turning bands methods. However, line simulations are performed by a
spectral technique (Mantoglou and Wilson, 1982).
The standard method allows for the simulation of 2-dimensional random fields defined on arbitrary points or arbitrary grids. Here, a realisation is given as the cosine with random amplitude and random phase.
TBM2
, TBM3
(Turning bands methods; turning layers).
It is generally difficult to use the turning bands method
(TBM2
) directly
in the 2-dimensional space.
Instead, 2-dimensional random fields are frequently obtained
by simulating a 3-dimensional random field (using
TBM3
) and taking a 2-dimensional cross-section.
TBM3 allows for multiplicative models; in case of anisotropy the
anisotropy matrices must be multiples of the first matrix or the
anisotropy matrix consists of a time component only (i.e. all
components are zero except the very last one).TBM2
and TBM3
allow for arbitrary points, and
arbitrary grids
(arbitrary number of points in each direction, arbitrary grid length
for each direction).
Note: Both the precision and the simulation time
depend heavily on TBM*.linesimustep
and
TBM*.linesimufactor
that can be set by RFoptions
.
For covariance models with larger values of the scale parameter,
TBM*.linesimufactor=2
is too small.
The turning layers are used for the simulations with time component. Here, if the model is a multiplicative covariance function then the product may contain matrices with pure time component. All the other matrices must be equal up to a factor and the temporal part of the anisotropy matrix (right column) may contain only zeros, except the very last entry.
an invisible string vector of the Gaussian methods.
— details coming soon —
Most methods possess additional arguments,
see RFoptions()
that control the precision of the result. The default arguments
are chosen such that the simulations are fine for many models
and their parameters.
The example in RFvariogram()
shows a way of checking the precision.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. and Schlather, M. (2004) Statistical modeling with covariance functions. In preparation.
Lantuejoul, Ch. (2002) Geostatistical simulation. New York: Springer.
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
Original work:
Circulant embedding:
Chan, G. and Wood, A.T.A. (1997) An algorithm for simulating stationary Gaussian random fields. J. R. Stat. Soc., Ser. C 46, 171-181.
Dietrich, C.R. and Newsam, G.N. (1993) A fast and exact method for multidimensional Gaussian stochastic simulations. Water Resour. Res. 29, 2861-2869.
Dietrich, C.R. and Newsam, G.N. (1996) A fast and exact method for multidimensional Gaussian stochastic simulations: Extensions to realizations conditioned on direct and indirect measurement Water Resour. Res. 32, 1643-1652.
Wood, A.T.A. and Chan, G. (1994)
Simulation of stationary Gaussian processes in
J. Comput. Graph. Stat. 3, 409-432.
The code used in RandomFields is based on Dietrich and Newsam (1996).
Intrinsic embedding and Cutoff embedding:
Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. J. Comput. Graph. Statist. 11, 587–599.
Gneiting, T., Sevcikova, H., Percival, D.B., Schlather, M. and
Jiang, Y. (2005)
Fast and Exact Simulation of Large Gaussian Lattice Systems in
: Exploring the Limits
J. Comput. Graph. Statist. Submitted.
Markov Gaussian Random Field:
Rue, H. (2001) Fast sampling of Gaussian Markov random fields. J. R. Statist. Soc., Ser. B, 63 (2), 325-338.
Rue, H., Held, L. (2005) Gaussian Markov Random Fields: Theory and Applications. Monographs on Statistics and Applied Probability, no 104, Chapman \& Hall.
Turning bands method (TBM), turning layers:
Dietrich, C.R. (1995) A simple and efficient space domain implementation of the turning bands method. Water Resour. Res. 31, 147-156.
Mantoglou, A. and Wilson, J.L. (1982) The turning bands method for simulation of random fields using line generation by a spectral method. Water. Resour. Res. 18, 1379-1394.
Matheron, G. (1973) The intrinsic random functions and their applications. Adv. Appl. Probab. 5, 439-468.
Schlather, M. (2004) Turning layers: A space-time extension of turning bands. Submitted
Random coins:
Matheron, G. (1967) Elements pour une Theorie des Milieux Poreux. Paris: Masson.
RMmodel
,
RFsimulate
,
RandomFields.
RFgetMethodNames()
RFgetMethodNames()
The function returns the stored model.
RFgetModel(register, explicite.natscale, show.call=FALSE, origin="original")
RFgetModel(register, explicite.natscale, show.call=FALSE, origin="original")
register |
|
explicite.natscale |
logical. Advanced option.
If missing, then the model is returned as stored.
If |
show.call |
logical or character. If If |
origin |
character; one of |
Whereas
RFgetModel
returns a model that can be re-used
by the user,
RFgetModelInfo
can return detailed information.
The stored model is returned in list format.
Put Storing=TRUE
, see RFoptions
,
if you like to have (more)
internal information in case of failure of an initialization of
a random field simulation.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(scale=4, var=2) + RMnugget(var=3) + RMtrend(mean=1) z <- RFsimulate(model, 1:4) RFgetModel(show.call=FALSE) RFgetModel(show.call=TRUE)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(scale=4, var=2) + RMnugget(var=3) + RMtrend(mean=1) z <- RFsimulate(model, 1:4) RFgetModel(show.call=FALSE) RFgetModel(show.call=TRUE)
The function returns information about an RMmodel, either internal information when used in simulations, for instance, or general information
RFgetModelInfo(...) RFgetModelInfo_register(register, level = 1, spConform = RFoptions()$general$spConform, which.submodels = c("user", "internal", "call+user", "call+internal", "user.but.once", "internal.but.once", "user.but.once+jump", "internal.but.once+jump", "all"), modelname = NULL, origin = "original") RFgetModelInfo_model(model, params, dim = 1, Time = FALSE, kernel = FALSE, exclude_trend = TRUE, ...)
RFgetModelInfo(...) RFgetModelInfo_register(register, level = 1, spConform = RFoptions()$general$spConform, which.submodels = c("user", "internal", "call+user", "call+internal", "user.but.once", "internal.but.once", "user.but.once+jump", "internal.but.once+jump", "all"), modelname = NULL, origin = "original") RFgetModelInfo_model(model, params, dim = 1, Time = FALSE, kernel = FALSE, exclude_trend = TRUE, ...)
... |
See the argument of |
register |
|
level |
integer [0...5]; level of details, i.e. the higher the number the more details are given. |
spConform |
see |
which.submodels |
Internally, the sub-models are represented in two different ways: ‘internal’ and ‘user’. The latter is very close to the model defined by the user. Most models have a leading internal model.
The values The values The values The value |
modelname |
string. If |
model , params
|
object of class |
dim |
positive integer. Spatial dimension. |
Time |
logical. Should time be considered, too? |
kernel |
logical. Should the model be considered as a kernel? |
exclude_trend |
logical. Currently, only |
origin |
character; one of |
RFgetModelInfo
branches either into
RFgetModelInfo_register
or RFgetModelInfo_model
,
depending on the type of the first argument. The latter two are
usually not called by the user.
RFgetModelInfo
has three standard usages:
RFgetModelInfo()
returns internal information on the
last call of an RF
function.
RFgetModelInfo(RFfunction)
returns internal information on the
last call of RFfunction
.
RFgetModelInfo(RMmodel)
returns general information on
RMmodel
Whereas RFgetModelInfo()
can return detailed internal information,
RFgetModel
returns a model that can be re-used
by the user.
If RFgetModelInfo(model)
is called a list is returned with the
following elements:
trans.inv
: logical. Whether the model is translation
invariant (stationary)
isotropic
: logical. Whether the model is rotation
invariant (stationary)
NAs
: in case of an additive model it gives the number
of NAs in each submodel
minmax
: a data frame containing information on all
arguments set to NA
s
pmin
, pmax
: lower and upper endpoint of the
parameter values usually found in practice
type
: integer; recognized particularities of a parameter;
an explanation of the values is given after the table, if printed.
NAN
: the number of NAN
s found
min
, max
: mathematically valid lower and upper
endpoints of the parameter values
omin
, omax
: logical. If FALSE
the
respective mathematical endpoint is included
col
, row
: the dimension of the parameter.
If the parameter is a scalar then col = row = 1
. If it is a
vector then col = 1
.
bayes
: currently not used (always FALSE
)
Else a list of internal structure is returned.
Put Storing=TRUE
, see RFoptions
if you like to have more
internal information in case of failure of an initialisation of
a random field simulation.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
commandRFgetModel, RFsimulate
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(scale=4, var=2) + RMnugget(var=3) + RMtrend(mean=1) z <- RFsimulate(model, 1:4, storing=TRUE) RFgetModelInfo() model <- RMwhittle(scale=NA, var=NA, nu=NA) + RMnugget(var=NA) RFgetModelInfo(model)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(scale=4, var=2) + RMnugget(var=3) + RMtrend(mean=1) z <- RFsimulate(model, 1:4, storing=TRUE) RFgetModelInfo() model <- RMwhittle(scale=NA, var=NA, nu=NA) + RMnugget(var=NA) RFgetModelInfo(model)
Displays the names of covariance and
variogram models (see RMmodel
) and returns them as a
list. The user may
specify and group the models according to the following properties:
type of function ("positive definite"
,
"variogram"
, etc.)
whether the function depends on two arguments
("kernel"
) or on one argument only ("single variable"
)
types of isotropy
whether the model is an operator
whether the model is a normal scale mixture
whether the model has a finite range covariance
validity in certain dimensions of the coordinate space
maximal possible dimension of the coordinate space
uni- or multivariety
See Details
for an explanation and
RMmodelgenerator
for possible states (values) of these properties.
RFgetModelNames(type = RC_TYPE_NAMES, domain = RC_DOMAIN_NAMES, isotropy = RC_ISO_NAMES, operator = c(TRUE, FALSE), monotone = RC_MONOTONE_NAMES, implied_monotonicities = length(monotone) == 1, finiterange = c(TRUE, FALSE, NA), valid.in.dim = c(1, Inf), vdim = c(1, 5), group.by, exact.match = !missing(group.by), simpleArguments = FALSE, internal, newnames)
RFgetModelNames(type = RC_TYPE_NAMES, domain = RC_DOMAIN_NAMES, isotropy = RC_ISO_NAMES, operator = c(TRUE, FALSE), monotone = RC_MONOTONE_NAMES, implied_monotonicities = length(monotone) == 1, finiterange = c(TRUE, FALSE, NA), valid.in.dim = c(1, Inf), vdim = c(1, 5), group.by, exact.match = !missing(group.by), simpleArguments = FALSE, internal, newnames)
type , domain , isotropy , operator , monotone , finiterange , vdim
|
see constants for the definition of |
implied_monotonicities |
logical. If |
valid.in.dim |
an optional integer indicating the dimension of the space where the model is valid |
group.by |
an optional character string or |
exact.match |
logical. If not |
simpleArguments |
logical. If |
internal , newnames
|
both logical;
|
The plain call RFgetModelNames()
simply gives back a
vector of
the names of all implemented covariance and variogram models and operators,
i.e. members of the class
RMmodelgenerator
.
The following arguments can be specified.
In general, only exact matches are returned. One exception exists:
If the length of type
equals 1 and if group.by
is not
given, then types included in type
are also returned.
E.g. if type="variogram"
and group.by
is not given
then only models are returned that are negative definite.
However, also positive definite functions and tail correlaton
functions are returned if "type"
is included in group.by
.
type
specifies the class of functions; for
the meaning of the possible values see
RMmodelgenerator
stationarity
specifies the type of stationarity; for
the meaning of the possible values see
RMmodelgenerator
isotropy
specifies the type of isotropy; for
the meaning of the possible values see
RMmodelgenerator
operator
indicates whether the model is an operator,
i.e. it requires at least one submodel,
e.g. +
or
RMdelay
are operators; see
RMmodelgenerator
monotone
indicates what kind of monotonicity is known,
e.g., whether the model is a normal
scale mixture, the latter including RMexp
or
RMcauchy
; see
RMmodelgenerator
finiterange
indicates whether the covariance of the
model has finite range, e.g. RMcircular
or
RMnugget
have covariances with finite range; see
RMmodelgenerator
.
NA
is used if the finiteness depends on the submodel.
valid.in.dim
If valid.in.dim=n
is
passed, all models which are valid in dimension are
displayed. Otherwise
valid.in.dim
should be a bivariate vector
giving the range of requested dimensions.
maxdim
if a positive integer, it specifies the maximal
possible dimension of the coordinate space;
note that a model which is valid in dimension
is also valid in dimension
;
maxdim=-1
means that the maximal possible dimension depends
on the parameters of the RMmodel
object;
maxdim=-2
means that the maximal possible dimension is
adopted from the called submodels;
see also
RMmodelgenerator
vdim
if a positive integer, vdim specifies, whether
the model is -variate;
vdim=-1
means that being multivariate
in a certain dimension depends on the parameters of the
RMmodel
object;
vdim=-2
means that being multivariate
in a certain dimension is adopted from the called submodels;
see also
RMmodelgenerator
If vdim
is bivariate then a range is given.
group.by
If group.by="propertyname"
is
passed, the displayed models are grouped according to
propertyname
.
All arguments allow also for vectors of values. In case of
valid.in.dim
the smallest value is taken.
The interpretation is canonical.
Note that the arguments stationarity
, isotropy
,
operator
, monotone
, finiterange
,
maxdim
, vdim
are also slots (attributes) of the SP4-class
RMmodelgenerator
.
Either a vector of model names if the argument
group.by
is not used;
or a list of vectors of model names if the argument group.by
is
used
(with list elements specified by the categories of the grouping
argument).
In case internal
or newnames
is given,
RFgetModelNames
prints a table of the currently
implemented covariance functions and the matching methods.
RFgetModelNames
returns NULL
.
In case internal
or newnames
is given,
only the values of internal
,
newnames
and operator
are considered.
All the other arguments are ignored and
RFgetModelNames
prints a table of the currently
implemented covariance functions and the matching methods:
internal
:
if TRUE
also RMmodels
are listed that are
internal, hence invisible to the user. Default: FALSE
.
newnames
:
The model names of version 2 of RandomFields and earlier
can still be used in the model definitions. Namely when the
list notation is chosen; see Advanced RMmodels for the
latter. If internal
or newnames
is given, then
these old names are shown; if newnames=TRUE
then also the
usual names are shown.
Default: FALSE
.
In fact, both internal and public
models can have different variants implemented.
These variants are also shown if
internal
has a value greater than or equal to 2
,
operator
:
see above.
Here, also an indication is given, which method for simulating Gaussian random fields matches the model.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
constants,
RMmodelgenerator
,
RMmodel
,
RandomFields
,
RC_DOMAIN_NAMES, RC_ISO_NAMES
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # get list of names of all functions RFgetModelNames() # any kind of positive definite functions RFgetModelNames(type="positive definite", exact.match=TRUE) ## Not run: RFgetModelNames(type="positive definite") # get a list of names of all stationary models RFgetModelNames(type="positive definite", domain="single variable", exact.match=TRUE) ## Not run: RFgetModelNames(type="positive definite", domain="single variable") # get a vector of all model names RFgetModelNames(group.by=NULL)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # get list of names of all functions RFgetModelNames() # any kind of positive definite functions RFgetModelNames(type="positive definite", exact.match=TRUE) ## Not run: RFgetModelNames(type="positive definite") # get a list of names of all stationary models RFgetModelNames(type="positive definite", domain="single variable", exact.match=TRUE) ## Not run: RFgetModelNames(type="positive definite", domain="single variable") # get a vector of all model names RFgetModelNames(group.by=NULL)
RFgridDataFrame
Class for attributes in one-dimensional space.
## S4 method for signature 'RFgridDataFrame' RFspDataFrame2conventional(obj, data.frame=FALSE)
## S4 method for signature 'RFgridDataFrame' RFspDataFrame2conventional(obj, data.frame=FALSE)
obj |
an |
data.frame |
logical. If |
Objects can be created by using the functions
RFgridDataFrame
or
conventional2RFspDataFrame
or by calls of the form
as(x, "RFgridDataFrame")
, where x
is of class
RFgridDataFrame
.
.RFparams
:list of up to 5 elements;
n is the number
of repetitions of the random field contained in the data
slot
vdim
gives the dimension of the values of
the random
field, equals 1 in most cases
has.variance
indicates whether information on the variance is available,
coordunits
gives the names of the
units for the coordinates
varunits
gives the names of the
units for the variables
data
:object of class data.frame
,
containing attribute data
grid
:object of class GridTopology
.
signature(obj =
"RFgridDataFrame")
: generates nice plots
of the random field; if , a two-dimensional
subspace can be selected using the argument
MARGIN
; to get different slices in a third direction, the
argument MARGIN.slices
can be used;
for more details see plot-method
or type
method?plot("RFgridDataFrame")
signature(x = "RFgridDataFrame")
:
uses the show
-method for class SpatialGridDataFrame
.
signature(x = "RFgridDataFrame")
:
identical to show
-method
signature(obj =
"RFgridDataFrame")
: conversion to a list of
non-sp-package based objects; the data
-slot
is converted to an array of dimension
signature(x = "RFgridDataFrame")
:
returns the coordinates
signature(x = "RFgridDataFrame")
: selects
columns of data
-slot; returns an
object of class RFgridDataFrame
.
signature(x = "RFgridDataFrame")
: replaces
columns of data
-slot; returns an
object of class RFgridDataFrame
.
signature(x = "RFgridDataFrame")
:
converts into other formats, only implemented for target class
RFpointsDataFrame
signature(...)
: if arguments have identical
topology, combine their attribute values
signature(x = "RFgridDataFrame")
: returns the range
signature(x = "RFgridDataFrame")
: plots histogram
signature(x = "RFgridDataFrame")
: converts
data
-slot to matrix
signature(x = "RFgridDataFrame")
: converts
data
-slot to array
signature(x = "RFgridDataFrame")
: converts
data
-slot to vector
signature(x = "RFgridDataFrame")
:
converts data
-slot and coordinates to a data.frame
Methods summary
and dimensions
are defined for the “parent”-class
RFsp
.
Alexander Malinowski, Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFspatialGridDataFrame
,
which is for point
locations in higher dimensional spaces,
RFpointsDataFrame-class
which is for one-dimensional
arbitrary locations,
RFsp
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,10,length=100) f <- RFsimulate(model=RMgauss(), x=x, n=3) str(f) str(RFspDataFrame2conventional(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE plot(f, nmax=2)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,10,length=100) f <- RFsimulate(model=RMgauss(), x=x, n=3) str(f) str(RFspDataFrame2conventional(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE plot(f, nmax=2)
This is a nice instructive graphical tool useful in particular for teaching classes
RFgui(data, x, y, same.algorithm = TRUE, ev, bin = NULL, xcov, ycov, sim_only1dim=FALSE, wait = 0, ...)
RFgui(data, x, y, same.algorithm = TRUE, ev, bin = NULL, xcov, ycov, sim_only1dim=FALSE, wait = 0, ...)
data |
See |
x |
a |
y |
a |
same.algorithm |
Force the picture being simulated with the same algorithm so that the pictures are always directly comparable. The disadvantage is that some models are simulated only (very) approximatively. |
ev |
instead of the data, the empirical variogram itself might be passed |
bin |
only considered if |
xcov |
|
ycov |
Only for anisotropic models. |
sim_only1dim |
Logical. The argument determines whether a process should be simulated on the line or on the plane |
wait |
integer. See details. |
... |
further options and control arguments for the simulation
that are passed to and processed by |
If wait
is negative the xterm does not wait for the
tkltk-window to be finished. Further the variable RFgui.model
is created in the environment .GlobalEnv
and contains the
currently chosen variable in the gui. RFgui
always returns
NULL
.
If wait
is non-negative the xterm waits for the
tkltk-window to be finished. RFgui
returns invisibly
the last chosen model (or NULL
if no model has been chosen).
RFgui
idles a lot when wait=0
. It idles less for
higher values by sleeping about wait
microseconds. Of course
the handling in the tkltk window gets slower as well. Reasonable values
for wait
are within [0,1000]
.
same.alg = TRUE is equivalent to setting
circulant.trials=1
,
circulant.simu_method = "RPcirculant"
,
circulant.force=TRUE
,
circulant.mmin=-2
.
If wait < 0
the function returns NULL
else it returns the last chosen RMmodel
.
If wait < 0
,
a side effect of RFgui
is the creation of the variable RFgui.model
on .GlobalEnv
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Daphne Boecker; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
soil
for a further example
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgui()
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgui()
The function estimates the Hurst coefficient of a process
RFhurst(x, y = NULL, z = NULL, data, sort = TRUE, block.sequ = unique(round(exp(seq(log(min(3000, dimen[1]/5)), log(dimen[1]), len = min(100, dimen[1]))))), fft.m = c(1, min(1000, (fft.len - 1)/10)), fft.max.length = Inf, method = c("dfa", "fft", "var"), mode = if (interactive ()) c("plot", "interactive") else "nographics", pch = 16, cex = 0.2, cex.main = 0.85, printlevel = RFoptions()$basic$printlevel, height = 3.5, ...)
RFhurst(x, y = NULL, z = NULL, data, sort = TRUE, block.sequ = unique(round(exp(seq(log(min(3000, dimen[1]/5)), log(dimen[1]), len = min(100, dimen[1]))))), fft.m = c(1, min(1000, (fft.len - 1)/10)), fft.max.length = Inf, method = c("dfa", "fft", "var"), mode = if (interactive ()) c("plot", "interactive") else "nographics", pch = 16, cex = 0.2, cex.main = 0.85, printlevel = RFoptions()$basic$printlevel, height = 3.5, ...)
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
data |
the data |
sort |
logical. If |
block.sequ |
ascending sequences of block lengths for which the detrended fluctuation analysis and the variance method are performed. |
fft.m |
vector of 2 integers; lower and upper endpoint of indices for the frequency which are used in the calculation of the regression line for the periodogram near the origin. |
fft.max.length |
if the number of points in |
method |
list of implemented methods to calculate the Hurst parameter; see Details |
mode |
character. A vector with components
Usually only one mode is given. Two modes may make sense in the combination c("plot", "interactive") in which case all the results are plotted first, and then the interactive mode is called. In the interactive mode, the regression domain is chosen by two mouse clicks with the left mouse; a right mouse click leaves the plot. |
pch |
vector or scalar; sign by which data are plotted. |
cex |
vector or scalar; size of |
cex.main |
font size for title in regression plot;
only used if mode includes |
printlevel |
integer. If |
height |
height of the graphics window |
... |
graphical arguments |
The function is still in development. Several functionalities do not exist - see the code itself for the current stage.
The function calculates the Hurst coefficient by various methods:
detrended fluctuation analysis (dfa)
aggregated variation (var)
periodogram or WOSA estimator (fft)
The function returns a list with elements
dfa
, varmeth
, fft
corresponding to
the three methods given in the Details.
Each of the elements is itself a list that contains the following elements.
x |
the x-coordinates used for the regression fit |
y |
the y-coordinates used for the regression fit |
regr |
the coefficients of the |
sm |
smoothed curve through the (x,y) points |
x.u |
|
y.u |
|
regr.u |
|
H |
the Hurst coefficient |
H.u |
|
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
detrended fluctuation analysis
Peng, C.K., Buldyrev, S.V., Havlin, S., Simons, M., Stanley, H.E. and Goldberger, A.L. (1994) Mosaic organization of DNA nucleotides Phys. Rev. E 49, 1685-1689
aggregated variation
Taqqu, M.S. and Teverovsky, V. (1998) On estimating the intensity of long range dependence in finite and infinite variance time series. In: Adler, R.J., Feldman, R.E., and Taqqu, M.S. A Practical Guide to Heavy Tails, Statistical Techniques an Applications. Boston: Birkhaeuser
Taqqu, M.S. and Teverovsky, V. and Willinger, W. (1995) Estimators for long-range dependence: an empirical study. Fractals 3, 785-798
periodogram
Percival, D.B. and Walden, A.T. (1993) Spectral Analysis for Physical Applications: Multitaper and Conventional Univariate Techniques, Cambridge: Cambridge University Press.
Welch, P.D. (1967) The use of Fast Fourier Transform for the estimation of power spectra: a method based on time averaging over short, modified periodograms IEEE Trans. Audio Electroacoustics 15, 70-73.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- runif(1000) h <- RFhurst(1:length(x), data=x)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- runif(1000) h <- RFhurst(1:length(x), data=x)
The function allows for different methods of interpolation. Currently, only various kinds of kriging are installed.
RFinterpolate(model, x, y = NULL, z = NULL, T = NULL, grid=NULL, distances, dim, data, given=NULL, params, err.model, err.params, ignore.trend = FALSE, ...)
RFinterpolate(model, x, y = NULL, z = NULL, T = NULL, grid=NULL, distances, dim, data, given=NULL, params, err.model, err.params, ignore.trend = FALSE, ...)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
distances , dim
|
another alternative for the argument |
data |
matrix, data.frame or object of class If the argument
|
given |
optional, matrix or list. If |
err.model , err.params
|
For conditional simulation and random imputing
only. |
ignore.trend |
logical. If |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
In case of repeated data, they are kriged
separately; if the argument x
is missing,
data
may contain NA
s, which are then replaced by
the kriged values (imputing);
In case of intrinsic cokriging (intrinsic kriging for multivariate random fields) the pseudo-cross-variogram is used (cf. Ver Hoef and Cressie, 1991).
The value depends on the additional argument variance.return
,
see RFoptions
.
If variance.return=FALSE
(default), Kriging
returns a
vector or matrix of kriged values corresponding to the
specification of x
, y
, z
, and
grid
, and data
.
data
: a vector or matrix with one column
* grid=FALSE
. A vector of simulated values is
returned (independent of the dimension of the random field)
* grid=TRUE
. An array of the dimension of the
random field is returned (according to the specification
of x
, y
, and z
).
data
: a matrix with at least two columns
* grid=FALSE
. A matrix with the ncol(data)
columns
is returned.
* grid=TRUE
. An array of dimension
, where
is the dimension of
the random field, is returned (according to the specification
of
x
, y
, and z
). The last
dimension contains the realisations.
If variance.return=TRUE
, a list of two elements, estim
and
var
, i.e. the kriged field and the kriging variances,
is returned. The format of estim
is the same as described
above. The format of var
is accordingly.
Important options are
method
(overwriting the automatically detected variant
of kriging)
return_variance
(returning also the kriging variance)
locmaxm
(maximum number of conditional values before
neighbourhood kriging is performed)
fillall
imputing estimates location by default
varnames
and coordnames
in case
data.frame
s are used to tell which column contains the data
and the coordinates, respectively.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/; Marco Oesting, [email protected], https://www.isa.uni-stuttgart.de/institut/team/Oesting/
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/; Alexander Malinowski; Marco Oesting, [email protected], https://www.isa.uni-stuttgart.de/institut/team/Oesting/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
Cressie, N.A.C. (1993) Statistics for Spatial Data. New York: Wiley.
Goovaerts, P. (1997) Geostatistics for Natural Resources Evaluation. New York: Oxford University Press.
Ver Hoef, J.M. and Cressie, N.A.C. (1993) Multivariate Spatial Prediction. Mathematical Geology 25(2), 219-240.
Wackernagel, H. (1998) Multivariate Geostatistics. Berlin: Springer, 2nd edition.
RMmodel
,
RFvariogram
,
RandomFields
,
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Preparation of graphics dev.new(height=7, width=16) ## creating random variables first ## here, a grid is chosen, but does not matter p <- 3:8 points <- as.matrix(expand.grid(p,p)) model <- RMexp() + RMtrend(mean=1) dta <- RFsimulate(model, x=points) plot(dta) x <- seq(0, 9, 0.25) ## Simple kriging with the exponential covariance model model <- RMexp() z <- RFinterpolate(model, x=x, y=x, data=dta) plot(z, dta) ## Simple kriging with mean=4 and scaled covariance model <- RMexp(scale=2) + RMtrend(mean=4) z <- RFinterpolate(model, x=x, y=x, data=dta) plot(z, dta) ## Ordinary kriging model <- RMexp() + RMtrend(mean=NA) z <- RFinterpolate(model, x=x, y=x, data=dta) plot(z, dta) ## Co-Kriging n <- 100 x <- runif(n=n, min=1, max=50) y <- runif(n=n, min=1, max=50) rho <- matrix(nc=2, c(1, -0.8, -0.8, 1)) model <- RMparswmX(nudiag=c(0.5, 0.5), rho=rho) ## generation of artifical data data <- RFsimulate(model = model, x=x, y=y, grid=FALSE) ## introducing some NAs ... print(data) len <- length(data) data@data$variable1[1:(len / 10)] <- NA data@data$variable2[len - (0:len / 100)] <- NA print(data) plot(data) ## co-kriging x <- y <- seq(0, 50, 1) k <- RFinterpolate(model, x=x, y=y, data= data) plot(k, data) ## conditional simulation z <- RFsimulate(model, x=x, y=y, data= data) ## takes some time plot(z, data) close.screen(all = TRUE)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Preparation of graphics dev.new(height=7, width=16) ## creating random variables first ## here, a grid is chosen, but does not matter p <- 3:8 points <- as.matrix(expand.grid(p,p)) model <- RMexp() + RMtrend(mean=1) dta <- RFsimulate(model, x=points) plot(dta) x <- seq(0, 9, 0.25) ## Simple kriging with the exponential covariance model model <- RMexp() z <- RFinterpolate(model, x=x, y=x, data=dta) plot(z, dta) ## Simple kriging with mean=4 and scaled covariance model <- RMexp(scale=2) + RMtrend(mean=4) z <- RFinterpolate(model, x=x, y=x, data=dta) plot(z, dta) ## Ordinary kriging model <- RMexp() + RMtrend(mean=NA) z <- RFinterpolate(model, x=x, y=x, data=dta) plot(z, dta) ## Co-Kriging n <- 100 x <- runif(n=n, min=1, max=50) y <- runif(n=n, min=1, max=50) rho <- matrix(nc=2, c(1, -0.8, -0.8, 1)) model <- RMparswmX(nudiag=c(0.5, 0.5), rho=rho) ## generation of artifical data data <- RFsimulate(model = model, x=x, y=y, grid=FALSE) ## introducing some NAs ... print(data) len <- length(data) data@data$variable1[1:(len / 10)] <- NA data@data$variable2[len - (0:len / 100)] <- NA print(data) plot(data) ## co-kriging x <- y <- seq(0, 50, 1) k <- RFinterpolate(model, x=x, y=y, data= data) plot(k, data) ## conditional simulation z <- RFsimulate(model, x=x, y=y, data= data) ## takes some time plot(z, data) close.screen(all = TRUE)
RMmodel
RFlinearpart
returns the linear part of a model
RFlinearpart(model, x, y = NULL, z = NULL, T = NULL, grid=NULL, data, params, distances, dim, set=0, ...)
RFlinearpart(model, x, y = NULL, z = NULL, T = NULL, grid=NULL, data, params, distances, dim, set=0, ...)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
distances , dim
|
another alternative for the argument |
data |
matrix, data.frame or object of class |
set |
integer. See section Value for details. |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
RFlinearpart
returns a list
of three components, Y
, X
, vdim
returning
the deterministic trend, the design matrix, and the multivariability,
respectively.
If set
is positive, Y
and X
contain
the values for the set
-th set of coordinates.
Else, Y
and X
are both lists containing
the values for all the sets.
In the linear part of the model specification the parameters
that are NA must be the first model part. I.e.
NA * sin(R.p(new="isotropic")) + NA + R.p(new="isotropic")
is OK, but not
sin(R.p(new="isotropic")) * NA + NA + R.p(new="isotropic")
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Bayesian,
RMmodel
,
RFsimulate
,
RFlikelihood
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, pi, len=10) trend <- 2 * sin(R.p(new="isotropic")) + 3 model <- RMexp(var=2, scale=1) + trend print(RFlinearpart(model, x=x)) ## only a deterministic part trend <- NA * sin(R.p(new="isotropic")) + NA + R.p(new="isotropic") / pi model <- RMexp(var=NA, scale=NA) + trend print(RFlinearpart(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, pi, len=10) trend <- 2 * sin(R.p(new="isotropic")) + 3 model <- RMexp(var=2, scale=1) + trend print(RFlinearpart(model, x=x)) ## only a deterministic part trend <- NA * sin(R.p(new="isotropic")) + NA + R.p(new="isotropic") / pi model <- RMexp(var=NA, scale=NA) + trend print(RFlinearpart(model, x=x))
RFloglikelihood
returns the log likelihood for Gaussian
random fields. In case NAs are given that refer to linear modeling, the
ML of the linear model is returned.
RFlikelihood(model, x, y = NULL, z = NULL, T = NULL, grid = NULL, data, params, distances, dim, likelihood, estimate_variance =NA, ...)
RFlikelihood(model, x, y = NULL, z = NULL, T = NULL, grid = NULL, data, params, distances, dim, likelihood, estimate_variance =NA, ...)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
distances , dim
|
another alternative for the argument |
data |
matrix, data.frame or object of class |
likelihood |
Not programmed yet. Character.
Choice of kind of likelihood ("full", "composite", etc.),
see also |
estimate_variance |
logical or |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
The function calculates the likelihood for data of a Gaussian process
with given covariance structure.
The covariance structure may not have NA
values in the
parameters except for a global variance. In this case the variance
is returned that maximizes the likelihood.
Additional to the covariance structure the model may include a
trend. The latter may contain unknown linear parameters.
In this case again, the unknown parameters are estimated, and returned.
RFloglikelihood
returns a list
containing the likelihood, the log likelihood, and
the global variance (if estimated – see details).
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Bayesian,
RMmodel
,
RFfit
,
RFsimulate
,
RFlinearpart
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again requireNamespace("mvtnorm") pts <- 4 repet <- 3 model <- RMexp() x <- runif(n=pts, min=-1, max=1) y <- runif(n=pts, min=-1, max=1) dta <- as.matrix(RFsimulate(model, x=x, y=y, n=repet, spC = FALSE)) print(cbind(x, y, dta)) print(system.time(likeli <- RFlikelihood(model, x, y, data=dta))) str(likeli, digits=8) L <- 0 C <- RFcovmatrix(model, x, y) for (i in 1:ncol(dta)) { print(system.time(dn <- mvtnorm::dmvnorm(dta[,i], mean=rep(0, nrow(dta)), sigma=C, log=TRUE))) L <- L + dn } print(L) stopifnot(all.equal(likeli$log, L)) pts <- 4 repet <- 1 trend <- 2 * sin(R.p(new="isotropic")) + 3 #trend <- RMtrend(mean=0) model <- 2 * RMexp() + trend x <- seq(0, pi, len=pts) dta <- as.matrix(RFsimulate(model, x=x, n=repet, spC = FALSE)) print(cbind(x, dta)) print(system.time(likeli <- RFlikelihood(model, x, data=dta))) str(likeli, digits=8) L <- 0 tr <- RFfctn(trend, x=x, spC = FALSE) C <- RFcovmatrix(model, x) for (i in 1:ncol(dta)) { print(system.time(dn <- mvtnorm::dmvnorm(dta[,i], mean=tr, sigma=C,log=TRUE))) L <- L + dn } print(L) stopifnot(all.equal(likeli$log, L)) pts <- c(3, 4) repet <- c(2, 3) trend <- 2 * sin(R.p(new="isotropic")) + 3 model <- 2 * RMexp() + trend x <- y <- dta <- list() for (i in 1:length(pts)) { x[[i]] <- list(x = runif(n=pts[i], min=-1, max=1), y = runif(n=pts[i], min=-1, max=1)) dta[[i]] <- as.matrix(RFsimulate(model, x=x[[i]]$x, y=x[[i]]$y, n=repet[i], spC = FALSE)) } print(system.time(likeli <- RFlikelihood(model, x, data=dta))) str(likeli, digits=8) L <- 0 for (p in 1:length(pts)) { tr <- RFfctn(trend, x=x[[p]]$x, y=x[[p]]$y,spC = FALSE) C <- RFcovmatrix(model, x=x[[p]]$x, y=x[[p]]$y) for (i in 1:ncol(dta[[p]])) { print(system.time(dn <- mvtnorm::dmvnorm(dta[[p]][,i], mean=tr, sigma=C, log=TRUE))) L <- L + dn } } print(L) stopifnot(all.equal(likeli$log, L))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again requireNamespace("mvtnorm") pts <- 4 repet <- 3 model <- RMexp() x <- runif(n=pts, min=-1, max=1) y <- runif(n=pts, min=-1, max=1) dta <- as.matrix(RFsimulate(model, x=x, y=y, n=repet, spC = FALSE)) print(cbind(x, y, dta)) print(system.time(likeli <- RFlikelihood(model, x, y, data=dta))) str(likeli, digits=8) L <- 0 C <- RFcovmatrix(model, x, y) for (i in 1:ncol(dta)) { print(system.time(dn <- mvtnorm::dmvnorm(dta[,i], mean=rep(0, nrow(dta)), sigma=C, log=TRUE))) L <- L + dn } print(L) stopifnot(all.equal(likeli$log, L)) pts <- 4 repet <- 1 trend <- 2 * sin(R.p(new="isotropic")) + 3 #trend <- RMtrend(mean=0) model <- 2 * RMexp() + trend x <- seq(0, pi, len=pts) dta <- as.matrix(RFsimulate(model, x=x, n=repet, spC = FALSE)) print(cbind(x, dta)) print(system.time(likeli <- RFlikelihood(model, x, data=dta))) str(likeli, digits=8) L <- 0 tr <- RFfctn(trend, x=x, spC = FALSE) C <- RFcovmatrix(model, x) for (i in 1:ncol(dta)) { print(system.time(dn <- mvtnorm::dmvnorm(dta[,i], mean=tr, sigma=C,log=TRUE))) L <- L + dn } print(L) stopifnot(all.equal(likeli$log, L)) pts <- c(3, 4) repet <- c(2, 3) trend <- 2 * sin(R.p(new="isotropic")) + 3 model <- 2 * RMexp() + trend x <- y <- dta <- list() for (i in 1:length(pts)) { x[[i]] <- list(x = runif(n=pts[i], min=-1, max=1), y = runif(n=pts[i], min=-1, max=1)) dta[[i]] <- as.matrix(RFsimulate(model, x=x[[i]]$x, y=x[[i]]$y, n=repet[i], spC = FALSE)) } print(system.time(likeli <- RFlikelihood(model, x, data=dta))) str(likeli, digits=8) L <- 0 for (p in 1:length(pts)) { tr <- RFfctn(trend, x=x[[p]]$x, y=x[[p]]$y,spC = FALSE) C <- RFcovmatrix(model, x=x[[p]]$x, y=x[[p]]$y) for (i in 1:ncol(dta[[p]])) { print(system.time(dn <- mvtnorm::dmvnorm(dta[[p]][,i], mean=tr, sigma=C, log=TRUE))) L <- L + dn } } print(L) stopifnot(all.equal(likeli$log, L))
Calculates the empirical (cross-)madogram. The empirical
(cross-)madogram of two random fields and
is given by
where , and where
denotes the number of pairs of data points with distancevector
.
RFmadogram(model, x, y=NULL, z=NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL)
RFmadogram(model, x, y=NULL, z=NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
distances , dim
|
another alternative for the argument |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
data |
matrix, data.frame or object of class |
bin |
a vector giving the borders of the bins; If not specified an array describing the empirical (pseudo-)(cross-) covariance function in every direction is returned. |
phi |
an integer defining the number of sectors one half of the X/Y plane shall be divided into. If not specified, either an array is returned (if bin missing) or isotropy is assumed (if bin specified). |
theta |
an integer defining the number of sectors one half of the X/Z plane shall be divided into. Use only for dimension |
deltaT |
vector of length 2, specifying the temporal bins. The internal bin vector becomes |
vdim |
the number of variables of a multivariate data set. If not given and |
RFmadogram
computes the empirical
cross-madogram for given (multivariate) spatial data.
The spatial coordinates x
, y
, z
should be vectors. For random fields of
spatial dimension write all vectors as columns of matrix x. In
this case do neither use y, nor z and write the columns in
gridtriple
notation.
If the data is spatially located on a grid a fast algorithm based on
the fast Fourier transformed (fft) will be used.
As advanced option the calculation method can also be changed for grid
data (see RFoptions
.)
It is also possible to use RFmadogram
to calculate
the pseudomadogram (see RFoptions
).
RFmadogram
returns objects of class
RFempVariog
.
Jonas Auel; Sebastian Engelke; Johannes Martini; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
Stein, M. L. (1999) Interpolation of Spatial Data. New York: Springer-Verlag
RMstable
,
RMmodel
,
RFsimulate
,
RFfit
,
RFcov
,
RFpseudomadogram
.
RFvariogram
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 1 ## use n <- 2 for better results ## isotropic model model <- RMexp() x <- seq(0, 10, 0.02) z <- RFsimulate(model, x=x, n=n) emp.vario <- RFmadogram(data=z) plot(emp.vario) ## anisotropic model model <- RMexp(Aniso=cbind(c(2,1), c(1,1))) x <- seq(0, 10, 0.05) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFmadogram(data=z, phi=4) plot(emp.vario) ## space-time model model <- RMnsst(phi=RMexp(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.05) T <- c(0, 0.1, 100) z <- RFsimulate(x=x, T=T, model=model, n=n) emp.vario <- RFmadogram(data=z, deltaT=c(10, 1)) plot(emp.vario, nmax.T=3) ## multivariate model model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFmadogram(data=z) plot(emp.vario) ## multivariate and anisotropic model model <- RMbiwm(A=matrix(c(1,1,1,2), nc=2), nudiag=c(0.5,2), s=c(3, 1, 2), c=c(1, 0, 1)) x <- seq(0, 20, 0.1) dta <- RFsimulate(model, x, x, n=n) ev <- RFmadogram(data=dta, phi=4) plot(ev, boundaries=FALSE)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 1 ## use n <- 2 for better results ## isotropic model model <- RMexp() x <- seq(0, 10, 0.02) z <- RFsimulate(model, x=x, n=n) emp.vario <- RFmadogram(data=z) plot(emp.vario) ## anisotropic model model <- RMexp(Aniso=cbind(c(2,1), c(1,1))) x <- seq(0, 10, 0.05) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFmadogram(data=z, phi=4) plot(emp.vario) ## space-time model model <- RMnsst(phi=RMexp(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.05) T <- c(0, 0.1, 100) z <- RFsimulate(x=x, T=T, model=model, n=n) emp.vario <- RFmadogram(data=z, deltaT=c(10, 1)) plot(emp.vario, nmax.T=3) ## multivariate model model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFmadogram(data=z) plot(emp.vario) ## multivariate and anisotropic model model <- RMbiwm(A=matrix(c(1,1,1,2), nc=2), nudiag=c(0.5,2), s=c(3, 1, 2), c=c(1, 0, 1)) x <- seq(0, 20, 0.1) dta <- RFsimulate(model, x, x, n=n) ev <- RFmadogram(data=dta, phi=4) plot(ev, boundaries=FALSE)
This function is written only for package writers who have based their code on RandomFields version 2.
It avoids warnings if the old style is used, and sets
spConform = FALSE
.
RFoldstyle(old=TRUE)
RFoldstyle(old=TRUE)
old |
logical |
NULL
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
See ‘version2’ for details on the commands of version 2.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again GaussRF(x=1:10, model="exp", param=c(0,1,0,1), grid=TRUE) RFoldstyle() GaussRF(x=1:10, model="exp", param=c(0,1,0,1), grid=TRUE)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again GaussRF(x=1:10, model="exp", param=c(0,1,0,1), grid=TRUE) RFoldstyle() GaussRF(x=1:10, model="exp", param=c(0,1,0,1), grid=TRUE)
RFoptions
sets and returns control arguments for the analysis
and the simulation of random fields. It expands the functionality of
RFoptions.
RFoptions(...)
arguments in tag = value
form, or a list of tagged
values.
The subsections below comment on
0. basic
: See RFoptions
1. general
: General options
2. br
: Options for Brown-Resnick
Fields
3. circulant
: Options for circulant embedding methods
RPcirculant
4. coords
: Options for coordinates and units, see
coordinate systems
5. direct
: Options for simulating by simple matrix decomposition
6. distr
: Options for distributions, in particular RRrectangular
7. empvario
: Options for calculating the empirical variogram
8. fit
: Options for RFfit
,
RFratiotest
, and RFcrossvalidate
9. gauss
: Options for simulating Gaussian random fields
10. graphics
: Options for graphical output
11. gui
: Options for RFgui
12. hyper
: Options for simulating hyperplane tessellations
13. krige
: Options for Kriging
14. maxstable
: Options for simulating max-stable random fields
15. mpp
: Options for the random coins (shot noise) methods
16. nugget
: Options for the nugget effect
17. registers
: Register numbers
18. sequ
: Options for the sequential method
19. solve
: Options for solving linear systems
20. special
: Options for some special methods
21. spectral
: Options for the spectral (turning bands) method
22. tbm
: Options for the turning bands method
23. internal
: Internal
1. General options
allowdistanceZero
boolean. Only used in
RFinterpolate
and in RFfit
.
If true, then
multiple observations or identical locations
are allowed within a single data set.
In this case, the coordinates are slightly scattered, so that
the points have some tiny distances.
Default: FALSE
.
cPrintlevel
cPrintlevel
is automatically set to printlevel
when printlevel
is changed.
Standard users will never use a value higher than 3.
0 : no messages
1 : messages and warnings when the user's input looks odd
2 : messages (and internal errors) documenting the choice of the
simulation method
3 : further user relevant informations
4 : information on recursive function calls
5 : function flow information of central functions
6 : errors that are internally treated
7 : details on building up the covariance structure
8 : details on taking the square root of the covariance matrix
9 : details on intermediate calculations
10 : further details on intermediate calculations
Note that printlevel
works
on the R level whereas cPrintlevel
works on the C level.
Default: 1
detailed_output
logical.
if TRUE
some function, e.g. RFcrossvalidate
will return additional information.
every
integer.
if greater than zero, then every every
th iteration is
printed if simulated by TBM or random coin method. The value zero
means that nothing is printed.
Default: 0
exactness
logical or NA. Currently only used when simulating Gaussian random fields.
TRUE
: RPcoins
,
RPhyperplane
, RPsequential
,
RPspectral
and RPtbm
and
approximative circulant embedding are excluded.
If the circulant embedding method is considered as badly
behaved, then the matrix decomposition methods are preferred.
FALSE
: all the methods are allowed.
If the circulant embedding method is
considered as badly behaved or the number of points to be
simulated is large, the turning bands methods are
rather preferred.
NA
: Similar to FALSE
, but
some inexact algorithms get less preference.
Default: NA
.
expected_number_simu
positive integer which is usally set
internally as the value of the argument n
in
RFsimulate
. The argument expected_number_simu
should be set only by an advanced users and only if
RFsimulate
will be called with argument n
alone.
gridtolerance
used in RFsimulate
to see if the coordinates build a
grid for x, y, z, T-values. This argument is also used
in case of conditional
simulation where the data locations might ly on
a grid.
Default: 1e-6
logical. Lists of arguments are treated slightly
different from non-lists. If asList=FALSE
they are treated the
same way as non-lists. This options being set to FALSE
after
calling RFoptions
it should be set as first element of a list.
Default: TRUE
modus_operandi
character. One of the values
"careless"
, "sloppy"
, "easygoing"
,
"normal"
, "precise"
, "pedantic"
,
"neurotic"
.
This argument is in an experimental stage and its definition
and effects will change very likely in near future.
This argument sets a lot of argument at once related to estimation
and simulation. "careless"
prefers rather fast algorithms,
but the results
might be very rough approximations. By way of contrast,
"neurotic"
will try very
hard to return exact result at the cost of hugh computing times.
Default: "normal"
na_rm_lines
logical. If TRUE
then a line of the data that contains a
NA
value is deleted. Otherwise it is tried to deal with the
NA
value at higher costs of computing time. (Only used for
kriging – estimation can fully deal with NA
s.)
Default: FALSE
.
output
character.
one of the values "sp"
(if and only if
spConform=TRUE
),
"RandomFields"
(if and only if spConform=FALSE
),
"geoR"
.
The output mode geoR
currently adds some attributes such as
the call of the function.
NOTE: output
is in an experimental stage, whose effects might
change in future. Currently, output
changes the values of
reportcoord
, returncall
and spConform
.
pch
character.
RFfit
: shown before evaluating any method;
if pch!=""
then one or two
additional steps in the MLE methods are
marked by “+” and “#”.
Simulation:
The character is printed after each
performed simulation if more than one simulation is performed at
once. If pch='!'
then an absolute
counter is shown instead of the character.
If pch='%'
then a
counter of percentages is shown instead of the character.
Note that also ‘H’s are printed in
the last two cases,
which may have undesirable interactions with some few other R
functions, e.g.
Sweave
.
Default: '*'
.
practicalrange
logical or integer.
If not FALSE
the range of primitive
covariance functions is
adjusted so that cov(1) is zero for models with finite range.
(Operators are too complex to be adjusted; for anisotropic
covariance the practical range is not well defined.)
The value of cov(1) is about 0.05 (for scale=1
)
for models without range. See RMmodel
or type
RFgetModelNames(type="positive definite",
domain="single variable", isotropy="isotropic", operator=FALSE, vdim=1)
for the list of primitive models.
FALSE
: the practical range ajustment is not used.
TRUE
: practicalrange
is applicable only if
the value is known exactly, or, at least, can be approximated by
a closed formula.
2
: if the practical range is not known exactly it
is approximated numerically.
Default: FALSE
.
printlevel
If printlevel
there is not any output on the screen. The
higher the number the more tracing information is given.
Standard users will never use a value higher than 3.
0 : no messages
1 : important (error) messages and warnings
2 : less important messages
3 : details, but still for the user
4 : recursive call tracing (only used within RFfit
)
5 : function flow information of large functions
6 : errors that are internally treated
7 : details on intermediate calculations
8 : further details on intermediate calculations
Default: 1
character.
Current values are "always"
, "important"
,
"warn"
, "never"
,
Both "warn"
and "important"
have any effect only
if the coordinate system is changed internally. In this case
"warn"
yields a displayed warning message whereas
"important"
adds an attribute to the result as in the
case "always"
.
If "always"
or "important"
the reports are added as attribute to the results.
Note that in this case the class of the result may change
(e.g. from "numeric"
to "atomic"
).
Default: "warn"
logical. If TRUE
then the call is returned as an attribute
Default: TRUE
integer. If NULL
or NA
set.seed
is not called.
Otherwise, set.seed(seed)
is set
before simulations are performed, e.g. by
RFsimulate
or RFdistr
.
If the argument is set locally, i.e., within a function,
it has the usual local effect. If it is set globally, i.e. by
RFoptions
the seed
is fixed
for all subsequent calls.
If the number of simulations n
is greater than one
and if RFoptions(seed=seed)
is set, the th
simulation is started with the seed ‘
seed
’.
Note also that RFratiotest
has its own argument
seed
with a slightly different meaning.
(does not work yet)
This argument is important iff RFsimulate
is used within
a function from package parallel.
The value of seed_incr
should be set only locally, i.e. not
by RFoptions()
.
If seed_incr != 0
(or the number of simulations n
is
greater than 1) and !is.na(seed)
then the seed for each simulation is calculated as
seed
seed_sub_incr
seed_incr
where runs from 1 to
n
.
Default: 0
set
integer.
Certain models (e.g. RMfixcov
and
RMcovariate
)
allow for lists as arguments.
set
selects a certain list element.
If necessary the list is recycled.
spConform
logical.
spConform=TRUE
might be used by
a standard user as this allows the comfortable use of plot
,
for instance, while spConform=FALSE
is much faster and
and consumes much less memory, hence might
be used by programmers or advanced users.
Details: if spConform=TRUE
then RFsimulate
and
many other functions
return an sp
-object (which is an S4 object). Otherwise, matrices
or lists are
returned as defined in RandomFields 2.0, see the manuals for the
specific functions. Frequently, the latter have now a class attribute
to make the output nicer.
Note: for large data sets (to be generated),
spConform=TRUE
should not be used.
See also output
.
Default: TRUE
skipchecks
logical.
If TRUE
, several checks whether the given parameter values
and the dimension are within the allowed range is skipped.
Do not change the value of this variable except you really
know what you do.
Default: FALSE
$
storing
Logical.
If FALSE
then the intermediate results are
destroyed after the simulation of the random field(s)
or if an error had occured.
If storing=TRUE
, then
additional simulations can be performed by calling
RFsimulate
with at most the argument n
.
This call can then be much faster, but the a rather large
amount of memory could be kept.
When storing
turned from TRUE
to FALSE
by
global call then all registers are deleted.
Advanced:
With RFoptions(storing=list(FALSE, register,
model_register))
single registers can be deleted.
Default: FALSE
Ttriple
Logical or NA
.
If TRUE
, then triple for the time argument T
is
expected, containing start, step (by), length.
If FALSE
a sequence on a grid is expected.
If NA
then the decision is automatic, but will lead to an
error if ambiguous.
vdim_close_together
logical. Used especially in functions that
create covariance matrices. If the model is multivariate, then two
ways of ordering the matrix exist. To consider first all variables at
a certain location (vdim_close_together=TRUE
) or to consider first
all locations keeping the variable fixed
(vdim_close_together=FALSE
).
Note that several simulation methods rely on the value FALSE
,
so that these methods will not work anymore if
vdim_close_together=FALSE
.
Default: FALSE
.
2. Options for Brown-Resnick Fields
deltaAM
integer; only used for simulation of BR processes via RPbrmixed
with optim_mixed=2
. In this case, deltaAM
is the number
of additionally simulated Gaussian processes used for an update of
areamat
in the optimization pricedure.
Default: 300
maxtrendmem
integer; the maximal number of real valued variables used for intermediate storage:
RPbrshifted: trends for shifted locations that may be stored at the same time when simulating BR processes.
RPbrnormed: Let be the number of locations.
Then a
(covariance) matrix has to be evaluated
at random columns.
if maxtrendmem
is large (and small,
),
multiple evaluations can be avoided.
Default: 1e7
.
meshsize
positive; width of the grid on which the shape functions in the M3
representation of BR processes are simulated; only used for
simulation of BR processes via RPbrmixed
.
Default: 0.1
.
optim_mixed
0, 1, 2
; only used for simulation of BR
processes via RPbrmixed
.
If optim_mixed=0
, the arguments
lambda
and
areamat
of RPbrmixed
are used for the simulation.
If optim_mixed=1
, lambda
is estimated for
areamat=1
.
If optim_mixed=2
, areamat
is optimized and
lambda
is estimated.
Default: 1
.
optim_mixed_tol
value in ; only used for simulation of BR processes via
RPbrmixed
with optim_mixed=2
. In this case,
areamat
is optimized under the constraint that the
probability of drawing the shape function incorrectly is bounded by
optim_mixed_tol
(cf. Oesting et al., 2012).
Default: 0.01
.
variobound
positive; the shape functions in the mixed moving maxima
representation are cut off where the variogram belonging
to phi
exceeds variobound
.
Default: 8.0
.
vertnumber
positive integer; for an efficient simulation of the shape functions
in the M3 representation of BR processes, the component from
of the domain
of the
underlying Poisson point process is sub-dividedinto cubes
(cf. Oesting et al., 2012);
vertical
is the number of
vertical breaks of ; only used for simulation of BR processes
via
RPbrmixed
with optim_mixed=2
.
Default: 7
.
3. circulant
: Options for circulant embedding methods, cf. RPcirculant
These options influence the standard circulant embedding
method, cutoff circulant embedding intrinsic circulant embedding.
It can also influence RPtbm
if the line is simulated
with any circulant embedding method.
approx_maxgrid
See RPcirculant
approx_step
See RPcirculant
dependent
See RPcirculant
force
See RPcirculant
maxGB
See RPcirculant
maxmem
See RPcirculant
mmin
See RPcirculant
strategy
See RPcirculant
tolIm
See RPcirculant
tolRe
See RPcirculant
trials
See RPcirculant
useprimes
See RPcirculant
4. coords
: Options for coordinates and units
coord_system
character. See coordinate systems
coordunits
coordnames
new_coord_system
new_coordunits
polar_coord
varnames
varunits
xyz_notation
zenit
5. direct
: Options for simulating by simple matrix decomposition
max_variab
Maximal size of the covariance matrix.
Default: 12000
6. distr
: Options for distributions, in particular RRrectangular
innermin
Default value to simulate from the
RRrectangular
distribution.
The minimal length of the interval where the Taylor expansion shall
be valid.
Default: 1e-20
.
maxit
Default value to simulate from the
RRrectangular
distribution.
The number of iterative steps where the the constant of the Taylor development is increased, to find an upper bound for the given function.
Default: 20
.
maxsteps
Default value to simulate from the
RRrectangular
distribution.
maxsteps
is usually the number of steps in the middle part of
the approximation. From this value and the length between
the determined endpoints for the approximation at the origin and in
the tail, the step length is calculated. If the step length is less
than minsteplen
the number of steps is reduced.
Default: 1000
.
mcmc_n
In case of the use of MCMC it leaves out
member of the Markov chain bevor the
member
is returned. See also maxsteps.
Default: 15
.
minsteplen
Default value to simulate from the
RRrectangular
distribution.
The minimal step length
for the middle part of approximation, which is a step function,
Default: 0
(i.e. not used as a criterion.)
outermax
Default value to simulate from the
RRrectangular
distribution.
The largest possible endpoint for the middle part that
approximates the function by a step function. See also innermax
.
Default: 20.
parts
Default value to simulate from the
RRrectangular
distribution.
parts
determines the number of tests that are performed to
check whether a proposed power function is an upper bound for
the given function, at the origin and the tail.
Default: 8
.
repetitions
Minimal number of realisations to determine a quantity of the
distribution by MCMC. E.g. to determine the integral value
in the paper of Oesting, Schlather, Zhou.
Default: 1000.
safety
Default value to simulate from the
RRrectangular
distribution.
First, at the origin, the first power function of the Taylor
expansion is taken as potential upper function.
The constant of the power function are increased by factor
safety
and the exponent of the function
similarly decreased. A number of test evaluations
is performed to check whether this modified function is indeed
a upper bound. If not, the considered interval at the origin
is reduced iteratively, the constants of the power function
further increased and the exponent decreased.
If maxit
iteration have been performed without success,
the search for an upper bound fails.
The search at the origin also fails if the interval around
the origin has become less than innermin
.
Similar procedure is performed for the tail.
Default: 0.08
.
7. empvario
: Options for calculating the empirical variogram
fft
Logical. Determines whether FFT should be used for data on a grid
Default: TRUE
.
phi0
numeric. In case of anisotropic fields directional cones are
considered. The argument phi0
determines the starting angle.
Default: 0
.
pseudovariogram
logical. Only in the multivariate case. Whether the pseudovariogram or the crossvariogram should be calculated.
Default: FALSE
.
theta0
numeric. In case of anisotropic fields directional cones are
considered. The argument theta0
determines one of the
boundaries, hence all boundaries for a given fixed number of cones.
The argument theta0
determines the starting value of the
second anglue in polar coordinate representation in 3 dimensions.
Default: 0
.
tol0
numeric. Estimated values of the empirical variogram
below tol0
times the grid step in the third dimension
are considered to be zero. Hence the respective values are set
to zero.
Default: 1e-13
.
8. fit
: Options for RFfit
,
RFratiotest
, and RFcrossvalidate
algorithm
See RFfitOptimiser.
Default: NULL
approximate_functioncalls
In case the parameter vector is too close to the given
bounds, the ML target function is evaluated on a grid
to get a new initial value for the ML estimation.
The number of points of the grid is approximately
approximate_functioncalls
.
Default: 50
boxcox_lb
lower bound for the Box-Cox transformation
Default: -10
.
boxcox_ub
upper bound for the Box-Cox transformation
Default: 10
.
bin_dist_factor
numeric. The empirical variogram is calculated up the distance
bin_dist_factor
times (maximum distance among any pair of locations)
Default: 0.5
.
bins
vector of explicit boundaries for the bins or the
number of bins for the empirical variogram (used in the
LSQ target function, which is described at the beginning
of the Details).
Note that for anisotropic models, the value of bins
might
be enlarged.
Default: 20
.
critical
logical or signed integer.
If critical=FALSE
and if the result of
any maximum likelihood method
is on a borderline, then the optimisation is redone
in a modified way (which takes about double extra time)
If critical=TRUE
and if the result of
any maximum likelihood method
is on a borderline, then a kind of profile likelihood
optimization is done (which takes about 10 times extra time)
If critical>=2
then a kind of profile likelihood
optimization is always done (which takes about n_crit
times extra time) for an automatically chosen selection
of the model parameters.
If critical>=3
then a kind of profile likelihood
optimization is always done (which takes about n_crit
times extra time) for all the parameters.
If critical<0
then none of the refined methods
are performed.
Default: TRUE
.
cross_refit
logical.
For each of the subset of the cross-validation method
the parameters have to be fitted to the given model.
If cross_refit
is TRUE
, this is done, but takes a huge
amount of time. If FALSE
, the model is fitted only once to
the data and the value at
each point is predicted with the same model given
the values of the other points.
Default: FALSE
.
see RFlikelihood
.
See the argument control
in optim.
factr_recall
is used for intermediate calculations.
character – not programmed yet.
types of likelihood are "auto"
, "full"
,
"composite"
, "tesselation"
;
Default: "auto"
lowerbound_scale_factor
The lower bound for the scale is determined as
(minimum distance between different pairs of points) /lowerbound_scale_factor
.
Default: 3
.
lowerbound_scale_ls_factor
For the LSQ target function a different lower bound for the scale is used. It is determined as
(minimum distance between different pairs of points) / lowerbound_scale_ls_factor
.
Default: 5
.
lowerbound_var_factor
The lower bound for the nugget and the variance is determined
as var(data
) / lowerbound_var_factor
.
If a standard model definition is given and
either the nugget or the variance is fixed,
the parameter to be estimated
must also be greater than lowerbound_sill
.
Default: 10000
.
maxmixedvar
OBSOLETE. upper bound for variance in a mixed model; so, the covariance model for mixed model part might be calibrated appropriately
max_neighbours
integer. Maximum number of locations (with depending values) that are allowed.
Default: 5000
.
minbounddistance
If any value of the parameter vector
returned from the ML estimation
is closer than minbounddistance
to any of the bounds or if any value
has a relative distance smaller than
minboundreldist
, then it is assumed that
the MLE algorithm has dropped into a local minimum,
and it will be continued with evaluating the
ML target function on a grid, cf. the beginning paragraphs
of the Details.
Default: 0.001
.
minboundreldist
relative distance to the bounds
below which a part of the algorithm is considered as
having failed. See minbounddistance
.
Default: 0.02
.
min_diag
Minimal value of any estimated diagonal matrix element.
Default: 1e-7
.
n_crit
integer. The approximate profiles that are considered.
Default: 10
.
nphi
scalar or vector of 2 components.
If it is a vector then the first component gives the first angle
of the xy plane
and the second one gives the number of directions on the half circle.
If scalar then the first angle is assumed to be zero.
Note that a good estimation of the variogramm by LSQ with a
anisotropic model a large value for ntheta
might be needed
(about 20).
Default: 1
.
ntheta
scalar or vector of 2 components. If it is a vector then the first component gives the first angle in the third direction and the second one gives the number of directions on the half circle. If scalar then the first angle is assumed to be zero.
Note that a good estimation of the variogramm by LSQ with a
anisotropic model a large value for ntheta
might be needed
(about 20).
Default: 1
.
ntime
scalar or vector of 2 components.
if ntimes
is a vector, then the first component are the
maximum time distance (in units of the grid length T[3]
) and the
second component gives the step size (in units of the grid length
T[3]
). If scalar then the step size is assumed to 1 (in units
of the grid length T[3]
).
Default: 20
.
only_users
boolean.
If true then only users_guess
is used as a
starting point for the fitting algorithms
Default: FALSE
.
optimiser
See RFfitOptimiser.
Default: "optim"
.
See the argument control
in optim.
pgtol_recall
is used for intermediate calculations.
refine_onborder
logical.
If TRUE
and an estimated parameter of the model
is close to the boundary, a second search for the optimum
is started.
Default: TRUE
minmixedvar
lower bound for variance in a mixed model; so, the covariance model for mixed model part might be calibrated appropriately
Default: 1/1000
ratiotest_approx
logical.
if TRUE
the approximative formula that twice the
difference of the likelihoods follow about a
distribution is used. The parameter of freedom equals
the number of parameters to be estimated for the covariance
function, including those for the covariates.
Default: TRUE
reoptimise
logical.
If TRUE && !only_users
then at a very last step,
the optimisation is redone with currently best parameters
and likelihood as scale parameter for optim
.
Default: TRUE
.
scale_max_relative_factor
If the initial scale
value for the ML estimation
obtained by the LSQ target function is
less than
scale_max_relative_factor
a warning is given that probably a nugget effect
is present.
Note: if scale_max_relative_factor
is greater
than lowerbound_scale_ls_factor
then
no warning is given as
the scale has the lower bound
lowerbound_scale_ls_factor
.
Default: 1000
scale_ratio
RFfit
uses parscale
and fnscale
in the calls of optim
. As these arguments should
have the magnitude of the estimated values, RFfit
checks this by calculating the absolute log ratios.
If they are larger than scale_ratio
,
parscale
and fnscale
are reset and the optimisation
is redone.
Default: 0.1
.
shortnamelength
The names of the variables in the returned table are
abbreviated by taking the first shortnamelength
letters.
Default: 4
.
smalldataset
If the number of locations is considered as small, then some more data are kept in the storage to accelerate the estimation algorithm.
Default: 2000
.
split
integer.
If the number of parameters to be numerically optimised is larger
than or equal to split
then RFfit
checks whether a
space-time covariance model or a multivariate covariance model
can be split into components, so that certain parameters
can be estimated separately.
Default: 4
.
cliquesize
integer.
RFfit
tries to split the data set
into parts of size splitn_neighbours[2] or less, but never more than
splitn_neighbours[3]
and never less than
splitn_neighbours[1].
Default: c(200, 1000, 3000)
.
splitfactor_neighbours
The total number of neighbouring boxes in each direction
, including the current box itself.
Default: 2
.
split_refined
logical.
If TRUE
then also submodels are fitted if splitted.
This takes more time, but anova
and
RFratiotest
, for instance,
will give additional information.
Default: TRUE
.
upperbound_scale_factor
The upper bound for the scale is determined as
upperbound_scale_factor
* (maximum distance
between all pairs of points).
Default: 3
.
upperbound_var_factor
The upper bound for the
variance and the nugget is determined
as upperbound_var_factor
* var(data
)
Default: 10
.
use_naturalscaling
logical. Only used if model is given in standard (simple) way.
If TRUE
then internally, rescaled
covariance functions will be used for which
cov(1)0.05.
use_naturalscaling
has the advantage that scale
and the form parameters of the model get ‘orthogonal’,
but use_naturalscaling
does not work for all models.
Note that this argument does not influence
the output of RFfit
: the parameter vector
returned by RFfit
refers
always to the standard covariance model as given in
RMmodel
. (In contrast to practicalrange
in RFoptions
.)
Advantages if use_naturalscaling=TRUE
:
scale
and the shape parameter of a parameterised
covariance model can be estimated better if they are estimated
simultaneously.
The estimated bounds calculated by means of
upperbound_scale_factor
and lowerbound_scale_factor
,
etc. might be more realistic.
in case of anisotropic models, the inverse of the elements of the anisotropy matrix should be in the above bounds.
Disadvantages if use_naturalscaling=TRUE
:
For some covariance models with additional parameters, the
rescaling factor has to be determined numerically.
Then, more time is needed to perform RFfit
.
note the use_naturalscaling
only affects simple
models, no operators. Also functions that define a parameter of
the model are not changed.
Default: FALSE
.
9. gauss
: Options for simulating Gaussian random fields
approx_zero
Value below which a correlation is considered to be essentially zero. This argument is used to determine the practical range of covariance function with non-compact support.
Default: 0.05
boxcox
real vector of one or two components.
If the first component is Inf
then no transformation
is performed. Otherwise the BoxCox transformation is performed.
Note that Box Cox only works in a Gaussian framework.
Note further that either boxcox
or loggauss
may be given.
Default c(Inf, 0)
direct_bestvar
integer.
When searching for an appropriate simuation method
the matrix decomposition method (method="direct"
)
is preferred if the number of variables is less than or equal to
direct_bestvariables
.
Default is 1200
.
loggauss
logical. Whether a log-Gauss random fields should be returned.
See also boxcox
for a generalisation.
paired
(“Antithetic pairs”.)
Logical. If TRUE
then the second half of the
simulations is logical. If TRUE
then the second half of the
simulations is obtained by
only changing the signs of all the standard Gaussian random variables,
on which the first half of the
simulations is based. Default is FALSE
.
stationary_only
See RPgauss
10. graphics
: Options for graphical output
always_close_device
logical.
If FALSE
the current device is kept as it is;
otherwise the current device is closed before the next
device is opened. If NA
it closes the preceding device
if the opened device is pdf or jpeg.
Default: NA
.
always_open_device
logical.
If TRUE
a new graphical window is opened for every
plot
if a standard graphical output is
used, trying to respect the aspect ratios for the plots.
The devices pdf and jpeg are always opened.
If NA
then the value is set
to interactive()
.
Default: TRUE
.
close_screen
logical; only relevant if
split_screen = TRUE
and always_close_screen = FALSE
.
If FALSE
the windows opened by
split.screen
are left open.
Default: TRUE
.
file
character; only relevant if
split_screen = TRUE
.
argument file
in pdf
If ""
then no internal naming is performed.
Default: ""
.
filenumber
integer; only relevant if
split_screen = TRUE
. Starting number of the file if
onefile=FALSE
. It is set to 0 whenever file
is
changed and onefile=FALSE
.
Default 0.
grDefault
logical. If FALSE
the graphic style up to Version 3.2
is used. Otherwise, the changes of th graphical style are reduced to
a minimum.
Default: FALSE
grPrintlevel
integer values 0, 1, 2; only relevant when simulations are plotted. The higher the more text is shown in the plot.
Default: 1
.
height
real number; only relevant if
a new device is opened, see alwyas_open_screen
.
height=NA
or height
is not positive: no device
is opened.
width = NA
If height
is greater than zero then it gives the height
of a single figure in a plot created by RandomFields;
See also close_screen
.
If plots with multiple figures are
shown, the height and width of the plot
will be increased by a factor up the
ones given by increase_upto
.
The width is calculated so that the aspect ratio is correct.
width
not NA
height
and width
give the size of the
whole window.
Default: 6
.
increase_upto
See height
.
Default: c(3,4)
.
split_screen
logical.
If TRUE
split.screen
is used to split the screen.
Otherwise par(mfcol)
.
When using split_screen
then the figures tend to be fancier.
Default: TRUE
.
onefile
logical; only relevant if
split_screen = TRUE
.
About the behaviour of argument onefile
in
pdf
Default: FALSE
.
width
real number or NA; only relevant if
always_open_screen=TRUE
. See height
for details.
Default: NA
.
11. gui
: Options for cRFgui
alwaysSimulate
logical. If TRUE
then a new random field is simulated
whenever a parameter is changed. Otherwise only the covariance
function or the variogram is re-plotted; simulations are performed
only when the correponding button is pressed.
Default: TRUE
.
simu_method
"RPcirculant"
,
"RPcutoff"
,
"RPintrinsic"
,
"RPtbm"
,
"RPspectral"
,
"RPdirect"
,
"RPsequential"
,
"RPaverage"
,
"RPnugget"
,
"RPcoins"
,
"RPhyperplane"
,
"RPspecific"
,
"any method"
.
Default: "RPcirculant"
.
size
vector of 2 components. Grid size of the simulated stochastic processes. The two components of the vector correspond to one-dimensional and two-dimensional processes, respectively.
Default: c(1024, 64)
.
12. hyper
: Options for simulating hyperplane tessellations
mar_distr
integer. This argument should not be changed yet.
It codes the marginal distribution used in the simulation:
0 : uniform distribution
1 : Frechet distribution with form argument mar_param
2 : Bernoulli distribution (Binomial with ) with
argument
mar_param
Default: 0
.
mar_param
Argument used for the marginal distribution. The argument should not be changed yet.
Default: NA
.
maxlines
integer. Maximum number of allowed lines.
Default: 1000
.
superpos
integer. number of superposed hyperplane tessellations.
Default: 300
.
13. krige
: Options for Kriging
cholesky_R
obsolete
fillall
logical value for imputing.
If true all the components are estimated whether they are
NA
or not.
Default: TRUE
.
locmaxn
Kriging is conditions on maximal locmaxn
points.
If the data contain more points, neighbourhood kriging is performed.
Default: 8000
.
locsplitfactor
In case of neighbourhood kriging, the area is split into small
boxes. The complete neighbourhood contains (2 *
locsplitfactor
+1) boxes in each direction.
Default: 2
.
locsplitn
vector of 3 components.
A box should contain no more than locsplitn[3]
points, but never less than locsplitn[1]
. If
a box had originally less than locsplitn[1]
points,
then the box is increased until at least locsplitn[2]
points are in the box.
Default: c(200, 1000, 5000)
.
method
obsolete
return.variance
logical.
If FALSE
the kriged field is
returned. If TRUE
a list of two elements, estim
and
var
, i.e. the kriged field and the kriging variances,
is returned.
Default: FALSE
.
14. maxstable
: Options for simulating max-stable random fields
check_every
integer. In order to get a precise simulation result, by definition,
the maximum must be taken, for each shape function, over alle
locations of interest. Clearly, small values will not play a role.
To this end, the global minimum has to be determined.
The calculation of the global minimum is expensive and therefor
should not be done too frequently. On the other hand,
rare updates increases the computing times for taking the maximum
over a single shape functions. Here, after every check_every
considered shape function, the global minimum is calculated.
It is expected that a good choice for check_every
is in
in the interval .
(For ease and for concerns of efficiency, the more adequate, local minimum is not considered.)
Default: 30 .
density_ratio
value in . This argument is considered only
if
flat=-1
and the simulation is performed on a grid.
Then, the ratio between the highest and the lowest value is
calculated within the convex hull of the grid. If the
value is less than density_ratio
then the grid points
are considered separately. Else the density is considered to be
constant in the convex hull of the grid.
Default: 0.0.
eps_zhou
positive real number, which
gives the aimed relative precision when the constant
in the paper of Oesting, Schlather, Zhou (2018) has to be estimated.
E.g. if
eps_zhou=0.01
then the first 2 digits should be
correct.
Default: 0.01
flathull
NA, FALSE, TRUE
. Only used in M3
modelling in the algorithm by Oesting, Schlather, Zhou (2018).
The argument is considered only if the simulation is performed on a
grid.
If flat=TRUE
, then the density
is considered to be flat
in the convex hull of the grid,
i.e. the simulation method of Schlather (2002) is used.
If flat=NA
the choice is done automatically.
Default: FALSE .
max_gauss
The simulation of the max-stable process by the old-fashioned
method of Schlather (2002) and by older methods for Brown-Resnick
processes
uses
a stopping rule that necessarily needs a finite upper endpoint
of the marginal distribution of the random field.
In the case of
Brown-Resnick processes
,
extremal Gaussian fields
,
and
extremal t fields
,
the upper endpoint is approximated by standardmax
.
Default: 3.0
.
max_n_zhou
positive integer.
The overall constant in the paper of
Oesting, Schlather, Zhou (2018) has to be determined
by MCMC, if the shape functions are random.
The two arguments, min_n_zhou
and max_n_zhou
,
give the minimal and the maximal
number of simulations that are performed. To economize
computer time the values of is partially estimated
when the shape functions are simulated. If the number
of shape functions is larger than the number of simulations
given by
eps_zhou
then
no further simulation is performed to determine .
So, it is advantageous to simulate all fields at once by
RFsimulate(..., n = )
.
Default: 1000 and 10000000, respectively.
maxpoints
positive integer; the maximal number of Poisson points to be simulated
for one realization of the max-stable random field. This option will
not be considered for most of the users. This option allows
the simulation to interrupt after maxpoints
shape function
have been placed.
Default: 2e9
(never).
mcmc_zhou
positive integer.
In case of random shape functions, an MCMC step is required.
mcmc_zhou
-1 equals the number of members of the MCMC chain
that are left out before the next value of the chain is returned.
Default: 20
min_n_zhou
see max_n_zhou
mcmc_zhou
positive integer.
In case of random shape functions, an MCMC step is required.
mcmc_zhou
-1 equals the number of members of the MCMC chain
that are left out before the next value of the chain is returned.
Default: 20
min_n_zhou
see max_n_zhou
min_shape_gumbel
To increase speed,
the minimum field value is assumed to be min_shape_gumbel
for calculation of threshold values for simulation short cuts.
During a simulation, its value becomes void as soon as the real
(current) minimum of the field being simulated exceeds
min_shape_gumbel
Default: -1e15
.
scatter_method
logical. If
Default: NA;
xi
Extreme value index. Default: 2e9
.
While can be set globally, the shift
and the
scale
can be given only locally within the process
definitions, e.g.,
RPsmith
.
Default: 1.0
.
15. mpp
: Options for the random coins (shot noise) methods
about_zero
In certain cases (Coins,RMtruncsupport),
functions are assumed to zero if the value is less than about_zero
.
Default: 0.001
.
n_estim_E
integer. Number of draws from the
distribution of the scale to estimate the mean of the distribution.
This is used only if the mean of the scale distribution
is not explicitely given.
Default: 50000
.
scatter_method
scatter_size
, scatter_max
Real valued and integer valued, respectively, or NA
.
Used in the internal function RMscatter
that calculates
for some function
and
for some distances
.
Let about_zero
, scatter_size
and scatter_max
.
We distinguish 4 cases:
scatter_size > 0
and scatter_max >= 0
Here, equals
.
and
with
.
scatter_size > 0
and scatter_max < 0
same as the previous case, but is chosen such that
,
,
and
,
.
scatter_size <= 0
and scatter_max >= 0
This option is possible only for grids.
Here runs on the given grid
,
but at most
scatter_max
steps.
scatter_size <= 0
and scatter_max < 0
this option is possible only for grids.
Here, runs over the whole grid.
shape_power
Shape functions are powered by shape_power
before used as
intensity function for the point process.
Default: 2.0
.
16. nugget
: Options for the nugget effect
Simulating a nugget effect is per se trivial.
However, it gets complicated
and best methods (including direct
and circulant
embedding
!) fail if zonal anisotropies are considered,
where sets of points have to be identified that belong to the
same subspace of eigenvalue 0 of the anisotropy matrix.
tol
The nugget tolerance influences two different kind of models
See there for more information.
17. registers
: Register numbers
Model for different purposes are or can be stored at
different places. They are called registers and have non-negative
numbers up to 21 (currently).
The user can use the registers 0..9.
register
number in 0:9; place where intermediate calculation for random field simulation are stored; the number refers to 10 internal registers 0..9.
Changing the register number only makes sense, when
two different random fields, say, are to be simulated
alternatingly, several times in a row. Then the
simlulation speed can be increased if several registers
are used, storing=TRUE
and RFsimulate
is used with the only argument n
.
Default: 0
18. sequ
: Options for the sequential method
back_steps
See RPsequential
initial
See RPsequential
max_variables
See RPsequential
19. solve
: Options for solving linear systems
det_as_log
See RFoptions
eigen2zero
See RFoptions
max_chol
integer. Maximum number of rows of a matrix in a Cholesky decomposition
Default:
max_svd
integer. Maximum number of rows of a matrix in a svd decomposition
Default:
pivot
Type of pivoting for the Cholesky decomposition. Possible values are
No pivoting.
If the matrix has a size greater than 3x3 and Choleskey fails without pivoting, privoting is done. For matrices of size less than 4x4, no pivoting and no checks are performed.
Do alwaoys pivoting. NOTE: privoted Cholesky decomposition yields only very approximately an upper triangular matrix L, but still L^t L = M holds true.
uses the same pivoting as in the previous pivoted decomposition. This option becomes relevant only when simulations with different parameters or different models shall be performed with the same seed so that also the pivoting must be coupled.
Default: PIVOT_auto
pivot_actual_size
See RFoptions
pivot_check
logical. Only used in pivoted Cholesky
decomposition.
If TRUE
and a numerically zero diagonal element is detected,
it is checked whether the offdiagonal elements are numerically zero
as well.
(See also pivot_max_deviation
and
pivot_max_reldeviation
.)
if NA
then, in RPdirect, the value is equivent to
FALSE
if the model is positive (semi-)definite.
TRUE
if the model is genuinely negative definite.
Default: NA
pivot_idx
See RFoptions
pivot_relerror
See RFoptions
pivot_max_deviation
See RFoptions
pivot_max_reldeviation
See RFoptions
solve_method
See RFoptions
spam_factor
See RFoptions
spam_min_n
See RFoptions
spam_min_p
See RFoptions
spam_pivot
See RFoptions
spam_sample_n
See RFoptions
spam_tol
See RFoptions
svdtol
See RFoptions
use_spam
See RFoptions
20. special
: Options for specific methods
multicopies
Only used by RMmult
.
The covariance functions are multiplied if the corresponding
independent random fields are multiplied. To get
an approximative Gaussian random fields with a multiplicative
covariance functions the average over multicopies
products of random fields is calculated.
21. spectral
: Options for the spectral (turning bands) method
ergodic
In case of an additive model and ergodic=FALSE
,
the additive component are chosen proportional to their
variance. In total lines
are simulated. If
ergodic=TRUE
, the components are simulated
separately and then added.
Default: FALSE
.
prop_factor
see RPspectral
sigma
see RPspectral
sp_grid
see RPspectral
sp_lines
see RPspectral
22. tbm
: Options for the turning bands method
center
Scalar or vector.
If not NA
, the center
is used as the center of
the turning bands for TBM2
and TBM3
.
Otherwise the center is determined
automatically such that the line length is minimal.
See also points
and the examples below.
Default: NA
.
fulldim
positiv integer. The dimension of the space into which the
simulated field is embedded. So, the value fulldim
must be at least the dimension of the field.
Default: 3.
grid
Logical.
The angle of the lines is random if
grid=FALSE
,
and lines
for in
1:lines
,
otherwise.
This option is used by both RPspectral
and RPtbm
, the latter only when the dimension is 2.
Default: TRUE
.
layers
Logical or integer. If TRUE
then the turning layers are used whenever
a time component is given.
If NA
the turning layers are used only when the
traditional TBM is not applicable.
If FALSE
then turning layers may never be used.
Default: TRUE
.
lines
Number of lines used.
Default: 60
.
linesimustep
If linesimustep
is positive the grid on the line has lag
linesimustep
.
See also linesimufactor
.
Default: 0.0
.
linesimufactor
linesimufactor
or
linesimustep
must be non-negative; if
linesimustep
is positive then linesimufactor
is ignored.
If both
arguments are naught then points
is used (and must be
positive).
The grid on the line is linesimufactor
-times
finer than the smallest distance.
See also linesimustep
.
Default: 2.0
.
points
integer. If greater than 0,
points
gives the number of points simulated on the TBM
line, hence
must be greater than the minimal number of points given by
the size of the simulated field and the two paramters
TBMx.linesimufactor
and TBMx.linesimustep
.
If points
is not positive the number of points is
determined automatically.
The use of center
and points
is highlighted
in an example below.
Default: 0
.
reduceddim
if positiv integer, then the value itself. If negativ, then the value is substracted from fulldim.
Default: -2
.
23. internal
: Internal options mostly for warnings and
messages
All these options should not be changed by the user unless he/she really known what he/she is doing.
Most of the options below change their value in a session without the user's notice.
do_tests
Internal variable. Do not use it.
Default: FALSE
.
examples_reduced
non-negative integer. If positve, then the design of any simulation in RandomFields is internally reduced in size (roughly downto the given value in each direction). Warnings report this behaviour. This option is necessary to run the examples of RandomFields under the time constraint of CRAN.
stored.init
internally used logical argument.
This option is closely related to
storing
which controls whether intermediate calculations
should be stored to have faster repeated simulations.
This user option is internally overwritten if the user calls several
simulations at once. This current value is stored in stored.init
.
Default: FALSE
.
warn_ambiguous
internally used logical argument.
Usually, the argument grid
in RFsimulate
,
for instance, can or should be given. If not given,
the system takes a default definition.
Additionally a message is displayed in this case if
ambiguous=TRUE
.
Default: FALSE
.
warn_aspect_ratio
internally used logical argument.
if TRUE
then a warning is given not a standard graphical
device is used and the package plots try to keep a certain aspect
ratio.
Default: TRUE
warn_colour_palette
internally used logical argument. If none of the packages RColorBrewer and colorspace are available and graphics are displayed, a message is displayed.
Default: TRUE
.
warn_constant
The definition of RMconstant
has changed.
A warning is displayed if the command is used. warn_constant
will become obsolete in future versions.
Default: TRUE
.
warn_coordinates
internally used logical argument.
If TRUE
then a transformation from earth coordinates to
cartesian coordinates is reported.
Default: TRUE
.
allow_duplicated_locations
logical.
If FALSE
duplicated locations are not allowed.
If TRUE
then the (standard) nugget effect becomes a non-stationary
model in an abstract space that cannot be extended outside the given
locations. See also RMnugget for the distinction between
measurement error and spatial nugget.
Default: FALSE
.
warn_missing_zenit
Only for Earth systems: a missing zenit is frequently a cause for errors that are difficult to understand. Therefore, in such cases an additional warning message is displayed.
Default: TRUE
warn_newAniso
obsolete.
internally used logical argument.
If newAniso=TRUE
and the argument Aniso
is used in the model
definition, then a message is displayed that the matrix Aniso
is multiplied from the right by , where up to Version 2.0
the argument
aniso
was available which was multiplied from
the left by .
Default: TRUE
.
warn_newstyle
internally used logical argument.
If TRUE
a message is displayed the by the argument
spConform=FALSE
oldstyle return values are obtained instead
of S4 objects.
Default: TRUE
.
warn_normal_mode
internally used logical argument.
if TRUE
then the function RFfit
displays the message that other values for the option
modus_operandi
are available.
Default: TRUE
.
warn_oldstyle
internally used logical argument.
If TRUE
a warning is given if an obsolete function
from Version 2 is used.
Default: TRUE
.
warn_on_grid
internally used logical argument.
If a (one-dimensional) grid is given, but the argument
grid=FALSE
, e.g. in RFsimulate
, this contraction is
reported if warn_on_grid=TRUE
Default: TRUE
.
warn_scale
internally used logical argument.
If warn_scale=TRUE
then a scale less than 10 [km] is reported
if earth coordinates are transformed to cartesian coordinates.
Default: TRUE
.
warn_var
In some cases, RandomFields cannot detect whether the
variance is non-negative. If TRUE
then a warning is displayed
in such a case.
Default: TRUE
.
NULL
if any argument is given, and the full list of
arguments, otherwise.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Basic
General
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., Space-Time Processes and Challenges Related to Environmental Problems. New York: Springer.
rectangular distribution; eps_zhou
Oesting, M., Schlather, M. and Zhou, C. (2013) On the Normalized Spectral Representation of Max-Stable Processes on a compact set. arXiv, 1310.1813
shape_power
Ballani, F. and Schlather, M. (2015) In preparation.
RFsimulate
,
RFoptionsAdvanced,
RFoptions
,
and RFgetMethodNames
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions() ############################################################ ## ## ## use of exactness ## ## ## ############################################################ x <- seq(0, 1, 1/30) model <- RMgauss() for (exactness in c(NA, FALSE, TRUE)) { readline(paste("\n\nexactness: `", exactness, "'; press return")) z <- RFsimulate(model, x, x, exactness=exactness, stationary_only=NA, storing=TRUE) print(RFgetModelInfo(which="internal")$internal$name) }
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions() ############################################################ ## ## ## use of exactness ## ## ## ############################################################ x <- seq(0, 1, 1/30) model <- RMgauss() for (exactness in c(NA, FALSE, TRUE)) { readline(paste("\n\nexactness: `", exactness, "'; press return")) z <- RFsimulate(model, x, x, exactness=exactness, stationary_only=NA, storing=TRUE) print(RFgetModelInfo(which="internal")$internal$name) }
Some more complex examples for the use of RFoptions
are given.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
############################################################# ## EXAMPLE 1 ## ## The following gives an example on the advantage of ## ## dependent=TRUE for simulating with RPcirculant if, in a ## ## study, most of the time is spent with simulating the ## ## Gaussian random fields. Here, the covariance at a pair ## ## of points is estimated for n independent repetitions ## ## and 2*n locally dependent repetitions. ## ## To get the precision, the procedure is repeated m times.## ############################################################# # In the example below, local.dependent speeds up the simulation # by about factor 16 at the price of an increased variance of # factor 1.5 RFoptions(seed=NA) len <- 10 x <- seq(0, 1, len=len) y <- seq(0, 1, len=len) grid.size <- c(length(x), length(y)) meth <- RPcirculant model <- RMexp(var=1.1, Aniso=matrix(nc=2, c(2,0.1,1.5,1))) m <- 5 n <- 100 # using local.dependent=FALSE (which is the default) c1 <- numeric(m) time <- system.time( for (i in 1:m) { cat("", i, "out of", m, "\n") z <- RFsimulate(meth(model), x, y, n=n, pch="", dependent=FALSE, spConform=FALSE, trials=5, force=TRUE) c1[i] <- cov(z[1, dim(z)[2], ], z[dim(z)[1], 1, ]) }) # many times slower than with local.dependent=TRUE below true.cov <- RFcov(model, t(y[c(1, length(y))]), t(x[c(length(x), 1)])) print(time) Print(true.cov, mean(c1), sd(c1), empty.lines=1)## true mean is zero # using local.dependent=TRUE ... c2 <- numeric(m) time <- system.time( for (i in 1:m) { cat("", i) z <- RFsimulate(meth(model), x, y, n=2 * n, pch="", dependent=TRUE, spConform=FALSE, trials=5, force=TRUE) c2[i] <- cov(z[1, dim(z)[2], ], z[dim(z)[1], 1, ]) }) print(time) ## 20 times faster Print(true.cov, mean(c2), sd(c2), empty.lines=1) ## much better results ## the sd is smaller (using more locally dependent realisations) ## but it is (much) faster! Note that for n=n2 instead of n=2 * n, ## the value of sd(c2) would be larger due to the local dependencies ## in the realisations. ############################################################# ## EXAMPLE 2 ## ## This example shows that the same realisation can be ## ## obtained on different grid geometries (or point ## ## configurations, i.e. grid, non-grid) using TBM ## ############################################################# RFoptions(seed=0) step <- 1 x1 <- seq(-150,150,step) y1 <- seq(-15, 15, step) x2 <- seq(-50, 50, step) model <- RPtbm(RMexp(scale=10)) RFoptions(storing=TRUE) mar <- c(2.2, 2.2, 0.1, 0.1) points <- 700 ###### simulation of a random field on long thin stripe z1 <- RFsimulate(model, x1, y1, center=0, seed=0, points=points, storing=TRUE, spConform=FALSE) ScreenDevice(height=1.55, width=12) par(mar=mar) image(x1, y1, z1, col=rainbow(100)) polygon(range(x2)[c(1,2,2,1)], range(y1)[c(1,1,2,2)], border="red", lwd=3) ###### definition of a random field on a square of shorter diagonal z2 <- RFsimulate(model, x2, x2, register=1, seed=0, center=0, points=points, spConform=FALSE) ScreenDevice(height=4.3, width=4.3) par(mar=mar) image(x2, x2, z2, zlim=range(z1), col=rainbow(100)) polygon(range(x2)[c(1,2,2,1)], range(y1)[c(1,1,2,2)], border="red", lwd=3) tbm.points <- RFgetModelInfo(level=3)$loc$totpts Print(tbm.points, empty.lines=0) # number of points on the line
############################################################# ## EXAMPLE 1 ## ## The following gives an example on the advantage of ## ## dependent=TRUE for simulating with RPcirculant if, in a ## ## study, most of the time is spent with simulating the ## ## Gaussian random fields. Here, the covariance at a pair ## ## of points is estimated for n independent repetitions ## ## and 2*n locally dependent repetitions. ## ## To get the precision, the procedure is repeated m times.## ############################################################# # In the example below, local.dependent speeds up the simulation # by about factor 16 at the price of an increased variance of # factor 1.5 RFoptions(seed=NA) len <- 10 x <- seq(0, 1, len=len) y <- seq(0, 1, len=len) grid.size <- c(length(x), length(y)) meth <- RPcirculant model <- RMexp(var=1.1, Aniso=matrix(nc=2, c(2,0.1,1.5,1))) m <- 5 n <- 100 # using local.dependent=FALSE (which is the default) c1 <- numeric(m) time <- system.time( for (i in 1:m) { cat("", i, "out of", m, "\n") z <- RFsimulate(meth(model), x, y, n=n, pch="", dependent=FALSE, spConform=FALSE, trials=5, force=TRUE) c1[i] <- cov(z[1, dim(z)[2], ], z[dim(z)[1], 1, ]) }) # many times slower than with local.dependent=TRUE below true.cov <- RFcov(model, t(y[c(1, length(y))]), t(x[c(length(x), 1)])) print(time) Print(true.cov, mean(c1), sd(c1), empty.lines=1)## true mean is zero # using local.dependent=TRUE ... c2 <- numeric(m) time <- system.time( for (i in 1:m) { cat("", i) z <- RFsimulate(meth(model), x, y, n=2 * n, pch="", dependent=TRUE, spConform=FALSE, trials=5, force=TRUE) c2[i] <- cov(z[1, dim(z)[2], ], z[dim(z)[1], 1, ]) }) print(time) ## 20 times faster Print(true.cov, mean(c2), sd(c2), empty.lines=1) ## much better results ## the sd is smaller (using more locally dependent realisations) ## but it is (much) faster! Note that for n=n2 instead of n=2 * n, ## the value of sd(c2) would be larger due to the local dependencies ## in the realisations. ############################################################# ## EXAMPLE 2 ## ## This example shows that the same realisation can be ## ## obtained on different grid geometries (or point ## ## configurations, i.e. grid, non-grid) using TBM ## ############################################################# RFoptions(seed=0) step <- 1 x1 <- seq(-150,150,step) y1 <- seq(-15, 15, step) x2 <- seq(-50, 50, step) model <- RPtbm(RMexp(scale=10)) RFoptions(storing=TRUE) mar <- c(2.2, 2.2, 0.1, 0.1) points <- 700 ###### simulation of a random field on long thin stripe z1 <- RFsimulate(model, x1, y1, center=0, seed=0, points=points, storing=TRUE, spConform=FALSE) ScreenDevice(height=1.55, width=12) par(mar=mar) image(x1, y1, z1, col=rainbow(100)) polygon(range(x2)[c(1,2,2,1)], range(y1)[c(1,1,2,2)], border="red", lwd=3) ###### definition of a random field on a square of shorter diagonal z2 <- RFsimulate(model, x2, x2, register=1, seed=0, center=0, points=points, spConform=FALSE) ScreenDevice(height=4.3, width=4.3) par(mar=mar) image(x2, x2, z2, zlim=range(z1), col=rainbow(100)) polygon(range(x2)[c(1,2,2,1)], range(y1)[c(1,1,2,2)], border="red", lwd=3) tbm.points <- RFgetModelInfo(level=3)$loc$totpts Print(tbm.points, empty.lines=0) # number of points on the line
This function sets globally graphical parameters for plots
of RMmodels
, simulations and estimations.
RFpar(...)
RFpar(...)
... |
see |
If RFpar
is called without arguments, the current list is
returned.
If RFpar
is called with NULL
only, the current list is
deleted.
Otherwise the arguments are stored for global use in RandomFields.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFpar(col="red") plot(RMexp())
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFpar(col="red") plot(RMexp())
RFpointsDataFrame
Class for attributes in one-dimensional space that are not on a grid.
## S4 method for signature 'RFpointsDataFrame' RFspDataFrame2conventional(obj)
## S4 method for signature 'RFpointsDataFrame' RFspDataFrame2conventional(obj)
obj |
an |
Objects can be created by using the functions
RFpointsDataFrame
or
conventional2RFspDataFrame
or by calls of the form
as(x, "RFpointsDataFrame")
, where x
is of class
RFpointsDataFrame
.
data
:object of class data.frame
,
containing attribute data
coords
:n-times-1 matrix of coordinates (each row is a point)
.RFparams
:list of 2; .RFparams$n
is the number
of repetitions of the random field contained in the data
slot,
.RFparams$vdim
gives the dimension of the values of the random
field, equals 1 in most cases
signature(obj =
"RFpointsDataFrame")
: generates nice plots
of the random field; if , a two-dimensional
subspace can be selected using the argument
MARGIN
; to get different slices in a third direction, the
argument MARGIN.slices
can be used;
for more details see plot-method
or type
method?plot("RFpointsDataFrame")
.
signature(x = "RFpointsDataFrame")
:
uses the show
-method for class SpatialPointsDataFrame
.
signature(x = "RFpointsDataFrame")
:
identical to show
-method
signature(obj =
"RFpointsDataFrame")
: conversion to a list of
non-sp-package based objects; the data
-slot
is converted to an array of dimension
signature(x = "RFpointsDataFrame")
:
returns the coordinates
signature(x = "RFpointsDataFrame")
: selects
columns of data
-slot; returns an
object of class RFpointsDataFrame
.
signature(x = "RFpointsDataFrame")
: replaces
columns of data
-slot; returns an
object of class RFpointsDataFrame
.
signature(x = "RFpointsDataFrame")
:
converts into other formats, only implemented for target class
RFgridDataFrame
signature(...)
: if arguments have identical
topology, combine their attribute values
signature(x = "RFpointsDataFrame")
: returns the range
signature(x = "RFpointsDataFrame")
: plots histogram
signature(x = "RFpointsDataFrame")
: converts
data
-slot to matrix
signature(x = "RFpointsDataFrame")
: converts
data
-slot to array
signature(x = "RFpointsDataFrame")
: converts
data
-slot to vector
signature(x = "RFpointsDataFrame")
:
converts data
-slot and coordinates to a data.frame
Methods summary
and dimensions
are defined for the “parent”-class
RFsp
.
Alexander Malinowski, Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFspatialPointsDataFrame
, which is for point
locations in higher dimensional spaces,
RFpointsDataFrame-class
which is for one-dimensional
locations on a grid,
RFsp
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- runif(100) f <- RFsimulate(model=RMexp(), x=x, n=3) str(f) str(RFspDataFrame2conventional(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE plot(f, nmax=2)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- runif(100) f <- RFsimulate(model=RMexp(), x=x, n=3) str(f) str(RFspDataFrame2conventional(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE plot(f, nmax=2)
Calculates the empirical pseudomadogram. The empirical
pseudomadogram of two random fields and
is given by
where , and where
denotes the number of pairs of data points with distancevector
.
RFpseudomadogram(model, x, y=NULL, z=NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL)
RFpseudomadogram(model, x, y=NULL, z=NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
distances , dim
|
another alternative for the argument |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
data |
matrix, data.frame or object of class |
bin |
a vector giving the borders of the bins; If not specified an array describing the empirical (pseudo-)(cross-) covariance function in every direction is returned. |
phi |
an integer defining the number of sectors one half of the X/Y plane shall be divided into. If not specified, either an array is returned (if bin missing) or isotropy is assumed (if bin specified). |
theta |
an integer defining the number of sectors one half of the X/Z plane shall be divided into. Use only for dimension |
deltaT |
vector of length 2, specifying the temporal bins. The internal bin vector becomes |
vdim |
the number of variables of a multivariate data set. If not given and |
RFpseudomadogram
computes the empirical
pseudomadogram for given (multivariate) spatial data.
The spatial coordinates x
, y
, z
should be vectors. For random fields of
spatial dimension write all vectors as columns of matrix x. In
this case do neither use y, nor z and write the columns in
gridtriple
notation.
If the data is spatially located on a grid a fast algorithm based on
the fast Fourier transformed (fft) will be used.
As advanced option the calculation method can also be changed for grid
data (see RFoptions
.)
It is also possible to use RFpseudomadogram
to calculate
the pseudomadogram (see RFoptions
).
RFpseudomadogram
returns objects of class
RFempVariog
.
Jonas Auel; Sebastian Engelke; Johannes Martini; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
Stein, M. L. (1999) Interpolation of Spatial Data. New York: Springer-Verlag
RMstable
,
RMmodel
,
RFsimulate
,
RFfit
,
RFcov
,
RFmadogram
.
RFvariogram
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) n <- 2 x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFpseudomadogram(data=z) plot(emp.vario)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) n <- 2 x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFpseudomadogram(data=z) plot(emp.vario)
Calculates the theoretical and empirical Pseudovariogram.
RFpseudovariogram(model, x, y=NULL, z = NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL)
RFpseudovariogram(model, x, y=NULL, z = NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
distances , dim
|
another alternative for the argument |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
data |
matrix, data.frame or object of class |
bin |
a vector giving the borders of the bins; If not specified an array describing the empirical (pseudo-)(cross-) covariance function in every direction is returned. |
phi |
an integer defining the number of sectors one half of the X/Y plane shall be divided into. If not specified, either an array is returned (if bin missing) or isotropy is assumed (if bin specified). |
theta |
an integer defining the number of sectors one half of the X/Z plane shall be divided into. Use only for dimension |
deltaT |
vector of length 2, specifying the temporal bins. The internal bin vector becomes |
vdim |
the number of variables of a multivariate data set. If not given and |
RFpseudovariogram
computes the empirical
pseudovariogram for given (multivariate) spatial data.
The spatial coordinates x
, y
, z
should be vectors. For random fields of
spatial dimension write all vectors as columns of matrix x. In
this case do neither use y, nor z and write the columns in
gridtriple
notation.
If the data is spatially located on a grid a fast algorithm based on
the fast Fourier transformed (fft) will be used.
As advanced option the calculation method can also be changed for grid
data (see RFoptions
.)
an objects of class
RFempVariog
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
Stein, M. L. (1999) Interpolation of Spatial Data. New York: Springer-Verlag
RMstable
,
RMmodel
,
RFsimulate
,
RFfit
,
RFcov
,
RFmadogram
.
RFvariogram
,
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=2) emp.vario <- RFpseudovariogram(data=z) plot(emp.vario, model=model)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=2) emp.vario <- RFpseudovariogram(data=z) plot(emp.vario, model=model)
The function performs an approximate chi2 test or
a Monte Carlo likelihood ratio test
based on fitgauss
. Currently, it only works for
Gaussian random fields.
RFratiotest(nullmodel, alternative, x, y = NULL, z = NULL, T = NULL, grid=NULL, data, alpha, n = 5 / alpha, seed = 0, lower = NULL, upper = NULL, methods, sub.methods, optim.control = NULL, users.guess = NULL, distances = NULL, dim, transform = NULL, ...)
RFratiotest(nullmodel, alternative, x, y = NULL, z = NULL, T = NULL, grid=NULL, data, alpha, n = 5 / alpha, seed = 0, lower = NULL, upper = NULL, methods, sub.methods, optim.control = NULL, users.guess = NULL, distances = NULL, dim, transform = NULL, ...)
nullmodel , alternative
|
See Details. The set of parameters
to be estimated for |
alpha |
value in [0,1] or missing. Significance level. |
n |
integer. The test is based on |
seed |
integer. If not |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
data |
matrix, data.frame or object of class |
lower |
list or vector. Lower bounds for the parameters. If |
upper |
list or vector. Upper bounds for the parameters. See |
methods |
Main methods to be used for estimating. If several methods are given, estimation will be performed with each method and the results reported. |
sub.methods |
variants of the least squares fit of the variogram. variants of the maximum likelihood fit of the covariance function. See RFfit for details. |
users.guess |
User's guess of the parameters. All the parameters must be given using the same rules as for |
distances , dim
|
another alternative for the argument |
optim.control |
control list for |
transform |
obsolete for users; use |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
nullmodel
(and the alternative
) can be
a covariance model, see RMmodel
or
type RFgetModelNames(type="variogram")
to get all options.
If RFoptions
ratiotest_approx
is TRUE
the chisq approximation is performed. Otherwise
a Monte Carlo ratio test is performed.
RFfit
or
RMmodelFit
Here, a chisq approximative test is always performed on the already fitted models.
RFratiotest
tries to detect whether
nullmodel
is a submodel of alternative
.
If it fails,
a message is printed that says that an automatic detection has not been possible;
it is not guaranteed anymore that the alternative
model
returns a (log) likelihood that is at least as large as
that of the nullmodel
,
even if nullmodel
is a submodel of alternative
.
This is due to numerical optimisation which is never perfect.
Otherwise it is guaranteed that the alternative
model has
a (log) likelihood that is at least as large as that of the nullmodel
.
The test returns a message whether the null hypothesis, i.e. the smaller model is accepted. Invisibly, a list that also contains
p
, the -value
n
data.ratio
the log ratio for the data
simu.ratio
the log ratio for the simulations
data.fit
the models fitted to the data
msg
the message that is also directly returned
It has S3 class "RFratiotest"
.
prints the summary
gives a summary
An important RFoptions
is ratiotest_approx
.
Note that the likelihood ratio test may take a huge amount of time.
This function does not depend on the value of
RFoptions
()$PracticalRange
. The function RFratiotest
always uses the standard specification
of the covariance model as given in RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFfit
,
RMmodel
,
RandomFields
,
weather
.
This function simulates unconditional random fields:
univariate and multivariate, spatial and spatio-temporal Gaussian random fields
fields based on Gaussian fields such as Chi2 fields or Binary fields, see RP.
It also simulates conditional random fields for
univariate and multivariate, spatial and spatio-temporal Gaussian random fields
Here, only the simulation of Gaussian random fields is described. For other kinds of random fields (binary, max-stable, etc.) or more sophisticated approaches see RFsimulateAdvanced.
RFsimulate(model, x, y=NULL, z=NULL, T=NULL, grid=NULL, distances, dim, data, given=NULL, err.model, params, err.params, n=1, ...)
RFsimulate(model, x, y=NULL, z=NULL, T=NULL, grid=NULL, distances, dim, data, given=NULL, err.model, params, err.params, n=1, ...)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
distances , dim
|
another alternative for the argument |
data |
For conditional simulation and random imputing only. If
matrix, data.frame or object of class If the argument
|
given |
optional, matrix or list. If |
err.model , err.params
|
For conditional simulation and random
imputing only. |
n |
number of realizations to generate. For a very advanced feature, see the notes in RFsimulateAdvanced. |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
By default, all Gaussian random fields have zero mean.
Simulating with trend can be done by including RMtrend
in the model, see the examples below.
If data
is passed, conditional simulation based on
simple kriging is performed:
If of class RFsp
,
ncol(data@coords)
must equal the dimension of the index
space. If data@data
contains only a single variable,
variable names are optional. If data@data
contains
more than one variable, variables must be named and model
must be given in the tilde notation resp ~ ...
(see
RFformula
) and "resp"
must be contained
in names(data@data)
.
If data
is a matrix or a data.frame, either ncol(data)
equals and the order of the
columns is (x, y, z, T, response) or, if
data
contains
more than one
response variable (i.e. ncol(data) > (dimension of index
space + 1)
), colnames(data)
must contain
colnames(x)
or those of "x", "y", "z", "T"
that
are not missing. The response variable name is matched with
model
, which must be given in the tilde notation. If
"x", "y", "z", "T"
are missing and data
contains
NA
s, colnames(data)
must contain an element which starts
with ‘data’; the corresponding column and those behind it are
interpreted as the given data and those before the corresponding
column are interpreted as the coordinates.
If x
is missing, RFsimulate
searches for
NA
s in the data and performs a conditional simulation
for them.
Specification of err.model
:
In geostatistics we have two different interpretations of a nugget
effect: small scale variability and measurement error.
The result of conditional simulation usually does not include the
measurement error. Hence the measurement error err.model
must be given separately. For sake of generality, any model (and not
only the nugget effect) is allowed.
Consequently, err.model
is ignored
when unconditional simulation is performed.
By default,
an object of the virtual class RFsp
;
result is of class RMmodel
.
RFspatialGridDataFrame
if the space-time dimension is greater than 1
and the coordinates are on a grid,
RFgridDataFrame
if the space-time dimension equals 1 and the coordinates are on a grid,
RFspatialPointsDataFrame
if the space-time dimension is greater than 1 and the coordinates are not on a grid,
RFpointsDataFrame
if the space-time dimension equals 1 and the coordinates are not on a
grid.
In case of a multivariate
If n > 1
the repetitions make the last dimension.
See RFsimulateAdvanced for additional options.
Several advanced options can be found in sections ‘General
options’ and ‘coords’ of RFoptions
.
In particular, option spConform=FALSE
leads to a simpler
(and faster!) output, see RFoptions
for details.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Lantuejoul, Ch. (2002) Geostatistical simulation. New York: Springer.
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
See RFsimulateAdvanced for more specific literature.
RFvariogram
,
RFfit
,
RFgetModelInfo
,
RFgui
,
RMmodel
,
RFoptions
,
RFsimulateAdvanced
,
RFsimulate.more.examples
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ############################################################# ## ## ## ONLY TWO VERY BASIC EXAMPLES ARE GIVEN HERE ## ## see ## ## ?RMsimulate.more.examples ## ## and ## ## ?RFsimulateAdvanced ## ## for more examples ## ## ## ############################################################# ############################################################# ## ## ## Unconditional simulation ## ## ## ############################################################# ## first let us look at the list of implemented models RFgetModelNames(type="positive definite", domain="single variable", iso="isotropic") ## our choice is the exponential model; ## the model includes nugget effect and the mean: model <- RMexp(var=5, scale=10) + # with variance 4 and scale 10 RMnugget(var=1) + # nugget RMtrend(mean=0.5) # and mean ## define the locations: from <- 0 to <- 20 x.seq <- seq(from, to, length=200) y.seq <- seq(from, to, length=200) simu <- RFsimulate(model, x=x.seq, y=y.seq) plot(simu) ############################################################# ## ## ## Conditional simulation ## ## ## ############################################################# # first we simulate some random values at # 100 random locations: n <- 100 x <- runif(n=n, min=-1, max=1) y <- runif(n=n, min=-1, max=1) dta <- RFsimulate(model = RMexp(), x=x, y=y, grid=FALSE) plot(dta) # let simulate a field conditional on the above data L <- if (interactive()) 100 else 5 x.seq.cond <- y.seq.cond <- seq(-1.5, 1.5, length=L) model <- RMexp() cond <- RFsimulate(model, x=x.seq.cond, y=y.seq.cond, data=dta) plot(cond, dta)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ############################################################# ## ## ## ONLY TWO VERY BASIC EXAMPLES ARE GIVEN HERE ## ## see ## ## ?RMsimulate.more.examples ## ## and ## ## ?RFsimulateAdvanced ## ## for more examples ## ## ## ############################################################# ############################################################# ## ## ## Unconditional simulation ## ## ## ############################################################# ## first let us look at the list of implemented models RFgetModelNames(type="positive definite", domain="single variable", iso="isotropic") ## our choice is the exponential model; ## the model includes nugget effect and the mean: model <- RMexp(var=5, scale=10) + # with variance 4 and scale 10 RMnugget(var=1) + # nugget RMtrend(mean=0.5) # and mean ## define the locations: from <- 0 to <- 20 x.seq <- seq(from, to, length=200) y.seq <- seq(from, to, length=200) simu <- RFsimulate(model, x=x.seq, y=y.seq) plot(simu) ############################################################# ## ## ## Conditional simulation ## ## ## ############################################################# # first we simulate some random values at # 100 random locations: n <- 100 x <- runif(n=n, min=-1, max=1) y <- runif(n=n, min=-1, max=1) dta <- RFsimulate(model = RMexp(), x=x, y=y, grid=FALSE) plot(dta) # let simulate a field conditional on the above data L <- if (interactive()) 100 else 5 x.seq.cond <- y.seq.cond <- seq(-1.5, 1.5, length=L) model <- RMexp() cond <- RFsimulate(model, x=x.seq.cond, y=y.seq.cond, data=dta) plot(cond, dta)
This man page will give a collection of basic examples for the use of
RFsimulate
.
For other kinds of random fields (binary, max-stable, etc.) or more sophisticated approaches see RFsimulateAdvanced.
See RFsimulate.sophisticated.examples for further examples.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFsimulate
,
RFsimulateAdvanced
,
RFsimulate.sophisticated.examples
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
This man page will give a collection of basic examples for the use of
RFsimulate
.
For other kinds of random fields (binary, max-stable, etc.) or more sophisticated approaches see RFsimulateAdvanced.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFsimulate
,
RFsimulateAdvanced
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
This function simulates unconditional random fields:
univariate and multivariate, spatial and spatio-temporal Gaussian random fields
It also simulates conditional random fields for
univariate and multivariate, spatial and spatio-temporal Gaussian random fields.
For basic simulation of Gaussian random fields, see RFsimulate. See RFsimulate.more.examples and RFsimulate.sophisticated.examples for further examples.
model |
object of class
|
x |
matrix of coordinates, or vector of x coordinates, or object
of class |
y |
optional vector of y coordinates, ignored if |
z |
optional vector of z coordinates, ignored if |
T |
optional vector of time coordinates,
|
grid |
logical; determines whether the vectors Note: If
|
data |
matrix, data.frame or object of class |
err.model |
same as |
distances |
object of class If |
dim |
integer; space or space-time dimension of the field |
n |
number of realizations to generate |
... |
further options and control arguments for the simulation
that are passed to and processed by |
RFsimulate
simulates different classes of random fields,
controlled by the wrapping model.
If the wrapping function of the model
argument is a covariance
or variogram model, i.e., one of the list obtained by
RFgetModelNames(type="variogram",
group.by="type")
, by default, a Gaussian field
with the corresponding covariance structure is simulated.
By default, the simulation method is chosen automatically through internal algorithms.
The simulation method can be set explicitly by enclosing the
covariance function with a method specification.
If other than Gaussian fields are to be simulated, the model
argument must be enclosed by a function specifying the type of the
random field.
There are different possibilities of passing the locations at which
the field is to be simulated. If grid=FALSE
, all coordinate
vectors (except for the time component ) must have the same
length and the field is only simulated at the locations given by the
rows of
or of
cbind(x, y, z)
. If is not
missing, the field is simulated for all combinations
or
,
nrow(x)
, length(T)
,
even if model
is not explicitly a space-time model.
If grid=TRUE
, the vectors x
,
y
, z
and T
or the columns of x
and
T
are
interpreted as a grid definition, i.e. the field is simulated at all
locations , as given by
expand.grid(x, y, z, T)
.
Here, “grid” means “equidistant in each direction”, i.e. all
vectors must be equidistant and in ascending order.
In case of more than 3 space dimensions, the coordinates must be
given in matrix notation. To enable different grid lengths for each
direction in combination with the matrix notation, the
“gridtriple” notation c(from, stepsize, len)
is used:
If x
, y
,
z
, T
or the columns of x
are of length 3, they
are internally replaced by seq(from=from,
to=from+(len-1)*stepsize, by=stepsize)
, i.e. the field
is simulated at all locationsexpand.grid(seq(x$from, length.out=x$len, by=x$stepsize),
seq(y$from, length.out=y$len, by=y$stepsize),
seq(z$from, length.out=z$len, by=z$stepsize),
seq(T$from, length.out=T$len, by=T$stepsize))
If data
is passed, conditional simulation is performed.
If of class RFsp
,
ncol(data@coords)
must equal the dimension of the index
space. If data@data
contains only a single variable,
variable names are optional. If data@data
contains
more than one variable, variables must be named and model
must be given in the tilde notation resp ~ ...
(see
RFformula
) and "resp"
must be contained
in names(data@data)
.
If data
is a matrix or a data.frame, either ncol(data)
equals and the order of the
columns is (x, y, z, T, response) or, if
data
contains
more than one
response variable (i.e. ncol(data) > (dimension of index
space + 1)
), colnames(data)
must contain
colnames(x)
or those of "x", "y", "z", "T"
that
are not missing. The response variable name is matched with
model
, which must be given in the tilde notation. If
"x", "y", "z", "T"
are missing and data
contains
NA
s, colnames(data)
must contain an element which starts
with ‘data’; the corresponding column and those behind it are
interpreted as the given data and those before the corresponding
column are interpreted as the coordinates.
If x
is missing, RFsimulate
searches for
NA
s in the data and performs a conditional simulation
for them.
Specification of err.model
:
In geostatistics we have two different interpretations of a nugget
effect: small scale variability and measurement error.
The result of conditional simulation usually does not include the
measurement error. Hence the measurement error err.model
must be given separately. For sake of generality, any model (and not
only the nugget effect) is allowed.
Consequently, err.model
is ignored
when unconditional simulation is performed.
By default,
an object of the virtual class
RFsp
;
result is of class
RFspatialGridDataFrame
if and the coordinates are on a grid,
result is of class
RFgridDataFrame
if and the coordinates are on a grid,
result is of class
RFspatialPointsDataFrame
if and the coordinates are not on a grid,
result is of class
RFpointsDataFrame
if and the coordinates are not on a
grid.
The output format can be switched to the "old" array format using
RFoptions
, either by globally setting
RFoptions(spConform=FALSE)
or by passing spConform=FALSE
in the call of RFsimulate
.
Then the object returned by RFsimulate
depends on the arguments n
and grid
in the following way:
If vdim > 1
the vdim
-variate vector makes the first dimension.
If grid=TRUE
an array of the dimension of the
random field makes the next dimensions. Here, the dimensions
are ordered in the sequence x
, y
, z
, T
(if given).
Else if no time component is given, then the values are passed as a single vector. Else if the time component is given the next 2 dimensions give the space and the time, respectively.
If n > 1
the repetitions make the last dimension.
Note: Conversion between the sp
format and the conventional format can be
done using the method RFspDataFrame2conventional
and the
function conventional2RFspDataFrame
.
InitRFsimulate
returns 0 if no error has occurred and a positive value
if failed.
Advanced options are
spConform
(suppressed return of S4 objects)
practicalrange
(forces range of covariances to be one)
exactness
(chooses the simulation method by precision)
seed
(sets .Random.seed
locally or
globally)
See RFoptions
for further options.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
General
Lantuejoul, Ch. (2002) Geostatistical simulation. New York: Springer.
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
Original work:
Circulant embedding:
Chan, G. and Wood, A.T.A. (1997) An algorithm for simulating stationary Gaussian random fields. J. R. Stat. Soc., Ser. C 46, 171-181.
Dietrich, C.R. and Newsam, G.N. (1993) A fast and exact method for multidimensional Gaussian stochastic simulations. Water Resour. Res. 29, 2861-2869.
Dietrich, C.R. and Newsam, G.N. (1996) A fast and exact method for multidimensional Gaussian stochastic simulations: Extensions to realizations conditioned on direct and indirect measurement Water Resour. Res. 32, 1643-1652.
Wood, A.T.A. and Chan, G. (1994)
Simulation of stationary Gaussian processes in
J. Comput. Graph. Stat. 3, 409-432.
The code used in RandomFields is based on Dietrich and Newsam (1996).
Intrinsic embedding and Cutoff embedding:
Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. J. Comput. Graph. Statist. 11, 587–599.
Gneiting, T., Sevcikova, H., Percival, D.B., Schlather, M. and
Jiang, Y. (2005)
Fast and Exact Simulation of Large Gaussian Lattice Systems in
: Exploring the Limits
J. Comput. Graph. Statist. Submitted.
Markov Gaussian Random Field:
Rue, H. (2001) Fast sampling of Gaussian Markov random fields. J. R. Statist. Soc., Ser. B, 63 (2), 325-338.
Rue, H., Held, L. (2005) Gaussian Markov Random Fields: Theory and Applications. Monographs on Statistics and Applied Probability, no 104, Chapman \& Hall.
Turning bands method (TBM), turning layers:
Dietrich, C.R. (1995) A simple and efficient space domain implementation of the turning bands method. Water Resour. Res. 31, 147-156.
Mantoglou, A. and Wilson, J.L. (1982) The turning bands method for simulation of random fields using line generation by a spectral method. Water. Resour. Res. 18, 1379-1394.
Matheron, G. (1973) The intrinsic random functions and their applications. Adv. Appl. Probab. 5, 439-468.
Schlather, M. (2004) Turning layers: A space-time extension of turning bands. Submitted
Random coins:
Matheron, G. (1967) Elements pour une Theorie des Milieux Poreux. Paris: Masson.
RFoptions
,
RMmodel
,
RFgui
,
methods for simulating Gaussian random fields
,
RFfit
,
RFvariogram
,
RFsimulate.more.examples,
RFsimulate.sophisticated.examples,
RPgauss
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RFsp
"RFsp"
is a virtual class which contains the four classes
RFspatialGridDataFrame
(data on a full grid and ),
RFspatialPointsDataFrame
(data not on a grid and ),
RFgridDataFrame
(data on a full grid and ),
RFpointsDataFrame
(data not on a grid and )
The first two subclasses are summarized in
"RFspatialDataFrame"
whilst the latter two are
summarized in "RFdataFrame"
.
are never to be generated; only derived classes can be meaningful.
signature(obj = "RFsp")
: returns a summary of the
object; uses or imitates summary method of class
Spatial
from the sp-package
signature(obj = "RFsp")
: retrieves the number
of spatial or spatio-temporal dimensions spanned
signature(obj = "RFsp")
:
transforms RFsp
objects to array
signature(obj = "RFsp")
:
transforms RFsp
objects to a list with additional information
signature(obj = "RFsp")
: selects columns of the
data
-slot, while all other slots are kept unmodified
signature(obj = "RFsp")
: replaces columns of the
data
-slot, while all other slots are kept unmodified
signature(object = "RFsp")
: returns the kriging
variance if available
This class is not useful itself, but the above mentioned classes in this package derived from it.
Alexander Malinowski; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFspatialGridDataFrame
,
RFspatialPointsDataFrame
,
RFgridDataFrame
,
RFpointsDataFrame
,
sp2RF
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Generating an object of class "RFspatialGridDataFrame" ## and one of class "RFspatialPointsDataFrame". model <- RMcauchy(gamma=4, var=0.1, scale=2) x <- seq(0,10,len=100) r <- cbind(runif(100, min=1, max=9),runif(100, min=1, max=9)) z1 <- RFsimulate(model=model, x=x, y=x, n=4) z2 <- RFsimulate(model=model, x=r, n=2) ## Applying available functions. class(z1) class(z2) summary(z1) summary(z2) plot(z1) plot(z2) z4 <- RFspDataFrame2conventional(z2) str(z2) str(z4) dta <- data.frame(coords=z4$x,data=z2@data[,1]) z3<-RFinterpolate(model=model, x=x, y=x, data=dta) plot(z3,z2) ## Illustrating the warning. a1 <- new("RFpointsDataFrame") str(a1) try(a2 <- new("RFsp")) ## ERROR
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Generating an object of class "RFspatialGridDataFrame" ## and one of class "RFspatialPointsDataFrame". model <- RMcauchy(gamma=4, var=0.1, scale=2) x <- seq(0,10,len=100) r <- cbind(runif(100, min=1, max=9),runif(100, min=1, max=9)) z1 <- RFsimulate(model=model, x=x, y=x, n=4) z2 <- RFsimulate(model=model, x=r, n=2) ## Applying available functions. class(z1) class(z2) summary(z1) summary(z2) plot(z1) plot(z2) z4 <- RFspDataFrame2conventional(z2) str(z2) str(z4) dta <- data.frame(coords=z4$x,data=z2@data[,1]) z3<-RFinterpolate(model=model, x=x, y=x, data=dta) plot(z3,z2) ## Illustrating the warning. a1 <- new("RFpointsDataFrame") str(a1) try(a2 <- new("RFsp")) ## ERROR
Class for spatial attributes that have spatial or
spatio-temporal locations (at least of dimension 2)
on a (full) regular grid. Direct extension of class
SpatialGridDataFrame
from the sp-package. See
sp2RF
for an explicit
transformation.
## S4 method for signature 'RFspatialGridDataFrame' RFspDataFrame2conventional(obj, data.frame=FALSE)
## S4 method for signature 'RFspatialGridDataFrame' RFspDataFrame2conventional(obj, data.frame=FALSE)
obj |
an |
data.frame |
logical. If |
Objects can be created by using the functions
RFspatialGridDataFrame
or
conventional2RFspDataFrame
or by calls of the form
as(x, "RFspatialGridDataFrame")
, where x
is of class
RFspatialGridDataFrame
.
.RFparams
:list of 2; .RFparams$n
is the number
of repetitions of the random field contained in the data
slot;
.RFparams$vdim
gives the dimension of the values of the random
field, equals 1 in most cases
data
:object of class data.frame
;
containing attribute data
grid
:object of class
GridTopology
; grid
parameters
bbox
:matrix specifying the bounding box
proj4string
:object of class CRS
;
projection
Class "SpatialGridDataFrame"
, directly.
Class "SpatialGrid"
, by class "SpatialGridDataFrame"
.
Class "Spatial"
, by class "SpatialGrid"
.
signature(obj =
"RFspatialGridDataFrame")
:
generates contour
plots
signature(obj =
"RFspatialGridDataFrame")
: generates nice image
plots
of the random field; if , a two-dimensional
subspace can be selected using the argument
MARGIN
; to get different slices in a third direction, the
argument MARGIN.slices
can be used;
for more details see plot-method
or type
method?plot("RFspatialGridDataFrame")
signature(obj =
"RFspatialGridDataFrame")
: generates persp
plots
signature(x = "RFspatialGridDataFrame")
:
uses the show
-method for class
SpatialGridDataFrame
.
signature(x = "RFspatialGridDataFrame")
:
identical to show
-method
signature(obj =
"RFspatialGridDataFrame")
: conversion to a list of
non-sp-package based objects; the data
-slot
is converted to an array of dimension ; the
grid
-slot is
converted to a 3-row matrix; the grid definition of a possible
time-dimension becomes a separate list element
signature(obj =
"RFspatialGridDataFrame")
: conversion of the data
-slot
to an array of dimension , where the
space-time-dimensions run fastest, and
and
are
the last two dimensions
signature(x = "RFspatialGridDataFrame")
:
calculates the coordinates from grid definition
signature(x = "RFspatialGridDataFrame")
: selects
columns of data
-slot; returns an
object of class RFspatialGridDataFrame
.
signature(x = "RFspatialGridDataFrame")
: replaces
columns of data
-slot; returns an
object of class RFspatialGridDataFrame
.
signature(x = "RFspatialGridDataFrame")
:
converts into other formats, only implemented for target class
RFspatialPointsDataFrame
signature(...)
: if arguments have identical
topology, combine their attribute values
signature(x = "RFspatialGridDataFrame")
: returns the range
signature(x = "RFspatialGridDataFrame")
: plots histogram
signature(x = "RFspatialGridDataFrame")
:
converts data
-slot to matrix
signature(x = "RFspatialGridDataFrame")
:
converts data
-slot to array
signature(x = "RFspatialGridDataFrame")
:
converts data
-slot to vector
signature(x = "RFspatialGridDataFrame")
:
converts data
-slot and coordinates to a data.frame
Note that in the data
-slot, each column is ordered according to the
ordering of coordinates(grid)
, the first dimension runs fastest
and for all BUT the second dimension, coordinate values are in
ascending order. In the second dimension, coordinate values run from
high to low. Hence, when converting to conventional formats using
RFspDataFrame2conventional
or RFspDataFrame2dataArray
,
the data array is re-ordered such that all dimensions are in ascending
order. as.matrix
does not perform re-ordering.
Methods summary
,
and dimensions
are defined for the “parent”-class
RFsp
.
Alexander Malinowski, Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFspatialPointsDataFrame-class
, which is for point
locations that are not on a grid,
RFgridDataFrame-class
which is for one-dimensional
locations,
RFsp
,
sp2RF
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 3 x <- GridTopology(cellcentre.offset=c(0, 0), cellsize=c(1, 0.2), cells.dim=c(10, 30)) f <- RFsimulate(model=RMexp(), x=x, n=n) str(f) str(RFspDataFrame2conventional(f)) str(RFspDataFrame2dataArray(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE str(as(f, "RFspatialPointsDataFrame")) plot(f, nmax=2) steps <- c(10, 1, 10, 10) x2 <- rbind(c(0, 0, 0, 0), c(1, 0.2, 2, 5), steps) scale <- 10 f2 <- RFsimulate(model=RMwhittle(nu=1.2, scale=scale), x=x2, n=n, grid = TRUE) plot(f2, MARGIN=c(3,4), MARGIN.slices=1, n.slices=6, nmax=2) f.sp <- RFsimulate(model=RMexp(), x=x, n=n) f.old <- RFsimulate(model=RMexp(), x=x, n=n, spConform=FALSE) all.equal(RFspDataFrame2conventional(f.sp)$data, f.old, check.attributes=FALSE) ## TRUE
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 3 x <- GridTopology(cellcentre.offset=c(0, 0), cellsize=c(1, 0.2), cells.dim=c(10, 30)) f <- RFsimulate(model=RMexp(), x=x, n=n) str(f) str(RFspDataFrame2conventional(f)) str(RFspDataFrame2dataArray(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE str(as(f, "RFspatialPointsDataFrame")) plot(f, nmax=2) steps <- c(10, 1, 10, 10) x2 <- rbind(c(0, 0, 0, 0), c(1, 0.2, 2, 5), steps) scale <- 10 f2 <- RFsimulate(model=RMwhittle(nu=1.2, scale=scale), x=x2, n=n, grid = TRUE) plot(f2, MARGIN=c(3,4), MARGIN.slices=1, n.slices=6, nmax=2) f.sp <- RFsimulate(model=RMexp(), x=x, n=n) f.old <- RFsimulate(model=RMexp(), x=x, n=n, spConform=FALSE) all.equal(RFspDataFrame2conventional(f.sp)$data, f.old, check.attributes=FALSE) ## TRUE
Class for spatial attributes that have spatial or
spatio-temporal locations (at least of dimension 2)
that are not on a grid. Direct extension of class
SpatialPointsDataFrame
from the sp-package. See sp2RF
for an explicit
transformation.
## S4 method for signature 'RFspatialPointsDataFrame' RFspDataFrame2conventional(obj)
## S4 method for signature 'RFspatialPointsDataFrame' RFspDataFrame2conventional(obj)
obj |
an |
Objects can be created by using the functions
RFspatialPointsDataFrame
or
conventional2RFspDataFrame
or by calls of the form
as(x, "RFspatialPointsDataFrame")
, where x
is of class
RFspatialPointsDataFrame
.
.RFparams
:list of 2; .RFparams$n
is the number
of repetitions of the random field contained in the data
slot,
.RFparams$vdim
gives the dimension of the values of the random
field, equals 1 in most cases
data
:object of class
data.frame
,
containing attribute data
coords.nrs
:coords
:matrix of coordinates (each row is a
point); in case of SpatialPointsDataFrame an object of class
SpatialPoints
is also allowed,
see SpatialPoints.
bbox
:matrix specifying the bounding box
proj4string
:object of class CRS;
projection
Class
SpatialPointsDataFrame
,
directly.
Class SpatialPoints
, by class
SpatialPointsDataFrame
.
Class Spatial
,
by class SpatialPoints
.
signature(obj =
"RFspatialPointsDataFrame")
: generates nice plots
of the random field; if , a two-dimensional
subspace can be selected using the argument
MARGIN
; to get different slices in a third direction, the
argument MARGIN.slices
can be used;
for more details see plot-method
or type
method?plot("RFspatialPointsDataFrame")
signature(x = "RFspatialPointsDataFrame")
:
uses the show
-method for class
SpatialPointsDataFrame
signature(x = "RFspatialPointsDataFrame")
:
identical to show
-method
signature(obj =
"RFspatialPointsDataFrame")
: conversion to a list of
non-sp-package based objects; the data
-slot
is converted to an array of dimension
signature(x = "RFspatialPointsDataFrame")
:
returns the coordinates
signature(x = "RFspatialPointsDataFrame")
: selects
columns of data
-slot; returns an
object of class RFspatialPointsDataFrame
signature(x = "RFspatialPointsDataFrame")
: replaces
columns of data
-slot; returns an
object of class RFspatialPointsDataFrame
signature(x = "RFspatialPointsDataFrame")
:
converts into other formats, only implemented for target class
RFspatialGridDataFrame
signature(...)
: if arguments have identical
topology, combine their attribute values
signature(x = "RFspatialPointsDataFrame")
: returns the range
signature(x = "RFspatialPointsDataFrame")
: plots histogram
signature(x = "RFspatialPointsDataFrame")
:
converts data
-slot to matrix
signature(x = "RFspatialPointsDataFrame")
:
converts data
-slot to array
signature(x = "RFspatialPointsDataFrame")
:
converts data
-slot to vector
signature(x = "RFspatialPointsDataFrame")
:
converts data
-slot and coordinates to a data.frame
Note that in the data
-slot, each column is ordered according to the
ordering of coordinates(grid)
, the first dimension runs fastest
and for all BUT the second dimension, coordinate values are in
ascending order. In the second dimension, coordinate values run from
high to low. Hence, when converting to conventional formats using
RFspDataFrame2conventional
or
RFspDataFrame2dataArray
,
the data array is re-ordered such that all dimensions are in ascending
order. as.matrix
does not perform re-ordering.
Methods summary
and dimensions
are defined for the “parent”-class
RFsp
.
Alexander Malinowski, Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFspatialGridDataFrame-class
, which is for point
locations that are on a grid,
RFpointsDataFrame-class
which is for one-dimensional
locations,
RFsp
,
sp2RF
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- cbind(runif(50), runif(50)) f <- RFsimulate(model=RMexp(), x=x, n=3) str(f) str(RFspDataFrame2conventional(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE try(as(f, "RFspatialGridDataFrame")) # yields error plot(f, nmax=2) f2 <- RFsimulate(model=RMwhittle(nu=1.2, scale=10), x=cbind(x,x), n=4) plot(f2, MARGIN=c(3,4), nmax=2) f.sp <- RFsimulate(model=RMexp(), x=x, n=3) f.old <- RFsimulate(model=RMexp(), x=x, n=3, spConform=FALSE) all.equal(RFspDataFrame2conventional(f.sp)$data, f.old, check.attributes=FALSE) ## TRUE
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- cbind(runif(50), runif(50)) f <- RFsimulate(model=RMexp(), x=x, n=3) str(f) str(RFspDataFrame2conventional(f)) head(coordinates(f)) str(f[2]) ## selects second column of data-slot all.equal(f, cbind(f,f)[1:3]) ## TRUE try(as(f, "RFspatialGridDataFrame")) # yields error plot(f, nmax=2) f2 <- RFsimulate(model=RMwhittle(nu=1.2, scale=10), x=cbind(x,x), n=4) plot(f2, MARGIN=c(3,4), nmax=2) f.sp <- RFsimulate(model=RMexp(), x=x, n=3) f.old <- RFsimulate(model=RMexp(), x=x, n=3, spConform=FALSE) all.equal(RFspDataFrame2conventional(f.sp)$data, f.old, check.attributes=FALSE) ## TRUE
Calculates empirical (cross-)variogram.
RFvariogram(model, x, y=NULL, z = NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL)
RFvariogram(model, x, y=NULL, z = NULL, T=NULL, grid, params, distances, dim, ..., data, bin=NULL, phi=NULL, theta = NULL, deltaT = NULL, vdim=NULL)
model , params
|
object of class |
x |
vector of x coordinates, or object of class |
y , z
|
optional vectors of y (z) coordinates, which should not be given if |
T |
optional vector of time coordinates, |
grid |
logical; the function finds itself the correct value in nearly all cases, so that usually |
distances , dim
|
another alternative for the argument |
... |
for advanced use: further options and control arguments for the simulation that are passed to and processed by |
data |
matrix, data.frame or object of class |
bin |
a vector giving the borders of the bins; If not specified an array describing the empirical (pseudo-)(cross-) covariance function in every direction is returned. |
phi |
an integer defining the number of sectors one half of the X/Y plane shall be divided into. If not specified, either an array is returned (if bin missing) or isotropy is assumed (if bin specified). |
theta |
an integer defining the number of sectors one half of the X/Z plane shall be divided into. Use only for dimension |
deltaT |
vector of length 2, specifying the temporal bins. The internal bin vector becomes |
vdim |
the number of variables of a multivariate data set. If not given and |
RFvariogram
computes the empirical
cross-variogram for given (multivariate) spatial data.
The empirical
(cross-)variogram of two random fields and
is given by
where , and where
denotes the number of pairs of data points with distancevector
.
The spatial coordinates x
, y
, z
should be vectors. For random fields of
spatial dimension write all vectors as columns of matrix x. In
this case do neither use y, nor z and write the columns in
gridtriple
notation.
If the data is spatially located on a grid a fast algorithm based on
the fast Fourier transformed (fft) will be used.
As advanced option the calculation method can also be changed for grid
data (see RFoptions
.)
RFvariogram
returns objects of class
RFempVariog
.
Sebastian Engelke; Johannes Martini; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
Stein, M. L. (1999) Interpolation of Spatial Data. New York: Springer-Verlag
RMstable
,
RMmodel
,
RFsimulate
,
RFfit
,
RFcov
,
RFpseudovariogram
.
RFmadogram
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 1 ## use n <- 2 for better results ## isotropic model model <- RMexp() x <- seq(0, 10, 0.02) z <- RFsimulate(model, x=x, n=n) emp.vario <- RFvariogram(data=z) plot(emp.vario, model=model) ## anisotropic model model <- RMexp(Aniso=cbind(c(2,1), c(1,1))) x <- seq(0, 10, 0.05) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFvariogram(data=z, phi=4) plot(emp.vario, model=model) ## space-time model model <- RMnsst(phi=RMexp(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.05) T <- c(0, 0.1, 100) z <- RFsimulate(x=x, T=T, model=model, n=n) emp.vario <- RFvariogram(data=z, deltaT=c(10, 1)) plot(emp.vario, model=model, nmax.T=3) ## multivariate model model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFvariogram(data=z) plot(emp.vario, model=model) ## multivariate and anisotropic model model <- RMbiwm(A=matrix(c(1,1,1,2), nc=2), nudiag=c(0.5,2), s=c(3, 1, 2), c=c(1, 0, 1)) x <- seq(0, 20, 0.1) dta <- RFsimulate(model, x, x, n=n) ev <- RFvariogram(data=dta, phi=4) plot(ev, model=model, boundaries=FALSE)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 1 ## use n <- 2 for better results ## isotropic model model <- RMexp() x <- seq(0, 10, 0.02) z <- RFsimulate(model, x=x, n=n) emp.vario <- RFvariogram(data=z) plot(emp.vario, model=model) ## anisotropic model model <- RMexp(Aniso=cbind(c(2,1), c(1,1))) x <- seq(0, 10, 0.05) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFvariogram(data=z, phi=4) plot(emp.vario, model=model) ## space-time model model <- RMnsst(phi=RMexp(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.05) T <- c(0, 0.1, 100) z <- RFsimulate(x=x, T=T, model=model, n=n) emp.vario <- RFvariogram(data=z, deltaT=c(10, 1)) plot(emp.vario, model=model, nmax.T=3) ## multivariate model model <- RMbiwm(nudiag=c(1, 2), nured=1, rhored=1, cdiag=c(1, 5), s=c(1, 1, 2)) x <- seq(0, 20, 0.1) z <- RFsimulate(model, x=x, y=x, n=n) emp.vario <- RFvariogram(data=z) plot(emp.vario, model=model) ## multivariate and anisotropic model model <- RMbiwm(A=matrix(c(1,1,1,2), nc=2), nudiag=c(0.5,2), s=c(3, 1, 2), c=c(1, 0, 1)) x <- seq(0, 20, 0.1) dta <- RFsimulate(model, x, x, n=n) ev <- RFvariogram(data=dta, phi=4) plot(ev, model=model, boundaries=FALSE)
RMangle
delivers an anisotropy matrix for the
argument Aniso
in RMmodel
in two dimensions.
RMangle
requires one or two stretching values, passed by
ratio
or diag
, and an angle
.
In two dimensions and with
angle
equal to and
diag
equal to the
anisotropy matrix
is
A = diag(d1, d2) %*% matrix(ncol=2, c(cos(a), sin(a), -sin(a), cos(a)))
In three dimensions and with
angle
equal to , second angle
and
diag
equal to the
anisotropy matrix
is
A = diag(d1, d2, d3) %*% matrix(ncol=3, c(cos(a) * cos(L), sin(a) * cos(L), sin(L), -sin(a), cos(a), 0, -cos(a) * sin(L), -sin(a) * sin(L), cos(L)
))
i.e. turns a vector x first in the
plane, then
in the
plane.
RMangle(angle, lat.angle, ratio, diag)
RMangle(angle, lat.angle, ratio, diag)
angle |
angle |
lat.angle |
second angle; in 3 dimensions only |
ratio |
equivalent to |
diag |
the diagonal components of the matrix |
RMangle
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(Aniso=RMangle(angle=pi/4, ratio=3)) plot(model, dim=2) x <- seq(0, 2, 0.05) z <- RFsimulate(x, x, model=model) plot(z) model <- RMexp(Aniso=RMangle(angle=pi/4, lat.angle=pi/8, diag=c(1,2,3))) x <- seq(0, 2, 0.2) z <- RFsimulate(x, x, x, model=model) plot(z, MARGIN.slices=3) ## next model gives an example how to estimate the parameters back n <- 20 x <- runif(n, 0, 10) y <- runif(n, 0, 10) coords <- expand.grid(x, y) model <- RMexp(Aniso=RMangle(angle=pi/4, diag=c(1/4, 1/12))) d <- RFsimulate(model, x=coords[, 1], y=coords[, 2], n=10) estmodel <- RMexp(Aniso=RMangle(angle=NA, diag=c(NA, NA))) system.time(RFfit(estmodel, data=d, modus_operandi='sloppy'))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(Aniso=RMangle(angle=pi/4, ratio=3)) plot(model, dim=2) x <- seq(0, 2, 0.05) z <- RFsimulate(x, x, model=model) plot(z) model <- RMexp(Aniso=RMangle(angle=pi/4, lat.angle=pi/8, diag=c(1,2,3))) x <- seq(0, 2, 0.2) z <- RFsimulate(x, x, x, model=model) plot(z, MARGIN.slices=3) ## next model gives an example how to estimate the parameters back n <- 20 x <- runif(n, 0, 10) y <- runif(n, 0, 10) coords <- expand.grid(x, y) model <- RMexp(Aniso=RMangle(angle=pi/4, diag=c(1/4, 1/12))) d <- RFsimulate(model, x=coords[, 1], y=coords[, 2], n=10) estmodel <- RMexp(Aniso=RMangle(angle=NA, diag=c(NA, NA))) system.time(RFfit(estmodel, data=d, modus_operandi='sloppy'))
Askey's model
RMaskey(alpha, var, scale, Aniso, proj) RMtent(var, scale, Aniso, proj)
RMaskey(alpha, var, scale, Aniso, proj) RMtent(var, scale, Aniso, proj)
alpha |
a numerical value in the interval [0,1] |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This covariance function is valid for dimension if
.
For
we get the well-known triangle (or tent)
model, which is only valid on the real line.
RMaskey
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Covariance function
Askey, R. (1973) Radial characteristic functions. Technical report, Research Center, University of Wisconsin-Madison.
Golubov, B. I. (1981) On Abel-Poisson type and Riesz means, Anal. Math. 7, 161-184.
Applications as covariance function
Gneiting, T. (1999) Correlation functions for atmospheric data analysis. Quart. J. Roy. Meteor. Soc., 125:2449-2464.
Gneiting, T. (2002) Compactly supported correlation functions. J. Multivar. Anal., 83:493-508.
Wendland, H. (1994) Ein Beitrag zur Interpolation mit radialen Basisfunktionen. Diplomarbeit, Goettingen.
Wendland, H. Piecewise polynomial, positive definite and compactly supported radial functions of minimal degree. Adv. Comput. Math., 4:389-396, 1995.
Tail correlation function (for )
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
RMmodel
,
RMbigneiting
,
RMgengneiting
,
RMgneiting
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMtent() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMtent() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMave
is a univariate stationary covariance model
which depends on a normal scale mixture covariance model .
The corresponding covariance function only depends on the difference
between two points in
the
-dimensional space and is given by
where is the identity matrix. The spatial dimension is
and
is real-valued.
RMave(phi, A, z, spacetime, var, scale, Aniso, proj)
RMave(phi, A, z, spacetime, var, scale, Aniso, proj)
phi |
a covariance model which is a normal mixture, that means an
|
A |
a symmetric |
z |
a |
spacetime |
logical. If FALSE then the model is interpreted as
if |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
See Schlather, M. (2010), Example 13 with l=1.
RMave
returns an object of class RMmodel
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (2010) Some covariance models based on normal scale mixtures. Bernoulli, 16, 780-797.
RFfit
,
RFsimulate
,
RMmodel
,
RMstp
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Example of an evaluation of the ave2-covariance function ## in three different ways ## --------------------------------------------------------- ## some parameters A and z A <- matrix(c(2,1,1,2),ncol=2) z <- c(1,2) ## h for evalutation h <- c(1,2) ## some abbreviations E <- matrix(c(1,0,0,1),ncol=2) B <- A %*% h %*% t(h) %*% A phi <- function(t){return(RFcov(RMwhittle(1), t))} ## --------------------------------------------------------- ## the following should yield the same value 3 times ## (also for other choices of A,z and h) z1 <- RFcov( model=RMave(RMwhittle(1),A=A,z=z) , x=t(c(h,0)) ) z2 <- RFcov( model=RMave(RMwhittle(1),A=A,z=z,spacetime=FALSE) , x=t(h) ) z3 <- ( (det(E+2*B))^(-1/2) ) * phi( sqrt( sum(h*h)/2 + (t(z) %*% h)^2 * ( 1-2*t(h) %*% A %*% solve(E+2*B) %*% A %*% h) ) ) ## ## Not run: stopifnot(abs(z1-z2)<1e-12, abs(z2-z3)<1e-12)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Example of an evaluation of the ave2-covariance function ## in three different ways ## --------------------------------------------------------- ## some parameters A and z A <- matrix(c(2,1,1,2),ncol=2) z <- c(1,2) ## h for evalutation h <- c(1,2) ## some abbreviations E <- matrix(c(1,0,0,1),ncol=2) B <- A %*% h %*% t(h) %*% A phi <- function(t){return(RFcov(RMwhittle(1), t))} ## --------------------------------------------------------- ## the following should yield the same value 3 times ## (also for other choices of A,z and h) z1 <- RFcov( model=RMave(RMwhittle(1),A=A,z=z) , x=t(c(h,0)) ) z2 <- RFcov( model=RMave(RMwhittle(1),A=A,z=z,spacetime=FALSE) , x=t(h) ) z3 <- ( (det(E+2*B))^(-1/2) ) * phi( sqrt( sum(h*h)/2 + (t(z) %*% h)^2 * ( 1-2*t(h) %*% A %*% solve(E+2*B) %*% A %*% h) ) ) ## ## Not run: stopifnot(abs(z1-z2)<1e-12, abs(z2-z3)<1e-12)
RMball
refers to the indicator function of a ball
with radius 1.
RMball(var, scale, Aniso, proj)
RMball(var, scale, Aniso, proj)
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMpolygon
,
RMspheric
,
RFsimulate
,
RMmodel
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,10,len=100) model <- RMball(var=2,scale=1.5) plot(model) z <- RFsimulate(RPpoisson(model),x=x,y=x,intensity=0.1) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,10,len=100) model <- RMball(var=2,scale=1.5) plot(model) z <- RFsimulate(RPpoisson(model),x=x,y=x,intensity=0.1) plot(z)
RMbcw
is a variogram model
that bridges between some intrinsically stationary isotropic processes
and some stationary ones. It reunifies the
RMgenfbm
‘b’, RMgencauchy
‘c’
and RMdewijsian
‘w’.
The corresponding centered semi-variogram only depends on the distance
between two points and is given by
where and
.
RMbcw(alpha, beta, c, var, scale, Aniso, proj)
RMbcw(alpha, beta, c, var, scale, Aniso, proj)
alpha |
a numerical value; should be in the interval (0,2]. |
beta |
a numerical value; should be in the interval (-infty,2]. |
c |
only for experts. If given, a not necessarily positive definite
function |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
For ,
,
we have the generalized fractal Brownian motion
RMgenfbm
,
the generalized Cauchy model RMgencauchy
,
and the de Wisjian model RMdewijsian
, respectively.
Hence its two arguments alpha
and beta
allow for modelling the smoothness and a wide range of tail behaviour,
respectively.
RMbcw
returns an object of class RMmodel
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M (2014) A parametric variogram model bridging between stationary and intrinsically stationary processes. arxiv 1412.1914.
RMlsfbm
is equipped with Matheron's constant for
the fractional brownian motion,
RMgenfbm
,
RMgencauchy
,
RMdewijsian
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbcw(alpha=1, beta=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbcw(alpha=1, beta=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMbernoulli
gives
the centered correlation function of a binary field,
obtained by thresholding a Gaussian field.
RMbernoulli(phi, threshold, correlation, centred, var, scale, Aniso, proj)
RMbernoulli(phi, threshold, correlation, centred, var, scale, Aniso, proj)
phi |
covariance function of class |
threshold |
real valued threshold, see
Default: 0. |
correlation |
logical. If Default: |
centred |
logical. If Default: |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This model yields the covariance function of the field
that is returned by RPbernoulli
.
RMbernoulli
returns an object of class RMmodel
.
Previous to version 3.0.33 the covariance function was returned, not the correlation function.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Ballani, Schlather
RPbernoulli
,
RMmodel
,
RFsimulate
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again threshold <- 0 x <- seq(0, 5, 0.02) GaussModel <- RMgneiting() n <- 1000 z <- RFsimulate(RPbernoulli(GaussModel, threshold=threshold), x=x, n=n) plot(z) model <- RMbernoulli(RMgauss(), threshold=threshold, correlation=FALSE) plot(model, xlim=c(0,5)) z1 <- as.matrix(z) estim.cov <- apply(z1, 1, function(x) cov(x, z1[1,])) points(coordinates(z), estim.cov, col="red")
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again threshold <- 0 x <- seq(0, 5, 0.02) GaussModel <- RMgneiting() n <- 1000 z <- RFsimulate(RPbernoulli(GaussModel, threshold=threshold), x=x, n=n) plot(z) model <- RMbernoulli(RMgauss(), threshold=threshold, correlation=FALSE) plot(model, xlim=c(0,5)) z1 <- as.matrix(z) estim.cov <- apply(z1, 1, function(x) cov(x, z1[1,])) points(coordinates(z), estim.cov, col="red")
RMbessel
is a stationary isotropic covariance model
belonging to the Bessel family.
The corresponding covariance function only depends on the distance between
two points and is given by
where ,
denotes the gamma function and
is a Bessel function of first kind.
RMbessel(nu, var, scale, Aniso, proj)
RMbessel(nu, var, scale, Aniso, proj)
nu |
a numerical value; should be equal to or greater than
|
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This covariance models a hole effect (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 92, cf. Gelfand et al. (2010), p. 26).
An important case is
which gives the covariance function
and which is only valid for . This equals
RMdampedcos
for , there.
A second important case is with covariance function
which is valid for .
This coincides with
RMwave
.
Note that all valid continuous stationary isotropic covariance
functions for -dimensional random fields
can be written as scale mixtures of a Bessel type
covariance function with
(cf. Gelfand et al., 2010, pp. 21–22).
RMbessel
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
http://homepage.tudelft.nl/11r49/documents/wi4006/bessel.pdf
RMdampedcos
,
RMwave
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbessel(nu=1, scale=0.1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbessel(nu=1, scale=0.1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMbicauchy
is a bivariate stationary isotropic covariance model
whose corresponding covariance function only depends on the distance
between
two points.
For constraints on the constants see Details.
RMbicauchy(alpha, beta, s, rho, var, scale, Aniso, proj)
RMbicauchy(alpha, beta, s, rho, var, scale, Aniso, proj)
alpha |
[to be done] |
beta |
[to be done] |
s |
a vector of length 3 of numerical values; each entry
positive; the vector |
rho |
[to be done] |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
Constraints on the constants: [to be done]
RMbicauchy
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Moreva, O., Schlather, M. (2016) Modelling and simulation of bivariate Gaussian random fields. arXiv 1412.1914
RMcauchy
,
Multivariate RMmodels.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## todo
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## todo
RMbigneiting
is a bivariate stationary isotropic covariance
model family whose elements
are specified by seven parameters.
Let
Then,
and
is the generalized Gneiting model
with parameters
and
, see
RMgengneiting
, i.e.,
RMbigneiting(kappa, mu, s, sred12, gamma, cdiag, rhored, c, var, scale, Aniso, proj)
RMbigneiting(kappa, mu, s, sred12, gamma, cdiag, rhored, c, var, scale, Aniso, proj)
kappa |
argument that chooses between the four different covariance
models and may take values |
mu |
|
s |
vector of two elements giving the scale of the models on the
diagonal, i.e. the vector |
sred12 |
value in |
gamma |
a vector of length 3 of numerical values; each entry is
positive.
The vector |
cdiag |
a vector of length 2 of numerical values; each entry
positive; the vector |
c |
a vector of length 3 of numerical values;
the vector Either
|
rhored |
value in |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
A sufficient condition for the
constant is
where .
The constant in the formula above is obtained as follows:
Let
If and
then
else
In the function RMbigneiting
, either c
is
passed, then the above condition is checked, or rhored
is passed;
then is calculated by the above formula.
RMbigneiting
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Bevilacqua, M., Daley, D.J., Porcu, E., Schlather, M. (2012) Classes of compactly supported correlation functions for multivariate random fields. Technical report.
RMbigeneiting
is based on this original work.
D.J. Daley, E. Porcu and M. Bevilacqua have published end of
2014 an article intentionally
without clarifying the genuine authorship of RMbigneiting
,
in particular,
neither referring to this original work nor to RandomFields,
which has included RMbigneiting
since version 3.0.5 (05 Dec
2013).
Gneiting, T. (1999) Correlation functions for atmospherical data analysis. Q. J. Roy. Meteor. Soc Part A 125, 2449-2464.
Wendland, H. (2005) Scattered Data Approximation. Cambridge Monogr. Appl. Comput. Math.
RMaskey
,
RMbiwm
,
RMgengneiting
,
RMgneiting
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbigneiting(kappa=2, mu=0.5, gamma=c(0, 3, 6), rhored=1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbigneiting(kappa=2, mu=0.5, gamma=c(0, 3, 6), rhored=1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMbistable
is a bivariate stationary isotropic covariance model
whose corresponding covariance function only depends on the distance
between
two points.
For constraints on the constants see Details.
RMbistable(alpha, s, cdiag, rho, rhored, betared, alphadiag, var, scale, Aniso, proj)
RMbistable(alpha, s, cdiag, rho, rhored, betared, alphadiag, var, scale, Aniso, proj)
alpha , alphadiag
|
[to be done] |
s |
a vector of length 3 of numerical values; each entry
positive; the vector |
cdiag |
[to be done] |
rho , rhored
|
[to be done] |
betared |
to do |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
Constraints on the constants: [to be done]
RMbistable
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Moreva, O., Schlather, M. (2016) Modelling and simulation of bivariate Gaussian random fields. arXiv 1412.1914
RMstable
,
Multivariate RMmodels.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## todo
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## todo
RMbiwm
is a bivariate stationary isotropic covariance model
whose corresponding covariance function only depends on the distance
between
two points and is given for
by
Here is the covariance of the
RMwhittle
model.
For constraints on the constants see Details.
RMbiwm(nudiag, nured12, nu, s, cdiag, rhored, c, notinvnu, var, scale, Aniso, proj)
RMbiwm(nudiag, nured12, nu, s, cdiag, rhored, c, notinvnu, var, scale, Aniso, proj)
nudiag |
a vector of length 2 of numerical values; each entry
positive; the vector |
nured12 |
a numerical value in the interval |
nu |
alternative to |
s |
a vector of length 3 of numerical values; each entry
positive; the vector |
cdiag |
a vector of length 2 of numerical values; each entry
positive; the vector |
rhored |
a numerical value; in the interval |
c |
a vector of
length 3 of numerical values;
the vector |
notinvnu |
logical or |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
Constraints on the constants: For the diagonal elements we have
For the offdiagonal elements we have
for some constant and
for some constant in
.
The constants and
in the last equation are given as follows:
where is the Gamma function and
is the dimension
of the space.
The constant
is
the infimum of the function
on
where
(cf. Gneiting, T., Kleiber, W., Schlather, M. (2010), Full Bivariate Matern Model (Section 2.2)).
RMbiwm
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T., Kleiber, W., Schlather, M. (2010) Matern covariance functions for multivariate random fields JASA
RMparswm
,
RMwhittle
,
RMmodel
,
RFsimulate
,
RFfit
,
Multivariate RMmodels.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- seq(-10, 10, 0.2) model <- RMbiwm(nudiag=c(0.3, 2), nured=1, rhored=1, cdiag=c(1, 1.5), s=c(1, 1, 2)) plot(model) plot(RFsimulate(model, x, y))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- seq(-10, 10, 0.2) model <- RMbiwm(nudiag=c(0.3, 2), nured=1, rhored=1, cdiag=c(1, 1.5), s=c(1, 1, 2)) plot(model) plot(RFsimulate(model, x, y))
Let be an
-variate random field
and
a partition of the space.
Then
i.e. the model blends the components of to a new, univariate
model
.
RMblend(multi, blend, thresholds, var, scale, Aniso, proj)
RMblend(multi, blend, thresholds, var, scale, Aniso, proj)
multi |
a multivariate covariance function |
blend , thresholds
|
The Default: |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMblend
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Bonat, W.H. , Ribeiro, P. Jr. and Schlather, M. (2019) Modelling non-stationarity in scale. In preparation.
Genton, Apanovich Biometrika.
RMSadvanced
,
RMbubble
,
RMscale
,
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, if (interactive()) 0.01 else 0.5) len <- length(x) m <- matrix(1:len, nc=len, nr=len) m <- m > t(m) image(m) # two areas separated by the first bisector biwm <- RMbiwm(nudiag=c(0.3, 1), nured=1, rhored=1, cdiag=c(1, 1), s=c(1, 1, 0.5)) model <- RMblend(multi=biwm, blend=RMcovariate(data = as.double(m), raw=TRUE)) plot(z <- RFsimulate(model, x, x)) ## takes a while ...
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, if (interactive()) 0.01 else 0.5) len <- length(x) m <- matrix(1:len, nc=len, nr=len) m <- m > t(m) image(m) # two areas separated by the first bisector biwm <- RMbiwm(nudiag=c(0.3, 1), nured=1, rhored=1, cdiag=c(1, 1), s=c(1, 1, 0.5)) model <- RMblend(multi=biwm, blend=RMcovariate(data = as.double(m), raw=TRUE)) plot(z <- RFsimulate(model, x, x)) ## takes a while ...
This function can be used to model a max-stable process based on a binary field, with the same extremal correlation function as a Brown-Resnick process
Here, is the standard normal distribution
function, and
is a semi-variogram with sill
RMbr2bg(phi, var, scale, Aniso, proj)
RMbr2bg(phi, var, scale, Aniso, proj)
phi |
covariance function of class |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMbr2bg
binary random field RPbernoulli
simulated with RMbr2bg(RMmodel())
has
a uncentered covariance function that equals
the tail correlation function of the max-stable process constructed with this binary random field
the tail correlation function of Brown-Resnick process with
variogram RMmodel
.
Note that the reference paper is based on the notion of the (genuine) variogram, whereas the package RandomFields is based on the notion of semi-variogram. So formulae differ by factor 2.
object of class RMmodel
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
maxstableAdvanced,
RMbr2eg
,
RMmodel
,
RMm2r
,
RPbernoulli
,
RPbrownresnick
,
RPschlather
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(var=1.62 / 2) x <- seq(0, 10, 0.05) z <- RFsimulate(RPschlather(RMbr2eg(model)), x, x) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(var=1.62 / 2) x <- seq(0, 10, 0.05) z <- RFsimulate(RPschlather(RMbr2eg(model)), x, x) plot(z)
This function can be used to model a max-stable process based on a binary field, with the same extremal correlation function as a Brown-Resnick process
Here, is the standard normal distribution
function, and
is a semi-variogram with sill
RMbr2eg(phi, var, scale, Aniso, proj)
RMbr2eg(phi, var, scale, Aniso, proj)
phi |
covariance function of class |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMbr2eg
The extremal Gaussian model RPschlather
simulated with RMbr2eg(RMmodel())
has
tail correlation function that equals
the tail correlation function of Brown-Resnick process with
variogram RMmodel
.
Note that the reference paper is based on the notion of the (genuine) variogram, whereas the package RandomFields is based on the notion of semi-variogram. So formulae differ by factor 2.
object of class RMmodel
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
maxstableAdvanced,
RMbr2bg
,
RMmodel
,
RMm2r
,
RPbernoulli
,
RPbrownresnick
,
RPschlather
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(var=1.62 / 2) binary.model <- RPbernoulli(RMbr2bg(model)) x <- seq(0, 10, 0.05) z <- RFsimulate(RPschlather(binary.model), x, x) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp(var=1.62 / 2) binary.model <- RPbernoulli(RMbr2bg(model)) x <- seq(0, 10, 0.05) z <- RFsimulate(RPschlather(binary.model), x, x) plot(z)
RMbrownresnick
defines
the tail correlation function of the Brown-Resnick process.
where is the standard normal distribution function
and
is the semi-variogram.
RMbrownresnick(phi, var, scale, Aniso, proj)
RMbrownresnick(phi, var, scale, Aniso, proj)
phi |
variogram of class |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
For a given RMmodel
the function
RMbrownresnick(RMmodel())
'returns' the tail correlation
function of a Brown-Resnick process with variogram RMmodel
.
object of class RMmodel
In the paper Kabluchko et al. (2009) the variogram instead of the semi-variogram is considered, so the formulae differ slightly.
In Version 3.0.33 a typo has been corrected.
Here, a definition is used that is consistent with the rest of the package.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Kabluchko, Z., Schlather, M. & de Haan, L (2009) Stationary max-stable random fields associated to negative definite functions Ann. Probab. 37, 2042-2065.
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
RFsimulate
,
RMm2r
, RMm3b
, RMmps
,
RMmodel
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again #plot covariance model of type RMbrownresnick RMmodel <- RMfbm(alpha=1.5, scale=0.2) plot(RMbrownresnick(RMmodel)) #simulate and plot corresponding Gaussian random field x <- seq(-5, 5, 0.05) z <- RFsimulate(RMbrownresnick(RMmodel), x=x, y=x) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again #plot covariance model of type RMbrownresnick RMmodel <- RMfbm(alpha=1.5, scale=0.2) plot(RMbrownresnick(RMmodel)) #simulate and plot corresponding Gaussian random field x <- seq(-5, 5, 0.05) z <- RFsimulate(RMbrownresnick(RMmodel), x=x, y=x) plot(z)
A model that allows for arbitray areas of scale applied to an isotropic model, i.e.
as long as . Here,
is the scaling at location
,
The cross-correlations between areas of
different scales are given through a modified distance
. Let
be a finite
subset of
depending on the scale
.
Let
be a weight for an auxiliary point
with
.
Let
. Then
Here, is the finite set of values
that are realized on the locations of interest
and
is the difference of two
realized and ordered values of the scaling
.
RMbubble(phi, scaling, z, weight, minscale, barycentre, var, scale, Aniso, proj)
RMbubble(phi, scaling, z, weight, minscale, barycentre, var, scale, Aniso, proj)
phi |
isotropic submodel |
scaling |
model that gives the non-stationary scaling |
z |
matrix of the union of all |
weight |
vector of weights |
minscale |
vector for partioning |
barycentre |
logical. If The argument has no effect when Default: |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
minscale
gives the minimal scale value above which
the corresponding points
z
define the set .
The validity of the set
ends with the next lower value
given.
Let minscale = (10, 10, 10, 7, 7, 7, 0.5)
. Then for some
-dimensional vectors
we have
Note that, in this case, all realized scaling values must be
. Note further, that the weights for the subset must
sum up to one, i.e.
RMbubble
returns an object of class RMmodel
.
This model is defined only for grids.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Bonat, W.H. , Ribeiro, P. Jr. and Schlather, M. (2019) Modelling non-stationarity in scale. In preparation.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, if (interactive()) 0.02 else 0.5) d <- sqrt(rowSums(as.matrix(expand.grid(x-0.5, x-0.5))^2)) d <- matrix(d < 0.25, nc=length(x)) image(d) scale <- RMcovariate(data=as.double(d) * 2 + 0.5, raw=TRUE) ## two models: ## the frist uses the standard approach for determining the ## reference point z, which is based on gradients ## the second takes the centre of the ball model1 <- RMbubble(RMexp(), scaling=scale) model2 <- RMbubble(RMexp(), scaling=scale, z=c(0.5, 0.5)) model3 <- RMbubble(RMexp(), scaling=scale, barycentre=TRUE) # approx. of model2 ## model2 has slightly higher correlations than model1: C1 <- RFcovmatrix(model1, x, x) C2 <- RFcovmatrix(model2, x, x) C3 <- RFcovmatrix(model3, x, x) print(range(C2 - C1)) dev.new(); hist(C2 - C1) print(range(C3 - C2)) # only small differences to C2 print(mean(C3 - C2)) dev.new(); hist(C3 - C2) plot(z1 <- RFsimulate(model1, x, x)) plot(z2 <- RFsimulate(model2, x, x)) plot(z3 <- RFsimulate(model3, x, x)) # only tiny differences to z2 ## in the following we compare the standard bubble model with ## the models RMblend, RMscale and RMS (so, model2 above ## performs even better) biwm <- RMbiwm(nudiag=c(0.5, 0.5), nured=1, rhored=1, cdiag=c(1, 1), s=c(0.5, 2.5, 0.5)) blend <- RMblend(multi=biwm, blend=RMcovariate(data = as.double(d), raw=TRUE)) plot(zblend <- RFsimulate(blend, x, x)) ## takes a while ... Cblend <- RFcovmatrix(blend, x, x) Mscale <- RMscale(RMexp(), scaling = scale, penalty=RMid() / 2) plot(zscale <- RFsimulate(Mscale, x, x)) Cscale <- RFcovmatrix(Mscale, x, x) Mscale2 <- RMscale(RMexp(), scaling = scale, penalty=RMid() / 20000) plot(zscale2 <- RFsimulate(Mscale2, x, x)) Cscale2 <- RFcovmatrix(Mscale2, x, x) S <- RMexp(scale = scale) plot(zS <- RFsimulate(S, x, x)) CS <- RFcovmatrix(S, x, x) print(range(C1 - CS)) print(range(C1 - Cscale)) print(range(C1 - Cscale2)) print(range(C1 - Cblend)) dev.new(); hist(C1-CS) ## C1 is better dev.new(); hist(C1-Cscale) ## C1 is better dev.new(); hist(C1-Cscale2) ## both are equally good. Maybe C1 slightly better dev.new(); hist(C1-Cblend) ## C1 is better
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, if (interactive()) 0.02 else 0.5) d <- sqrt(rowSums(as.matrix(expand.grid(x-0.5, x-0.5))^2)) d <- matrix(d < 0.25, nc=length(x)) image(d) scale <- RMcovariate(data=as.double(d) * 2 + 0.5, raw=TRUE) ## two models: ## the frist uses the standard approach for determining the ## reference point z, which is based on gradients ## the second takes the centre of the ball model1 <- RMbubble(RMexp(), scaling=scale) model2 <- RMbubble(RMexp(), scaling=scale, z=c(0.5, 0.5)) model3 <- RMbubble(RMexp(), scaling=scale, barycentre=TRUE) # approx. of model2 ## model2 has slightly higher correlations than model1: C1 <- RFcovmatrix(model1, x, x) C2 <- RFcovmatrix(model2, x, x) C3 <- RFcovmatrix(model3, x, x) print(range(C2 - C1)) dev.new(); hist(C2 - C1) print(range(C3 - C2)) # only small differences to C2 print(mean(C3 - C2)) dev.new(); hist(C3 - C2) plot(z1 <- RFsimulate(model1, x, x)) plot(z2 <- RFsimulate(model2, x, x)) plot(z3 <- RFsimulate(model3, x, x)) # only tiny differences to z2 ## in the following we compare the standard bubble model with ## the models RMblend, RMscale and RMS (so, model2 above ## performs even better) biwm <- RMbiwm(nudiag=c(0.5, 0.5), nured=1, rhored=1, cdiag=c(1, 1), s=c(0.5, 2.5, 0.5)) blend <- RMblend(multi=biwm, blend=RMcovariate(data = as.double(d), raw=TRUE)) plot(zblend <- RFsimulate(blend, x, x)) ## takes a while ... Cblend <- RFcovmatrix(blend, x, x) Mscale <- RMscale(RMexp(), scaling = scale, penalty=RMid() / 2) plot(zscale <- RFsimulate(Mscale, x, x)) Cscale <- RFcovmatrix(Mscale, x, x) Mscale2 <- RMscale(RMexp(), scaling = scale, penalty=RMid() / 20000) plot(zscale2 <- RFsimulate(Mscale2, x, x)) Cscale2 <- RFcovmatrix(Mscale2, x, x) S <- RMexp(scale = scale) plot(zS <- RFsimulate(S, x, x)) CS <- RFcovmatrix(S, x, x) print(range(C1 - CS)) print(range(C1 - Cscale)) print(range(C1 - Cscale2)) print(range(C1 - Cblend)) dev.new(); hist(C1-CS) ## C1 is better dev.new(); hist(C1-Cscale) ## C1 is better dev.new(); hist(C1-Cscale2) ## both are equally good. Maybe C1 slightly better dev.new(); hist(C1-Cblend) ## C1 is better
RMcauchy
is a stationary isotropic covariance model
belonging to the Cauchy family.
The corresponding covariance function only depends on the distance between
two points and is given by
where .
See also
RMgencauchy
.
RMcauchy(gamma, var, scale, Aniso, proj)
RMcauchy(gamma, var, scale, Aniso, proj)
gamma |
a numerical value; should be positive to provide a valid covariance function for a random field of any dimension. |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The paramater determines the asymptotic power law. The smaller
, the longer the long-range dependence. The covariance function is very regular near the origin, because its Taylor expansion only contains even terms and reaches its sill slowly.
Each covariance function of the Cauchy Family is a normal scale mixture.
The generalized Cauchy Family (see RMgencauchy
)
includes this family for the choice and
.
The generalized Hyperbolic Family (see
RMhyperbolic
)
includes this family for the choice and
; in this case scale=
.
RMcauchy
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. SIAM review 46, 269–282.
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
RMcauchytbm
,
RMgencauchy
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcauchy(gamma=1) x <- seq(0, 10, 0.02) plot(model, xlim=c(-3, 3)) plot(RFsimulate(model, x=x, n=4))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcauchy(gamma=1) x <- seq(0, 10, 0.02) plot(model, xlim=c(-3, 3)) plot(RFsimulate(model, x=x, n=4))
RMcauchytbm()
is a shortcut of
RMtbm(RMgencauchy())
and is
given here for downwards compatibility.
RMcauchytbm(alpha, beta, gamma, var, scale, Aniso, proj)
RMcauchytbm(alpha, beta, gamma, var, scale, Aniso, proj)
alpha , beta
|
See |
gamma |
is the same as |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMcauchytbm
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. SIAM review 46, 269–282.
RMcauchy
,
RMgencauchy
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcauchytbm(alpha=1, beta=1, gamma=3) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcauchytbm(alpha=1, beta=1, gamma=3) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
in d=2RMchoquet
is an isotropic covariance model. The
corresponding covariance function only depends on the angle
between two points on the sphere and is given for d=2 by
where
and is the Legendre Polynomial of integer order
.
RMchoquet(b)
RMchoquet(b)
b |
a numerical vector of weights in |
By the results (cf. Gneiting, T. (2013), p.1333) of Schoenberg and
others like Menegatto, Chen, Sun, Oliveira and Peron, the class
of all real valued funcions on
, with
and such that the associated isotropic function
is (strictly) positive definite is represented by this covariance model. The model can be interpreted as Choquet representation in terms of extremal members, which are non-strictly positive definite.
Special cases are the multiquadric family (see
RMmultiquad
) and the model of the sine power function (see
RMsinepower
).
RMchoquet
returns an object of class RMmodel
.
Christoph Berreth; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. (2013) Strictly and non-strictly positive definite functions on spheres. Bernoulli, 19(4), 1327-1349.
Schoenberg, I.J. (1942) Positive definite functions on spheres. Duke Math.J.,9, 96-108.
Menegatto, V.A. (1994) Strictly positive definite kernels on the Hilbert sphere. Appl. Anal., 55, 91-101.
Chen, D., Menegatto, V.A., and Sun, X. (2003) A necessary and sufficient condition for strictly positive definite functions on spheres. Proc. Amer. Math. Soc.,131, 2733-2740.
Menegatto, V.A., Oliveira, C.P. and Peron, A.P. (2006) Strictly positive definite kernels on subsets of the complex plane. Comput. Math. Appl., 51, 1233-1250.
RMmodel
,
RFsimulate
,
RFfit
,
spherical models
,
RMmultiquad
,
RMsinepower
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## to do
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## to do
RMcircular
is a stationary isotropic covariance model
which is only valid for dimensions .
The corresponding covariance function only depends on the distance
between
two points and is given by
RMcircular(var, scale, Aniso, proj)
RMcircular(var, scale, Aniso, proj)
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model is only valid for dimensions .
It is a covariance function with compact support
(cf. Chiles, J.-P. and Delfiner, P. (1999), p. 82).
RMcircular
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcircular() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcircular() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMconstant
defines a spatially constant covariance function.
RMconstant(M, var)
RMconstant(M, var)
M |
a numerical matrix defining the user-defined covariance for a random field; the matrix should be positive definite, symmetric and its dimension should be equal to the length of observation or simulation vector. |
var |
variance |
RMconstant
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMconstant(diag(2),var=3) plot(model) x <- seq(0,10,length=100) z <- RFsimulate(model=model,x=x)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMconstant(diag(2),var=3) plot(model) x <- seq(0,10,length=100) z <- RFsimulate(model=model,x=x)
This function generalizes the well-known non-stationary covariance
function of the Brownian motion with variogram
,
to arbitrary variogram models any spatial processes of any dimension
and multivariability.
Furthermore, the
standard condition for the Brownian motion is that
variance equals
at the origin,
i.e.,
for any zero mean Gaussian process
with variogram
is replaced by
with
.
For a given variogram ,
and
, the model
equals
RMcov(gamma, x, y=NULL, z=NULL, T=NULL, grid, a, var, scale, Aniso, proj, raw, norm)
RMcov(gamma, x, y=NULL, z=NULL, T=NULL, grid, a, var, scale, Aniso, proj, raw, norm)
gamma |
a variogram model. Possibly multivariate. |
x , y , z , T , grid
|
The usual arguments as in |
a |
vector of weights. The length of |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
raw |
logical. If |
norm |
optional model that gives the norm between locations |
RMcov
returns an object of class RMmodel
Martin Schlather, [email protected]
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again bm <- RMfbm(alpha=1) plot(bm) x <- seq(0, 6, if (interactive()) 0.125 else 3) plot(RFsimulate(bm, x)) ## standardizing with the random variable at the origin z1 <- RFsimulate(RMcov(bm), x) plot(z1) z1 <- as.vector(z1) zero <- which(abs(x) == 0) stopifnot(abs(z1[zero]) < 1e-13) ## standardizing with the random variable at the center of the interval z2 <- RFsimulate(RMcov(bm, "center"), x) plot(z2) z2 <- as.vector(z2) stopifnot(abs(z2[(length(z2) + 1) / 2]) < 1e-13) ## standardizing with the random variables at the end points of the interval z3 <- RFsimulate(RMcov(bm, "extremals"), x) plot(z3) z3 <- as.vector(z3) stopifnot(abs(z3[1] + z3[length(z3)]) < 1e-13)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again bm <- RMfbm(alpha=1) plot(bm) x <- seq(0, 6, if (interactive()) 0.125 else 3) plot(RFsimulate(bm, x)) ## standardizing with the random variable at the origin z1 <- RFsimulate(RMcov(bm), x) plot(z1) z1 <- as.vector(z1) zero <- which(abs(x) == 0) stopifnot(abs(z1[zero]) < 1e-13) ## standardizing with the random variable at the center of the interval z2 <- RFsimulate(RMcov(bm, "center"), x) plot(z2) z2 <- as.vector(z2) stopifnot(abs(z2[(length(z2) + 1) / 2]) < 1e-13) ## standardizing with the random variables at the end points of the interval z3 <- RFsimulate(RMcov(bm, "extremals"), x) plot(z3) z3 <- as.vector(z3) stopifnot(abs(z3[1] + z3[length(z3)]) < 1e-13)
The model makes covariates available.
RMcovariate(formula=NULL, data, x, y=NULL, z=NULL, T=NULL, grid, raw, norm, addNA, factor)
RMcovariate(formula=NULL, data, x, y=NULL, z=NULL, T=NULL, grid, raw, norm, addNA, factor)
formula , data
|
formula and by which the data should be modelled, similar to lm. If |
x , y , z , T , grid
|
optional.
The usual arguments as in |
raw |
logical. If |
norm |
optional model that gives the norm between locations |
addNA |
If |
factor |
real value. From user's point of view very much the same
as setting the argument |
.
The function interpolates (nearest neighbour) between the values.
RMcovariate
returns an object of class RMmodel
.
c
, x
also accept lists of data. However, its use is not in an advanced
stage yet.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again z <- 0.2 + (1:10) RFfctn(RMcovariate(z), 1:10) RFfctn(RMcovariate(data=z, x=1:10), c(2, 2.1, 2.5, 3))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again z <- 0.2 + (1:10) RFfctn(RMcovariate(z), 1:10) RFfctn(RMcovariate(data=z, x=1:10), c(2, 2.1, 2.5, 3))
RMcoxisham
is a stationary covariance model
which depends on a univariate stationary isotropic covariance model
, which is a normal scale mixture.
The corresponding covariance function only depends on the difference
between two points in
-dimensional space and is given by
Here is a vector in
-dimensional space;
is the
-identity matrix and
is
a
-correlation matrix with
.
The parameter
is in
.
Currently, the implementation is done only for
.
RMcoxisham(phi,mu,D,beta,var, scale, Aniso, proj)
RMcoxisham(phi,mu,D,beta,var, scale, Aniso, proj)
phi |
a univariate stationary isotropic covariance model for random fields
on |
mu |
a vector in |
D |
a |
beta |
numeric in the interval |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This model stems from a rainfall model (cf. Cox, D.R., Isham, V.S. (1988)) and equals the following expectation
where the random wind speed vector follows a
-variate
normal distribution with expectation
and covariance matrix
(cf. Schlather, M. (2010), Example 9).
RMcoxisham
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Cox, D.R., Isham, V.S. (1988) A simple spatial-temporal model of rainfall. Proc. R. Soc. Lond. A, 415, 317-328.
Schlather, M. (2010) On some covariance models based on normal scale mixtures. Bernoulli, 16, 780-797.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcoxisham(RMgauss(), mu=1, D=1) x <- seq(0, 10, 0.3) plot(model, dim=2) plot(RFsimulate(model, x=x, y=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcoxisham(RMgauss(), mu=1, D=1) x <- seq(0, 10, 0.3) plot(model, dim=2) plot(RFsimulate(model, x=x, y=x))
RMcubic
is a stationary isotropic covariance model
which is only valid for dimensions .
The corresponding covariance function only depends on the distance
between
two points and is given by
RMcubic(var, scale, Aniso, proj)
RMcubic(var, scale, Aniso, proj)
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model is only valid for dimensions .
It is a 2 times differentiable covariance function with compact support
(cf. Chiles, J.-P. and Delfiner, P. (1999), p. 84).
RMcubic
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcubic() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcubic() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMcurlfree
is a multivariate covariance model which depends on
a univariate stationary covariance model where the covariance function phi(h)
is twice differentiable.
The corresponding matrix-valued covariance function C of the model
only depends on the difference between two points and it is
given by the following components:
the potential
the vector field given by
the field of sinks and sources
RMcurlfree(phi, which, var, scale, Aniso, proj)
RMcurlfree(phi, which, var, scale, Aniso, proj)
phi |
a univariate stationary covariance model (2- or 3-dimensional). |
which |
vector of integers. If not given all components are returned; otherwise the selected components are returned. |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model returns the potential field in the first component, the corresponding curlfree field and field of sources and sinks in the last component.
See also the models RMdivfree
and RMvector
.
RMcurlfree
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Scheuerer, M. and Schlather, M. (2012) Covariance Models for Divergence-Free and Curl-Free Random Vector Fields. Stochastic Models 28:3.
RMderiv
,
RMdivfree
,
RMvector
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcurlfree(RMgauss(), scale=4) plot(model, dim=2) x.seq <- y.seq <- seq(-10, 10, 0.2) simulated <- RFsimulate(model=model, x=x.seq, y=y.seq) plot(simulated, select.variables=list(1, c(1, 2:3), 4))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMcurlfree(RMgauss(), scale=4) plot(model, dim=2) x.seq <- y.seq <- seq(-10, 10, 0.2) simulated <- RFsimulate(model=model, x=x.seq, y=y.seq) plot(simulated, select.variables=list(1, c(1, 2:3), 4))
RMcutoff
is a functional on univariate stationary
isotropic covariance functions .
The corresponding function (which is not necessarily a
covariance function,
see details) only depends on the distance
between two
points in
-dimensional space and is given by
The parameters and
are chosen internally such that
is a smooth function.
RMcutoff(phi, diameter, a, var, scale, Aniso, proj)
RMcutoff(phi, diameter, a, var, scale, Aniso, proj)
phi |
a univariate stationary isotropic covariance model. See, for instance,
|
diameter |
a numerical value; should be greater than 0; the diameter of the domain on which the simulation is done |
a |
a numerical value; should be greater than 0; has been shown to be
optimal for |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The algorithm that checks the given parameters knows
only about some few necessary conditions.
Hence it is not ensured that
the cutoff-model is a valid covariance function for any
choice of and the parameters.
For certain models , e.g.
RMstable
,
RMwhittle
and RMgencauchy
, some
sufficient conditions
are known (cf. Gneiting et al. (2006)).
RMcutoff
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T., Sevecikova, H, Percival, D.B., Schlather M., Jiang Y. (2006) Fast and Exact Simulation of Large Gaussian Lattice Systems in $R^2$: Exploring the Limits. J. Comput. Graph. Stat. 15, 483–501.
Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. J. Comput. Graph. Statist. 11, 587–599
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() plot(model, model.cutoff=RMcutoff(model, diameter=1), xlim=c(0, 4)) model <- RMstable(alpha = 0.8) plot(model, model.cutoff=RMcutoff(model, diameter=2), xlim=c(0, 5)) x <- y <- seq(0, 4, 0.05) plot(RFsimulate(RMcutoff(model), x=x, y = y))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() plot(model, model.cutoff=RMcutoff(model, diameter=1), xlim=c(0, 4)) model <- RMstable(alpha = 0.8) plot(model, model.cutoff=RMcutoff(model, diameter=2), xlim=c(0, 5)) x <- y <- seq(0, 4, 0.05) plot(RFsimulate(RMcutoff(model), x=x, y = y))
RMdagum
is a stationary isotropic covariance model.
The corresponding covariance function only depends on the distance between
two points and is given by
The parameters and
can be varied in the intervals
and
, respectively.
RMdagum(beta, gamma, var, scale, Aniso, proj)
RMdagum(beta, gamma, var, scale, Aniso, proj)
beta |
numeric in |
gamma |
numeric in |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
Like the generalized Cauchy model the Dagum family can be used to model fractal dimension and Hurst effect. For a comparison of these see Berg, C. and Mateau, J. and Porcu, E. (2008). This paper also establishes valid parameter choices for the Dagum family, but be careful because therein the model is parameterized differently.
RMdagum
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Berg, C. and Mateau, J. and Porcu, E. (2008) The dagum family of isotropic correlation functions. Bernoulli 14(4), 1134–1149.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdagum(beta=0.5, gamma=0.5, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdagum(beta=0.5, gamma=0.5, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMdampedcos
is a stationary isotropic covariance model.
The corresponding covariance function only depends on the distance between
two points and is given by
RMdampedcos(lambda, var, scale, Aniso, proj)
RMdampedcos(lambda, var, scale, Aniso, proj)
lambda |
numeric. The range depends on the dimension of the random field (see details). |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model is valid for any dimension . However, depending on the dimension of
the random field the following bound for the argument
has to be respected:
This covariance models a hole effect (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 92).
For we obtain the covariance function
which is only valid for
and corresponds to
RMbessel
for
, there.
RMdampedcos
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
RMbessel
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdampedcos(lambda=0.3, scale=0.1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdampedcos(lambda=0.3, scale=0.1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
The only purpose of this function is the declaration of dummy variables for defining more complex relations between parameters that are to be estimated.
Its value as a covariance model is identically zero, independently of the variables declared.
RMdeclare(...)
RMdeclare(...)
... |
the names of additional parameters, not in inverted commas. No values should be given. |
RMdeclare
returns an object of class RMmodel
Only scalars can be defined here, since only scalars can be used within formulae.
Martin Schlather, [email protected]
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## The following two examples illustrate the use of RMdeclare and the ## argument 'params'. The purpose is not to give nice statistical models x <- seq(1, 3, 0.1) ## note that there isn't any harm to declare variables ('u') ## RMdeclare that are of no use in a simulation model <- ~ RMexp(sc=sc1, var=var1) + RMgauss(var=var2, sc=sc2) + RMdeclare(u) p <- list(sc1=2, var1=3, sc2=4, var2=5) z <- RFsimulate(model = model, x=x, y=x, params=p) plot(z) ## note that the model remains the same, only the values in the ## following list change. Here, sc1, var1, sc2 and u are estimated ## and var2 is given by a forula. p.fit <- list(sc1 = NA, var1=NA, var2=~2 * u, sc2 = NA, u=NA) lower <- list(sc1=20, u=5) upper <- list(sc2=1.5, sc1=100, u=15) f <- RFfit(model, data=z, params=p.fit, lower = lower, upper = upper) print(f) ## The second example shows that rather complicated constructions are ## possible, i.e., formulae involving several variables, both known ('abc') ## and unknown ones ('sc', 'var'). Note that there are two different ## 'var's a unknown variable and an argument for RMwhittle ## Not run: model2 <- ~ RMexp(sc) + RMwhittle(var = g, nu=Nu) + RMnugget(var=nugg) + RMexp(var=var, Aniso=matrix(A, nc=2)) + RMdeclare(CCC, DD) p.fit <- list(g=~sc^1.5, nugg=~sc * var * abc, sc=NA, var=~DD, Nu=NA, abc=123, A = ~c(1, 2, DD * CCC, CCC), CCC = NA, DD=NA) lower <- list(sc=1, CCC=1, DD=1) upper <- list(sc=100, CCC=100, DD=100) f2 <- RFfit(model2, data=z, params=p.fit, lower = lower, upper = upper) print(f2) ## End(Not run)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## The following two examples illustrate the use of RMdeclare and the ## argument 'params'. The purpose is not to give nice statistical models x <- seq(1, 3, 0.1) ## note that there isn't any harm to declare variables ('u') ## RMdeclare that are of no use in a simulation model <- ~ RMexp(sc=sc1, var=var1) + RMgauss(var=var2, sc=sc2) + RMdeclare(u) p <- list(sc1=2, var1=3, sc2=4, var2=5) z <- RFsimulate(model = model, x=x, y=x, params=p) plot(z) ## note that the model remains the same, only the values in the ## following list change. Here, sc1, var1, sc2 and u are estimated ## and var2 is given by a forula. p.fit <- list(sc1 = NA, var1=NA, var2=~2 * u, sc2 = NA, u=NA) lower <- list(sc1=20, u=5) upper <- list(sc2=1.5, sc1=100, u=15) f <- RFfit(model, data=z, params=p.fit, lower = lower, upper = upper) print(f) ## The second example shows that rather complicated constructions are ## possible, i.e., formulae involving several variables, both known ('abc') ## and unknown ones ('sc', 'var'). Note that there are two different ## 'var's a unknown variable and an argument for RMwhittle ## Not run: model2 <- ~ RMexp(sc) + RMwhittle(var = g, nu=Nu) + RMnugget(var=nugg) + RMexp(var=var, Aniso=matrix(A, nc=2)) + RMdeclare(CCC, DD) p.fit <- list(g=~sc^1.5, nugg=~sc * var * abc, sc=NA, var=~DD, Nu=NA, abc=123, A = ~c(1, 2, DD * CCC, CCC), CCC = NA, DD=NA) lower <- list(sc=1, CCC=1, DD=1) upper <- list(sc=100, CCC=100, DD=100) f2 <- RFfit(model2, data=z, params=p.fit, lower = lower, upper = upper) print(f2) ## End(Not run)
RMdelay
is a -variate stationary covariance model.
which depends on a univariate stationary covariance model
.
The corresponding covariance function only depends on the difference
between two points in
-dimensional
space and is given by
where and
RMdelay(phi,s,var, scale, Aniso, proj)
RMdelay(phi,s,var, scale, Aniso, proj)
phi |
a univariate stationary covariance model, that means an
|
s |
a |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
Here, a multivariate random field is obtained from a single univariate random field by shifting it by a fixed value.
RMdelay
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package RandomFields. Journal of Statistical Software, 63 (8), 1-25, url = ‘http://www.jstatsoft.org/v63/i08/’
Wackernagel, H. (2003) Multivariate Geostatistics. Berlin: Springer, 3nd edition.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- seq(-10,10,0.2) model <- RMdelay(RMstable(alpha=1.9, scale=2), s=c(4,4)) plot(model, dim=2, xlim=c(-6, 6), ylim=c(-6,6)) simu <- RFsimulate(model, x, y) plot(simu, zlim="joint")
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- seq(-10,10,0.2) model <- RMdelay(RMstable(alpha=1.9, scale=2), s=c(4,4)) plot(model, dim=2, xlim=c(-6, 6), ylim=c(-6,6)) simu <- RFsimulate(model, x, y) plot(simu, zlim="joint")
RMderiv
is a multivariate covariance model which
models a field and its gradient.
For an isotropic covariance model , the covariance
given by
RMderiv
equals
for where
is the dimension of the field.
RMderiv(phi, which, var, scale, Aniso, proj)
RMderiv(phi, which, var, scale, Aniso, proj)
phi |
a univariate stationary covariance model (in 2 or 3 dimensions). |
which |
vector of integers. If not given all components are returned; otherwise the selected components are returned. |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMderiv
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Matheron
RMcurlfree
,
RMdivfree
,
RMvector
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMderiv(RMgauss(), scale=4) plot(model, dim=2) x.seq <- y.seq <- seq(-10, 10, 0.4) simulated <- RFsimulate(model=model, x=x.seq, y=y.seq) plot(simulated)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMderiv(RMgauss(), scale=4) plot(model, dim=2) x.seq <- y.seq <- seq(-10, 10, 0.4) simulated <- RFsimulate(model=model, x=x.seq, y=y.seq) plot(simulated)
The modified RMdewijsian
model
is an intrinsically stationary isotropic variogram model.
The corresponding centered semi-variogram only depends on the distance
between two points and is given by
where .
RMdewijsian(alpha, var, scale, Aniso, proj)
RMdewijsian(alpha, var, scale, Aniso, proj)
alpha |
a numerical value; in the interval (0,2]. |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
Originally, the logarithmic model was named
after de Wijs and reflects a principle of similarity (cf. Chiles,
J.-P. and Delfiner, P. (1999), p. 90).
But note that
is not a valid variogram
(
does not vanish) and can only be understood as a
characteristic of a generalized random field.
The modified RMdewijsian
model
is a valid variogram model
(cf. Wackernagel, H. (2003), p. 336).
RMdewijsian
returns an object of class RMmodel
.
Note that the (non-modified) de Wijsian model equals
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Wackernagel, H. (2003) Multivariate Geostatistics. Berlin: Springer, 3nd edition.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdewijsian(alpha=1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdewijsian(alpha=1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMdivfree
is a multivariate covariance model which depends on
a univariate stationary covariance model where the covariance function phi(h)
is twice differentiable.
The corresponding matrix-valued covariance function C of the model
only depends on the difference between two points and it is
given by the following components:
the potential
the vector field given by
the curl field
RMdivfree(phi, which, var, scale, Aniso, proj)
RMdivfree(phi, which, var, scale, Aniso, proj)
phi |
a univariate stationary covariance model (in 2 or 3 dimensions). |
which |
vector of integers. If not given all components are returned; otherwise the selected components are returned. |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model returns the potential field in the first component, the corresponding divfree field and the field of curl strength in the last component.
See also the models RMcurlfree
and RMvector
.
RMdivfree
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Scheuerer, M. and Schlather, M. (2012) Covariance Models for Divergence-Free and Curl-Free Random Vector Fields. Stochastic Models 28:3.
RMcurlfree
,
RMderiv
,
RMvector
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdivfree(RMgauss(), scale=4) plot(model, dim=2) x.seq <- y.seq <- seq(-10, 10, 0.2) simulated <- RFsimulate(model=model, x=x.seq, y=y.seq) plot(simulated) plot(simulated, select.variables=1) plot(simulated, select.variables=2:3) plot(simulated, select.variables=list(2:3)) plot(simulated, select.variables=list(1, 2:3, 4)) plot(simulated, select.variables=list(1, c(1, 2:3), 4))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMdivfree(RMgauss(), scale=4) plot(model, dim=2) x.seq <- y.seq <- seq(-10, 10, 0.2) simulated <- RFsimulate(model=model, x=x.seq, y=y.seq) plot(simulated) plot(simulated, select.variables=1) plot(simulated, select.variables=2:3) plot(simulated, select.variables=list(2:3)) plot(simulated, select.variables=list(1, 2:3, 4)) plot(simulated, select.variables=list(1, c(1, 2:3), 4))
RMeaxxa
and RMetaxxa
define the auxiliary functions
and
respectively.
RMeaxxa(E, A) RMetaxxa(E, A, alpha)
RMeaxxa(E, A) RMetaxxa(E, A, alpha)
E |
m-variate vector of positive values |
A |
|
alpha |
angle for the rotation matrix |
RMeaxxa
is defined in space and returns an m-variate model.
RMetaxxa
is a space-time model with two spatial dimensions.
The matrix R is a rotation matrix with angle where
is the time component.
RMeaxxa
and RMetaxxa
return an
object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (2010) On some covariance models based on normal scale mixtures. Bernoulli, 16, 780-797.
# see S10
# see S10
RMepscauchy
is a stationary isotropic covariance model
belonging to the generalized Cauchy family. In contrast to most
other models it is not a correlation function.
The corresponding covariance function only depends on the distance between
two points and is given by
where ,
and
.
See also
RMcauchy
.
RMepscauchy(alpha, beta, eps, var, scale, Aniso, proj)
RMepscauchy(alpha, beta, eps, var, scale, Aniso, proj)
alpha |
a numerical value; should be in the interval (0,2] to provide a valid covariance function for a random field of any dimension. |
beta |
a numerical value; should be positive to provide a valid covariance function for a random field of any dimension. |
eps |
a positive value |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This model has a smoothness parameter and a
parameter
which determines the asymptotic power law.
More precisely, this model admits simulating random fields where fractal dimension
D of the Gaussian sample and Hurst coefficient H
can be chosen independently (compare also
RMlgd
): Here, we have
and
I. e. the smaller , the longer the long-range
dependence.
The covariance function is very regular near the origin, because its Taylor expansion only contains even terms and reaches its sill slowly.
Each covariance function of the Cauchy family is a normal scale mixture.
Note that the Cauchy Family (see RMcauchy
) is included
in this family for the choice and
.
RMepscauchy
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. SIAM review 46, 269–282.
RMcauchy
,
RMcauchytbm
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMepscauchy(alpha=1.5, beta=1.5, scale=0.3, eps=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMepscauchy(alpha=1.5, beta=1.5, scale=0.3, eps=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMexp
is a stationary isotropic covariance model whose
corresponding covariance function only depends
on the distance between
two points and is given by
RMexp(var, scale, Aniso, proj)
RMexp(var, scale, Aniso, proj)
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This model is a special case of the Whittle covariance model (see RMwhittle
) if and of the symmetric stable family (see
RMstable
) if . Moreover,
it is the continuous-time analogue of the first order autoregressive time
series covariance structure.
The exponential covariance function is a normal scale mixture.
RMexp
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Covariance model
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
Tail correlation function
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
RMwhittle
,
RMstable
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMexponential
yields a covariance model
from a given variogram or covariance model.
The covariance is given as
if is a covariance model, and as
if is a variogram model.
RMexponential(phi, n, standardised, var, scale, Aniso, proj)
RMexponential(phi, n, standardised, var, scale, Aniso, proj)
phi |
a valid |
n |
integer, see formula above. Default is -1; if the multivariate dimension of the submodel is greater than 1 then only the default value is valid. |
standardised |
logical. If |
var , scale , Aniso , proj
|
optional arguments; same meaning for any |
If is a variogram, then
is a valid
covariance.
RMexponential
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
See, for instance,
Berg, C., Christensen, J. P. R., Ressel, P. (1984) Harmonic Analysis on Semigroups. Theory of Positive Definite and Related Functions. Springer, New York.
Sasvari, Z. (2013) Multivariate Characteristic and Correlation Functions. de Gruyter, Berlin.
Schlather, M. (2010) Some covariance models based on normal scale mixtures, Bernoulli 16, 780-797.
Schlather, M. (2012) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J. M., Schlather, M. Advances and Challenges in Space-time Modelling of Natural Events, Springer, New York.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexponential(RMfbm(alpha=1)) ## identical to RMexp() plot(RMexp(), model=model, type=c("p", "l"), pch=20)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexponential(RMfbm(alpha=1)) ## identical to RMexp() plot(RMexp(), model=model, type=c("p", "l"), pch=20)
RMfbm
is an intrinsically stationary isotropic variogram
model. The corresponding centered semi-variogram only depends on the
distance between two points and is given by
where .
By now, the model is implemented for dimensions up to 3.
For a generalized model see also RMgenfbm
.
RMfbm(alpha, var, scale, Aniso, proj)
RMfbm(alpha, var, scale, Aniso, proj)
alpha |
numeric in |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The variogram is unbounded and belongs to a non-stationary process with
stationary increments. For and
scale=2
we get a variogram corresponding to a standard Brownian Motion.
For the quantity
is called Hurst index and determines
the fractal dimension
of the corresponding Gaussian sample paths
where is the dimension of the random field (see Chiles and
Delfiner, 1999, p. 89).
RMfbm
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and P. Delfiner (1999) Geostatistics. Modeling Spatial Uncertainty. New York, Chichester: John Wiley & Sons.
Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. J. Comput. Graph. Statist. 11, 587–599.
RMgenfbm
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMfbm(alpha=1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMfbm(alpha=1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMfixcov
is a user-defined covariance according to
the given covariance matrix.
It extends to the space through a Voronoi tessellation.
RMfixcov(M, x, y=NULL, z=NULL, T=NULL, grid, var, proj, raw, norm)
RMfixcov(M, x, y=NULL, z=NULL, T=NULL, grid, var, proj, raw, norm)
M |
a numerical matrix defining the user-defined covariance for a random field; the matrix should be positive definite, symmetric and its dimension should be equal to the length of observation or simulation vector. |
x , y , z , T , grid
|
optional.
The usual arguments as in |
var , proj
|
optional arguments; same meaning for any
|
raw |
logical. If |
norm |
optional model that gives the norm between locations |
The covariances passed are implemented for the given locations. Within any Voronoi cell (around a given location) the correlation is assumed to be one.
In particular, it is used in RFfit
to define neighbour or network structure in the data.
RMfixcov
returns an object of class RMmodel
.
Starting with version 3.0.64, the former argument element
is replaced by the general
option set
in
RFoptions
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Ober, U., Ayroles, J.F., Stone, E.A., Richards, S., Zhu, D., Gibbs, R.A., Stricker, C., Gianola, D., Schlather, M., Mackay, T.F.C., Simianer, H. (2012): Using Whole Genome Sequence Data to Predict Quantitative Trait Phenotypes in Drosophila melanogaster. PLoS Genet 8(5): e1002685.
RMcovariate
,
RMmodel
,
RFsimulate
,
RFfit
,
RMuser
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Example 1 showing that the covariance structure is correctly implemented n <- 10 C <- matrix(runif(n^2), nc=n) (C <- C %*% t(C)) RFcovmatrix(RMfixcov(C), 1:n) ## Example 2 showing that the covariance structure is interpolated RFcovmatrix(RMfixcov(C, 1:n), c(2, 2.1, 2.5, 3)) ## Example 3 showing the use in a separable space-time model model <- RMfixcov(C, 1:n, proj="space") * RMexp(s=40, proj="time") (z <- RFsimulate(model, x = seq(0,12, 0.5), T=1:100)) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Example 1 showing that the covariance structure is correctly implemented n <- 10 C <- matrix(runif(n^2), nc=n) (C <- C %*% t(C)) RFcovmatrix(RMfixcov(C), 1:n) ## Example 2 showing that the covariance structure is interpolated RFcovmatrix(RMfixcov(C, 1:n), c(2, 2.1, 2.5, 3)) ## Example 3 showing the use in a separable space-time model model <- RMfixcov(C, 1:n, proj="space") * RMexp(s=40, proj="time") (z <- RFsimulate(model, x = seq(0,12, 0.5), T=1:100)) plot(z)
Expressions of the form X@RMfixed(beta)
can be used
within a formula of the type
that specifies the Linear Mixed Model.
Important remark: RMfixed
is NOT a function although
the parentheses notation is used to specify the vector of coefficients.
The matrix is the design matrix and
is a vector of coefficients.
Note that a fixed effect of the form is interpreted as
X@RMfixed(beta=NA)
by default (and is estimated
provided that the formula is used in
RFfit
).
Note that the 1
in an expression 1@RMfixed(beta)
is
interpreted as the identity matrix.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmodel
,
RFformula
,
RFsimulate
.
## For examples see the help page of 'RFformula'. ##
## For examples see the help page of 'RFformula'. ##
RMflatpower
is an intrinsically stationary isotropic variogram
model. The corresponding centered semi-variogram only depends on the
distance between two points and is given by
where .
For related models see RMgenfbm
.
RMflatpower(alpha, var, scale, Aniso, proj)
RMflatpower(alpha, var, scale, Aniso, proj)
alpha |
numeric in |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model is always smooth at the origin.
The parameter only gives the tail behaviour and
satisfies
.
The variogram is unbounded and belongs to a non-stationary process with stationary increments.
RMflatpower
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Oesting, M., Schlather, M., and Friederichs, P. (2014) Conditional Modelling of Extreme Wind Gusts by Bivariate Brown-Resnick Processes arxiv 1312.4584.
RMgenfbm
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMflatpower(alpha=0.5) x <- seq(0, 10, 0.1) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMflatpower(alpha=0.5) x <- seq(0, 10, 0.1) plot(model) plot(RFsimulate(model, x=x))
RMfractdiff
is a stationary isotropic covariance model.
The corresponding covariance function only depends on the distance
between two points and is given for integers
by
and otherwise linearly interpolated. Here, ,
denotes the gamma function.
It can only be used for one-dimensional random fields.
RMfractdiff(a, var, scale, Aniso, proj)
RMfractdiff(a, var, scale, Aniso, proj)
a |
|
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model is only valid for dimension .
It stems from time series modelling where the grid locations are
multiples of the scale parameter.
RMfractdiff
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMfractdiff(0.5, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMfractdiff(0.5, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMfractgauss
is a stationary isotropic covariance model.
The corresponding covariance function only depends on the distance between
two points and is given by
with . It can only be used for one-dimensional random fields.
RMfractgauss(alpha,var, scale, Aniso, proj)
RMfractgauss(alpha,var, scale, Aniso, proj)
alpha |
|
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model is only valid for dimension . It
is the covariance function for the fractional Gaussian noise with
self-affinity index (Hurst parameter)
with
.
RMfractgauss
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. SIAM review 46, 269–282.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMfractgauss(alpha=0.5, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMfractgauss(alpha=0.5, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMgauss
is a stationary isotropic covariance model.
The corresponding covariance function only depends on the distance
between two points and is given by
RMgauss(var, scale, Aniso, proj)
RMgauss(var, scale, Aniso, proj)
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This model is called Gaussian because of the functional similarity of the spectral density of a process with that covariance function to the Gaussian probability density function.
The Gaussian model has an infinitely differentiable covariance function. This smoothness is artificial. Furthermore, this often leads to singular matrices and therefore numerically instable procedures (cf. Stein, M. L. (1999), p. 29).
The Gaussian model is included in the symmetric stable class (see
RMstable
) for the choice .
RMgauss
returns an object of class
RMmodel
.
The use of RMgauss
is questionable from both a theoretical
(analytical paths) and a practical point of view (e.g. speed of
algorithms).
Instead, RMgneiting
should be used.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
Stein, M. L. (1999) Interpolation of Spatial Data. New York: Springer-Verlag
RMstable
and RMmatern
for generalizations;
RMmodel
,
RFsimulate
,
RFfit
.
Do not mix up with RPgauss
or RRgauss
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss(scale=0.4) x <- seq(0, 10, 0.02) plot(model) lines(RMgauss(), col="red") plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss(scale=0.4) x <- seq(0, 10, 0.02) plot(model) lines(RMgauss(), col="red") plot(RFsimulate(model, x=x))
RMgencauchy
is a stationary isotropic covariance model
belonging to the generalized Cauchy family.
The corresponding covariance function only depends on the distance between
two points and is given by
where and
.
See also
RMcauchy
.
RMgencauchy(alpha, beta, var, scale, Aniso, proj)
RMgencauchy(alpha, beta, var, scale, Aniso, proj)
alpha |
a numerical value; should be in the interval (0,2] to provide a valid covariance function for a random field of any dimension. |
beta |
a numerical value; should be positive to provide a valid covariance function for a random field of any dimension. |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This model has a smoothness parameter and a
parameter
which determines the asymptotic power law.
More precisely, this model admits simulating random fields where fractal dimension
D of the Gaussian sample and Hurst coefficient H
can be chosen independently (compare also with
RMlgd
): Here, we have
and
I. e. the smaller , the longer the long-range
dependence.
The covariance function is very regular near the origin, because its Taylor expansion only contains even terms and reaches its sill slowly.
Each covariance function of the Cauchy family is a normal scale mixture.
Note that the Cauchy Family (see RMcauchy
) is included
in this family for the choice and
.
RMgencauchy
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Covariance function
Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. SIAM review 46, 269–282.
Tail correlation function (for )
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
RMcauchy
,
RMcauchytbm
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgencauchy(alpha=1.5, beta=1.5, scale=0.3) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgencauchy(alpha=1.5, beta=1.5, scale=0.3) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMgenfbm
is an intrinsically stationary isotropic
variogram model.
The corresponding centered semi-variogram only depends on the distance
between two points and is given by
where and
.
See also RMfbm
.
RMgenfbm(alpha, beta, var, scale, Aniso, proj)
RMgenfbm(alpha, beta, var, scale, Aniso, proj)
alpha |
a numerical value; should be in the interval (0,2]. |
beta |
a numerical value; should be in the interval (0,2]. |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
Here, the variogram of RMfbm
is modified by
the transformation on variograms
for
. This original modification allows for
further generalization, cf.
RMbcw
.
RMgenfbm
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. (2002) Nonseparable, stationary covariance functions for space-time data, JASA 97, 590-600.
Schlather, M. (2010) On some covariance models based on normal scale mixtures. Bernoulli, 16, 780-797.
RMbcw
,
RMfbm
,
RMmodel
,
RMflatpower
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgenfbm(alpha=1, beta=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgenfbm(alpha=1, beta=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMgengneiting
is a stationary isotropic covariance model family whose elements
are specified by the two parameters and
with
being a non-negative integer and
with
denoting the dimension of the random field
(the models can be used for any dimension).
A corresponding covariance function only depends on the distance
between
two points. For the case
the Gneiting-Wendland model
equals the Askey model
RMaskey
,
For
the Gneiting model is given by
If
In the case
A special case of this model is RMgneiting
.
RMgengneiting(kappa, mu, var, scale, Aniso, proj)
RMgengneiting(kappa, mu, var, scale, Aniso, proj)
kappa |
|
; it chooses between the three different covariance models above.
mu |
|
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This isotropic family of covariance functions is valid for any dimension of the random field.
A special case of this family is RMgneiting
(with there) for the choice
.
RMgengneiting
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. (1999) Correlation functions for atmospherical data analysis. Q. J. Roy. Meteor. Soc Part A 125, 2449-2464.
Wendland, H. (2005) Scattered Data Approximation. Cambridge Monogr. Appl. Comput. Math.
RMaskey
,
RMbigneiting
,
RMgneiting
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgengneiting(kappa=1, mu=1.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) ## same models: model2 <- RMgengneiting(kappa=3, mu=1.5, scale= 1 / 0.301187465825) plot(RMgneiting(), model2=model2, type=c("p", "l"), pch=20)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgengneiting(kappa=1, mu=1.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x)) ## same models: model2 <- RMgengneiting(kappa=3, mu=1.5, scale= 1 / 0.301187465825) plot(RMgneiting(), model2=model2, type=c("p", "l"), pch=20)
RMgennsst
is a univariate stationary spaceisotropic
covariance model on
whose corresponding covariance is given by
RMgennsst(phi, psi, dim_u, var, scale, Aniso, proj)
RMgennsst(phi, psi, dim_u, var, scale, Aniso, proj)
phi |
is a normal mixture |
psi |
is a |
dim_u |
the dimension of the component |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This model is used for space-time modelling where the spatial component is isotropic.
RMgennsst
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (2010) On some covariance models based on normal scale mixtures. Bernoulli, 16, 780-797.
RMnsst
,
RMmodel
,
RFsimulate
,
RFfit
.
RMgneiting
is a stationary isotropic covariance model
which is only valid up to dimension 3, or 5 (see the argument orig
).
The corresponding covariance function only depends on the distance
between
two points and is given by
if and
otherwise. Here,
.
For a generalized model see also
RMgengneiting
.
RMgneiting(orig, var, scale, Aniso, proj)
RMgneiting(orig, var, scale, Aniso, proj)
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
orig |
logical.
If Default: |
This isotropic covariance function is valid only for dimensions less than or equal to 3. It is 6 times differentiable and has compact support.
This model is an alternative to RMgauss
as its graph is hardly distinguishable from the
graph of the Gaussian model, but possesses neither the mathematical nor the numerical disadvantages of the Gaussian model.
It is a special case of RMgengneiting
for the choice .
Note that, in the original work by Gneiting (1999), a numerical value slightly deviating from
the optimal one was used for :
.
RMgneiting
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
For the original version
Gneiting, T. (1999) Correlation functions for atmospherical data analysis. Q. J. Roy. Meteor. Soc Part A 125, 2449-2464.
For the version (orig=FALSE
)
this package RandomFields.
RMbigneiting
,
RMgengneiting
,
RMgauss
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again plot(RMgneiting(), model2=RMgneiting(orig=FALSE), model3=RMgauss(), xlim=c(-3,3), maxchar=100) plot(RMgneiting(), model2=RMgneiting(orig=FALSE), model3=RMgauss(), xlim=c(1.5,2.5), maxchar=100) model <- RMgneiting(orig=FALSE, scale=0.4) x <- seq(0, 10, 0.2) ## nicer with 0.1 instead of 0.2 z <- RFsimulate(model, x=x, y=x, z=x, T=c(1,1,4), maxGB=3) plot(z, MARGIN.slices=4, MARGIN.movie=3)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again plot(RMgneiting(), model2=RMgneiting(orig=FALSE), model3=RMgauss(), xlim=c(-3,3), maxchar=100) plot(RMgneiting(), model2=RMgneiting(orig=FALSE), model3=RMgauss(), xlim=c(1.5,2.5), maxchar=100) model <- RMgneiting(orig=FALSE, scale=0.4) x <- seq(0, 10, 0.2) ## nicer with 0.1 instead of 0.2 z <- RFsimulate(model, x=x, y=x, z=x, T=c(1,1,4), maxGB=3) plot(z, MARGIN.slices=4, MARGIN.movie=3)
RMgneitingdiff
is a stationary isotropic covariance model
which is only valid up to dimension 3.
The corresponding covariance function only depends on the distance
between
two points and is given by
where is Gneiting's model
RMgneiting
and is the Whittle model
RMwhittle
.
RMgneitingdiff(nu, taper.scale, scale, var, Aniso, proj)
RMgneitingdiff(nu, taper.scale, scale, var, Aniso, proj)
nu |
see |
taper.scale |
is the parameter |
scale |
is the parameter |
var , Aniso , proj
|
optional arguments; same meaning for any
|
The model allows to a certain degree the smooth modelling of the differentiability of a covariance function with compact support.
RMgneitingdiff
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. (1999) Correlation functions for atmospherical data analysis. Q. J. Roy. Meteor. Soc Part A 125, 2449-2464.
RMbigneiting
,
RMgneiting
,
RMgengneiting
,
RMgauss
,
RMmodel
,
RMwhittle
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgneitingdiff(nu=2, taper.scale=1, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgneitingdiff(nu=2, taper.scale=1, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMhyperbolic
is a stationary isotropic covariance model
called “generalized hyperbolic”.
The corresponding covariance function only depends on the distance
between two points and is given by
where denotes the modified Bessel function of
second kind.
RMhyperbolic(nu, lambda, delta, var, scale, Aniso, proj)
RMhyperbolic(nu, lambda, delta, var, scale, Aniso, proj)
nu , lambda , delta
|
numerical values; should either satisfy |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This class is over-parametrized, i.e. it can be reparametrized by
replacing the three parameters ,
and scale by two other parameters. This means
that the representation is not unique.
Each generalized hyperbolic covariance function is a normal scale mixture.
The model contains some other classes as special cases;
for we get the Cauchy covariance function
(see
RMcauchy
) with and scale=
;
the choice
yields a covariance model of type
RMwhittle
with smoothness parameter
and scale parameter
.
RMhyperbolic
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Shkarofsky, I.P. (1968) Generalized turbulence space-correlation and wave-number spectrum-function pairs. Can. J. Phys. 46, 2133-2153.
Barndorff-Nielsen, O. (1978) Hyperbolic distributions and distributions on hyperbolae. Scand. J. Statist. 5, 151-157.
Gneiting, T. (1997). Normal scale mixtures and dual probability densities. J. Stat. Comput. Simul. 59, 375-384.
RMcauchy
,
RMwhittle
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMhyperbolic(nu=1, lambda=2, delta=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMhyperbolic(nu=1, lambda=2, delta=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
The space-time covariance function is
RMiaco(nu, lambda, delta, var, scale, Aniso, proj)
RMiaco(nu, lambda, delta, var, scale, Aniso, proj)
nu , lambda
|
number in |
delta |
positive number |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMiaco
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
de Cesare, L., Myers, D.E., and Posa, D. (2002) FORPRAN programs for space-time modeling. Computers \& Geosciences 28, 205-212.
de Iaco, S.. Myers, D.E., and Posa, D. (2002) Nonseparable space-time covariance models: some parameteric families. Math. Geol. 34, 23-42.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMiaco(nu=1, lambda=1.5, delta=0.5) plot(model, dim=2) x <- seq(0, 10, 0.1) plot(RFsimulate(model, x=x, y=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMiaco(nu=1, lambda=1.5, delta=0.5) plot(model, dim=2) x <- seq(0, 10, 0.1) plot(RFsimulate(model, x=x, y=x))
RMid
is the identical function
where
is a vector of coordinates and
is a model value.
RMid()
RMid()
RMid
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmodel
.
RMid
,
RMtrafo
,
RMprod
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## C(x,y) = < x, y > RFcov(RMprod(RMid()), as.matrix(1:10), as.matrix(1:10), grid=FALSE)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## C(x,y) = < x, y > RFcov(RMprod(RMid()), as.matrix(1:10), as.matrix(1:10), grid=FALSE)
RMidmodel
is the identical operator on models, i.e.
for objects of class RMmodel
.
RMidmodel(phi, vdim, var, scale, Aniso, proj)
RMidmodel(phi, vdim, var, scale, Aniso, proj)
phi |
covariance function of class |
vdim |
for internal purposes |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMidmodel
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmodel
.
RMid
,
RMtrafo
,
RMprod
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() x <- 0:10 z <- RFsimulate(model, x) model2 <- RMidmodel(model) z2 <- RFsimulate(model, x) sum(abs(as.vector(z)- as.vector(z2))) == 0 # TRUE
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() x <- 0:10 z <- RFsimulate(model, x) model2 <- RMidmodel(model) z2 <- RFsimulate(model, x) sum(abs(as.vector(z)- as.vector(z2))) == 0 # TRUE
Internal models or model names that may appear in feedbacks from 'RandomFields'. Those endings by ‘Intern’ should appear only in very rare cases.
The following and many more internal models exist:
RF__Name__ : internal representation of certain functions RF__name__
RO#
: model for transforming coordinates within the cartesian
system
RO>
: model for transforming earth coordinates to cartesian
coordinates
ROmissing
: for error messages only
RMmixed
: internal representation of a mixed model
RMselect
: will be obsolete in future
RMsetparam
, RMptsGivenShape
, RMstandardShape
, RMstatShape
:
for max-stable processes and Poisson processes:
models that combine shape functions with corresponding point processes
RP__name__Intern
: internal representations of some processes
RPS
, RPplusp
, etc. : specific processes for
RMS and RMplus etc. (For those covariance models that
have specific simulation processes programmed.)
RMS
: internal representation of
the modifying arguments var
, scale
, Aniso
,
proj
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## in the following 'RPplus' appears as internal model x <- seq(0, 10, 1) z <- RFsimulate(RPspecific(RMexp() + RMnugget()), x) RFgetModelInfo(which="internal", level=0)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## in the following 'RPplus' appears as internal model x <- seq(0, 10, 1) z <- RFsimulate(RPspecific(RMexp() + RMnugget()), x) RFgetModelInfo(which="internal", level=0)
RMintexp
is a univariate stationary covariance model
depending on a univariate variogram model .
The corresponding covariance function only depends on the difference
between two points and is given by
RMintexp(phi, var, scale, Aniso, proj)
RMintexp(phi, var, scale, Aniso, proj)
phi |
a variogram |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMintexp
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (2012) Construction of covariance functions and unconditional simulation of random fields. Lecture Notes in Statistics, Proceedings, 207, 25–54.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMintexp(RMfbm(alpha=1.5, scale=0.2)) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMintexp(RMfbm(alpha=1.5, scale=0.2)) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMintrinsic
is a univariate stationary isotropic covariance
model which depends on a univariate stationary isotropic covariance model.
The corresponding covariance function C of the model
only depends on the distance between
two points and is given by
RMintrinsic(phi, diameter, rawR, var, scale, Aniso, proj)
RMintrinsic(phi, diameter, rawR, var, scale, Aniso, proj)
phi |
an |
diameter |
a numerical value; positive; should be the diameter of the domain on which simulation is done |
rawR |
a numerical value; greater or equal to 1 |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The parameters ,
and
are chosen internally such that
becomes a smooth function.
See formulas (3.8)-(3.10) in Gneiting et alii (2006).
This model corresponds to the method Intrinsic Embedding.
See also
RPintrinsic
.
NOTE: The algorithm that checks the given parameters knows
only about some few necessary conditions.
Hence it is not ensured that
the Stein-model is a valid covariance function for any
choice of and the parameters.
For certain models , i.e.
stable
,
whittle
, gencauchy
, and the variogram
model fractalB
some sufficient conditions are known.
RMintrinsic
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T., Sevecikova, H, Percival, D.B., Schlather M., Jiang Y. (2006) Fast and Exact Simulation of Large Gaussian Lattice Systems in $R^2$: Exploring the Limits. J. Comput. Graph. Stat. 15, 483–501.
Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces. J. Comput. Graph. Statist. 11, 587–599
RPintrinsic
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x.max <- 10 model <- RMintrinsic(RMfbm(alpha=1), diameter=x.max) x <- seq(0, x.max, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x.max <- 10 model <- RMintrinsic(RMfbm(alpha=1), diameter=x.max) x <- seq(0, x.max, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMkolmogorov
corresponds to a vector-valued random field with
covariance function
RMkolmogorov(var, scale, Aniso, proj)
RMkolmogorov(var, scale, Aniso, proj)
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMkolmogorov
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
The above formula is from eq. (6.32) of section 6.2 in
Pope, S.B. (2000) Turbulent Flows. Cambridge: Cambridge University Pess.
RMmodel
, RMcurlfree
,
RMdivfree
,
RMvector
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- seq(-2, 2, len=20) model <- RMkolmogorov() plot(model, dim=3, MARGIN=1:2, fixed.MARGIN=1) simu <- RFsimulate(model, x, y, z=0) plot(simu, select.variables=list(c(1,2)), col=c("red"))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- seq(-2, 2, len=20) model <- RMkolmogorov() plot(model, dim=3, MARGIN=1:2, fixed.MARGIN=1) simu <- RFsimulate(model, x, y, z=0) plot(simu, select.variables=list(c(1,2)), col=c("red"))
RMlgd
is a stationary isotropic covariance model, which is valid only for dimensions
.
The corresponding covariance function only depends on the distance
between
two points and is given by
where and
,
with
denoting the dimension of the random field.
RMlgd(alpha, beta, var, scale, Aniso, proj)
RMlgd(alpha, beta, var, scale, Aniso, proj)
alpha |
argument whose range depends on the dimension of the random field: |
beta |
positive number |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model is only valid for dimension .
This model admits simulating random fields where fractal dimension
D of the Gaussian sample and Hurst coefficient H
can be chosen independently (compare also RMgencauchy
):
Here, the random field has fractal dimension
and Hurst coefficient
for .
RMlgd
returns an object of class
RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect. SIAM review 46, 269–282.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMlgd(alpha=0.7, beta=4, scale=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMlgd(alpha=0.7, beta=4, scale=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMlsfbm
is a positive definite function on the
unit ball in centred at the origin,
with .
RMlsfbm(alpha, const, var, scale, Aniso, proj)
RMlsfbm(alpha, const, var, scale, Aniso, proj)
alpha |
numeric in |
const |
the
and should not be changed by the user in order to ensure positive definiteness. |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMlsfbm
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Martini, J., Schlather, M., Simianer, H. (In preparation.)
RMbcw
generalizes RMlsfbm
in case that
is given,
RMfbm
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMlsfbm(alpha=1, scale=10) x <- seq(0, 10, 0.02) plot(model, xlim=c(0,10)) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMlsfbm(alpha=1, scale=10) x <- seq(0, 10, 0.02) plot(model, xlim=c(0,10)) plot(RFsimulate(model, x=x))
RMma
is a univariate stationary covariance model
depending on a univariate stationary covariance model.
The corresponding covariance function only depends on the difference
between two points and is given by
RMma(phi, alpha, theta, var, scale, Aniso, proj)
RMma(phi, alpha, theta, var, scale, Aniso, proj)
phi |
a stationary covariance |
alpha |
a numerical value; positive |
theta |
a numerical value; in the interval |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMma
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Ma, C. (2003) Spatio-temporal covariance functions generated by mixtures. Math. Geol., 34, 965-975.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMma(RMgauss(), alpha=4, theta=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMma(RMgauss(), alpha=4, theta=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMmastein
is a univariate stationary covariance model
depending on a variogram or covariance model on the real axis.
The corresponding covariance function only depends on the difference
between two points and is given by
if is a variogram model.
It is given by
if is a covariance model.
Here is the Gamma function;
is the Whittle-Matern
model (RMwhittle).
RMmastein(phi, nu, delta, var, scale, Aniso, proj)
RMmastein(phi, nu, delta, var, scale, Aniso, proj)
phi |
an |
nu |
numerical value; positive; smoothness parameter of the
Whittle-Matern model (for |
delta |
a numerical value; |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
See Stein (2005), formula (12).
Instead of the velocity parameter in the original model
description, a preceding anisotropy matrix is chosen appropriately:
A is a spatial transformation matrix.
(I.e. (x,t) is multiplied from the left on the above matrix and
the first elements of the obtained vector are interpreted as
new spatial components and only these components are used to form
the argument in the Whittle-Matern function.)
The last component in the new coordinates is the time which is
passed to . (Velocity is assumed to be zero in
the new coordinates.)
Note, that for numerical reasons, may not exceed
the value 80.0. If exceeded the algorithm fails.
RMmastein
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Ma, C. (2003) Spatio-temporal covariance functions generated by mixtures. Math. Geol., 34, 965-975.
Stein, M.L. (2005) Space-time covariance functions. JASA, 100, 310-321.
RMwhittle
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make plotthem all random again model <- RMmastein(RMgauss(), nu=1, delta=10) plot(RMexp(), model.mastein=model, dim=2) x <- seq(0, 10, 0.1) plot(RFsimulate(model, x=x, y=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make plotthem all random again model <- RMmastein(RMgauss(), nu=1, delta=10) plot(RMexp(), model.mastein=model, dim=2) x <- seq(0, 10, 0.1) plot(RFsimulate(model, x=x, y=x))
RMmatrix
is a multivariate covariance model
depending on one multivariate covariance model, or
one or several univariate covariance models .
The corresponding covariance function is given by
if a multivariate case is given. Otherwise it returns a matrix
whose diagonal elements are filled with the univarate model(s)
C0
, C1
, etc, and the
offdiagonals are all zero.
RMmatrix(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, M, vdim, var, scale, Aniso, proj)
RMmatrix(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, M, vdim, var, scale, Aniso, proj)
C0 |
a k-variate covariance |
C1 , C2 , C3 , C4 , C5 , C6 , C7 , C8 , C9
|
optional univariate models |
M |
a k times k matrix, which is multiplied from left and right to
the given model;
|
vdim |
positive integer. This argument should be given if and only
if a multivariate model is created from a single univariate model and
|
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMmatrix
returns an object of class
RMmodel
.
RMmatrix
also allows variogram models are arguments.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Not run: ## first example: bivariate Linear Model of Coregionalisation x <- y <- seq(0, 10, 0.2) model1 <- RMmatrix(M = c(0.9, 0.43), RMwhittle(nu = 0.3)) + RMmatrix(M = c(0.6, 0.8), RMwhittle(nu = 2)) plot(model1) simu1 <- RFsimulate(RPdirect(model1), x, y) plot(simu1) ## second, equivalent way of defining the above model model2 <- RMmatrix(M = matrix(ncol=2, c(0.9, 0.43, 0.6, 0.8)), c(RMwhittle(nu = 0.3), RMwhittle(nu = 2))) simu2 <- RFsimulate(RPdirect(model2), x, y) stopifnot(all.equal(as.array(simu1), as.array(simu2))) ## third, equivalent way of defining the above model model3 <- RMmatrix(M = matrix(ncol=2, c(0.9, 0.43, 0.6, 0.8)), RMwhittle(nu = 0.3), RMwhittle(nu = 2)) simu3 <- RFsimulate(RPdirect(model3), x, y) stopifnot(all(as.array(simu3) == as.array(simu2))) ## End(Not run) ## second example: bivariate, independent fractional Brownian motion ## on the real axis x <- seq(0, 10, 0.1) modelB <- RMmatrix(c(RMfbm(alpha=0.5), RMfbm(alpha=1.5))) ## see the Note above print(modelB) simuB <- RFsimulate(modelB, x) plot(simuB) ## third example: bivariate non-stationary field with exponential correlation ## function. The variance of the two components is given by the ## variogram of fractional Brownian motions. ## Note that the two components have correlation 1. x <- seq(0, 10, 0.1) modelC <- RMmatrix(RMexp(), M=c(RMfbm(alpha=0.5), RMfbm(alpha=1.5))) print(modelC) simuC <- RFsimulate(modelC, x, x, print=1) #print(as.vector(simuC)) plot(simuC)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Not run: ## first example: bivariate Linear Model of Coregionalisation x <- y <- seq(0, 10, 0.2) model1 <- RMmatrix(M = c(0.9, 0.43), RMwhittle(nu = 0.3)) + RMmatrix(M = c(0.6, 0.8), RMwhittle(nu = 2)) plot(model1) simu1 <- RFsimulate(RPdirect(model1), x, y) plot(simu1) ## second, equivalent way of defining the above model model2 <- RMmatrix(M = matrix(ncol=2, c(0.9, 0.43, 0.6, 0.8)), c(RMwhittle(nu = 0.3), RMwhittle(nu = 2))) simu2 <- RFsimulate(RPdirect(model2), x, y) stopifnot(all.equal(as.array(simu1), as.array(simu2))) ## third, equivalent way of defining the above model model3 <- RMmatrix(M = matrix(ncol=2, c(0.9, 0.43, 0.6, 0.8)), RMwhittle(nu = 0.3), RMwhittle(nu = 2)) simu3 <- RFsimulate(RPdirect(model3), x, y) stopifnot(all(as.array(simu3) == as.array(simu2))) ## End(Not run) ## second example: bivariate, independent fractional Brownian motion ## on the real axis x <- seq(0, 10, 0.1) modelB <- RMmatrix(c(RMfbm(alpha=0.5), RMfbm(alpha=1.5))) ## see the Note above print(modelB) simuB <- RFsimulate(modelB, x) plot(simuB) ## third example: bivariate non-stationary field with exponential correlation ## function. The variance of the two components is given by the ## variogram of fractional Brownian motions. ## Note that the two components have correlation 1. x <- seq(0, 10, 0.1) modelC <- RMmatrix(RMexp(), M=c(RMfbm(alpha=0.5), RMfbm(alpha=1.5))) print(modelC) simuC <- RFsimulate(modelC, x, x, print=1) #print(as.vector(simuC)) plot(simuC)
Summary of implemented covariance and variogram models
To generate a covariance or variogram model for use within RandomFields, calls of the form
can be used, where _name_ has to be replaced by a valid model name.
...
can take model specific arguments.
var
is the optional variance argument ,
scale
the optional scale argument ,
Aniso
an optional anisotropy matrix or given by
RMangle
, and
proj
is the optional projection.
With denoting the original model, the transformed model is
.
See
RMS
for more details.
RM_name_
must be a function of class
RMmodelgenerator
.
The return value of all functions RM_name_
is of class
RMmodel
.
The following models are available
(cf. RFgetModelNames
):
Basic stationary and isotropic models
RMcauchy |
Cauchy family |
RMexp |
exponential model |
RMgencauchy |
generalized Cauchy family |
RMgauss |
Gaussian model |
RMgneiting |
differentiable model with compact support |
RMmatern |
Whittle-Matern model |
RMnugget |
nugget effect model |
RMspheric |
spherical model |
RMstable |
symmetric stable family or powered exponential model |
RMwhittle |
Whittle-Matern model, alternative parametrization |
Variogram models (stationary increments/intrinsically stationary)
RMfbm |
fractal Brownian motion |
Basic Operations
RMmult , * |
product of covariance models |
RMplus , + |
sum of covariance models or variograms |
Others
RMtrend |
trend |
RMangle |
defines a 2x2 anisotropy matrix by rotation and stretch arguments. |
Alexander Malinowski; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., Space-Time Processes and Challenges Related to Environmental Problems. New York: Springer.
Yaglom, A.M. (1987) Correlation Theory of Stationary and Related Random Functions I, Basic Results. New York: Springer.
Wackernagel, H. (2003) Multivariate Geostatistics. Berlin: Springer, 3nd edition.
RM for an overview over more advanced classes of models
RC, RF, RP, RR, R.,
RFcov
,
RFformula
,
RMmodelsAdvanced
,
RMmodelsAuxiliary
,
trend modelling
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## an example of a simple model model <- RMexp(var=1.6, scale=0.5) + RMnugget(var=0) #exponential + nugget plot(model)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## an example of a simple model model <- RMexp(var=1.6, scale=0.5) + RMnugget(var=0) #exponential + nugget plot(model)
RMmodel
Class for RandomFields' representation of explicit covariance models
RFplotModel(x, y, dim=1, n.points=if (dim==1 || is.contour) 200 else 100, fct.type=NULL, MARGIN, fixed.MARGIN, maxchar=15, ..., plotmethod=if (dim==1) "matplot" else "contour") ## S4 method for signature 'RMmodel,missing' plot(x, y, ...) ## S4 method for signature 'RMmodel' points(x, ..., type="p") ## S4 method for signature 'RMmodel' lines(x, ..., type="l") ## S4 method for signature 'RMmodel' image(x, ..., dim=2) ## S4 method for signature 'RMmodel' persp(x, ..., dim=2, zlab="")
RFplotModel(x, y, dim=1, n.points=if (dim==1 || is.contour) 200 else 100, fct.type=NULL, MARGIN, fixed.MARGIN, maxchar=15, ..., plotmethod=if (dim==1) "matplot" else "contour") ## S4 method for signature 'RMmodel,missing' plot(x, y, ...) ## S4 method for signature 'RMmodel' points(x, ..., type="p") ## S4 method for signature 'RMmodel' lines(x, ..., type="l") ## S4 method for signature 'RMmodel' image(x, ..., dim=2) ## S4 method for signature 'RMmodel' persp(x, ..., dim=2, zlab="")
x |
object of class |
y |
ignored in most methods |
MARGIN |
vector of two; two integer values giving the coordinate dimensions w.r.t. whether the field or the covariance model is to be plotted; in all other directions, the first index is taken. |
fixed.MARGIN |
only for |
maxchar |
integer. Maximum number of characters to print the model in the legend. |
... |
arguments to be passed to methods; mainly graphical
arguments, or further models in case of class |
dim |
must equal 1 or 2; only for |
n.points |
integer; only for |
fct.type |
character; only for |
plotmethod |
string or function. Internal. |
type |
character. See |
zlab |
character. See |
If RFoptions()$split_screen=TRUE
and
RFoptions()$close_screen=TRUE
then
the plot
functions return
the screen
numbers. Else NULL
.
Objects are created by calling a function of class
RMmodelgenerator
.
call
:language object; the function call by which the object was generated
name
:character string; nickname of the model, name of the function by which the object was generated
submodels
:list; contains submodels (if existent)
par.model
:list; contains model specific arguments
par.general
:list of 4; contains the four standard
arguments var
, scale
, Aniso
and proj
that
can be given for any model; if not specified by the user, the string
"RFdefault"
is inserted
signature(x = CLASS_CLIST)
: allows to sum up
covariance models; internally calls RMplus
.
signature(x = CLASS_CLIST)
: allows to substract
covariance models; internally calls R.minus
.
signature(x = CLASS_CLIST)
: allows to multiply
covariance models; internally calls R.mult
.
signature(x = CLASS_CLIST)
: allows to divide
covariance models; internally calls R.div
.
signature(x = CLASS_CLIST)
: concatenates
covariance functions or variogram models.
signature(x = CLASS_CLIST)
: gives a plot of the
covariance function or of the variogram model; for more details see
plot-method
.
signature(x = CLASS_CLIST)
: adds a covariance plot to
an existing plot; for more details see
plot-method
.
signature(x = CLASS_CLIST)
: adds a covariance plot to
an existing plot; for more details see
plot-method
.
signature(x = CLASS_CLIST)
: as the usual
str
-method for S4 objects but only those
entries of the
'par.general'-slot are shown that contain values different from
'RFdefault'
.
signature(x = CLASS_CLIST)
: returns the structure
of x
.
signature(x = CLASS_CLIST)
: identical with
show
-method, additional argument is max.level
.
signature(x = CLASS_CLIST)
: enables accessing
the slots via the "["
-operator, e.g. x["par.general"]
.
signature(x = CLASS_CLIST)
: enables replacing
the slots via the "["
-operator.
signature(x = CLASS_CLIST, y = "missing")
Generates covariance function or variogram function plots in one or two dimensions.
All the above arguments apply for all the S3 and S4
functions given here as they call RFplotModel
immediately.
Alexander Malinowski, Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
# see RMmodel for introductory examples # Compare: model <- RMexp(scale=2) + RMnugget(var=3) str(model) ## S4 object as default in version 3 of RandomFields model <- summary(model) str(model) ## list style as in version 2 of RandomFields ## see also 'spConform' in 'RFoptions' to make this style ## the default
# see RMmodel for introductory examples # Compare: model <- RMexp(scale=2) + RMnugget(var=3) str(model) ## S4 object as default in version 3 of RandomFields model <- summary(model) str(model) ## list style as in version 2 of RandomFields ## see also 'spConform' in 'RFoptions' to make this style ## the default
Extension of class RMmodel
which additionally contains
the likelihood of the data w.r.t. the covariance model represented by
the CLASS_CLIST part, the estimated trend of the data if it is a
constant trend, and the residuals of the data w.r.t. the model. Objects
of this class only occur as slots in the output of "RFfit".
Objects are only meant to be created by the function
RFfit
.
model,formel
:See RMmodel
.
variab
:vector of estimated variables. Variables are used in the internal representation and can be a subset of the parameters.
param
:vector of estimated parameters
covariate
:to do
globalvariance
:to do
hessian
:to do
likelihood
:numeric; the likelihood of the data w.r.t. the covariance model
AIC
:the AIC value for the ml estimation
AICc
:the corrected AIC value for the ml estimation
BIC
:the BIC value for the ml estimation
residuals
:array or of class RFsp
;
residuals of the data w.r.t. the trend model
Class CLASS_CLIST
, directly.
signature(x = CLASS_FIT)
: enables accessing
the slots via the "["
-operator, e.g. x["likelihood"]
signature(x = CLASS_FIT)
: enables replacing
the slots via the "["
-operator
signature(x = "RFfit")
: returns the structure
of x
signature(x = "RFfit")
: identical with
show
-method
performs a likelihood ratio test base on a chisq approximation
gives a summary
Alexander Malinowski; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
# see RFfit
# see RFfit
RMmodelgenerator
Class for all functions of this package with prefix RM
,
i.e. all functions that generate objects of class
RMmodel
; direct extension of
class function
.
Objects should not be created by the user!
.Data
:function; the genuine function that generates an
object of class
RMmodel
type
:character string; specifies the category of RMmodel-function, see Details
domain
:character string; specifies whether the corresponding function(s) depend on 1 or 2 variables, see Details
isotropy
:character string; specifies the type of isotropy of the corresponding covariance model, see Details
operator
:logical; specifies whether the underlying covariance model is an operator, see Details
monotone
:character string; specifies the kind of monotonicity of the model
finiterange
:logical; specifies whether the underlying covariance model has finite range, see Details
simpleArguments
:logical. If TRUE
than all the
parameters are real valued (or integer valued).
maxdim
:numeric; the maximal dimension, in which the corresponding model is a valid covariance model, see Details
vdim
:numeric; dimension of the value of the random field at a single fixed location, equals 1 in most cases, see Details
Class function
, directly.
signature(x = CLASS_CLIST)
: returns the structure
of x
signature(x = CLASS_CLIST)
: identical with
show
-method
signature(x = CLASS_RM)
: enables accessing
the slots via the "["-operator, e.g. x["maxdim"]
signature(x = CLASS_RM)
: enables replacing
the slots via the "["-operator
type
:can be one of the following strings:
'tail correlation function'
:indicates that the function returns a tail correlation function (a subclass of the set of positive definite functions)
'positive definite'
:indicates that the function returns a covariance function (positive definite function)
'negative definite'
:indicates that the function returns a variogram model (negative definite function)
'process'
:functions of that type determine the class of processes to be simulated
'method for Gauss processes'
:methods to simulate Gaussian random fields
'method for Brown-Resnick processes'
:methods to simulate Brown-Resnick fields
'point-shape function'
:functions of that type determine the distribution of points in space
'distribution family'
:e.g. (multivariate) uniform distribution, normal distribution, etc., defined in RandomFields. See RR for a complete list.
'shape function'
:functions used in, e.g., M3 processes (RPsmith)
'trend'
:RMtrend or a mixed model
'interface'
:indicates internal models which are usually
not visible for the users. These functions are the internal
representations of RFsimulate
,
RFcov
, etc. See RF for a complete list.
'undefined'
:some models can take different types, depending on the parameter values and/or the submodels
'other type'
:very very special internal functions, not belonging to any of the above types.
domain
:can be one of the following strings:
'single variable'
:Function depending on a single variable
'kernel'
:model refers to a kernel, e.g. a non-stationary covariance function
'framework dependent'
:domain depends on the calling model
'mismatch'
:this option is used only internally and should never appear
isotropy
:can be one of the following strings:
'isotropic'
:indicates that the model is isotropic
'space-isotropic'
:indicates that the spatial part of a spatio-temporal model is isotropic
'zero-space-isotropic'
:this property refers to space-time models; the model is called zerospaceisotropic if it is isotropic as soon as the time-component is zero
'vector-isotropic'
:multivariate vector model (flow fields) have a different notion of isotropy
'symmetric'
:the most basic property of any covariance function or variogram model
'cartesian system'
, 'earth system'
,
'spherical system'
, 'cylinder system'
:different coordinate systems
'non-dimension-reducing'
:the property does not hold
'parameter dependent'
:indicates that the type of isotropy of the model depends on the parameters passed to the model; in particular parameters may be submodels if an operator model is considered
'<mismatch>'
:this option is used only internally and should never appear
operator
:if TRUE
, the model requires at least
one submodel
monotone
:'mismatch in monotonicity'
:used if a statement on
the monotonocity does not make sense, e.g. for
RRmodels
'submodel dependent monotonicity'
:only for operators,
e.g. RMS
'previous model dependent monotonicity'
:internal; should not be used
'parameter dependent monotonicity'
:some models change their properties according to the parameters
'not monotone'
:none of the above categories; either the function is not monotone or properties are unknown
'monotone'
:isotone or antitone
'Gneiting-Schaback class'
:function belonging to Euclid's hat in Gneiting's 1999 paper
'normal mixture'
:scale mixture of the Gaussian model
'completely monotone'
:completely monotone function
'Bernstein'
:Bernstein function
Note that
'not monotone'
includes 'monotone'
and 'Bernstein'
'monotone'
includes 'Gneiting-Schaback class'
'Gneiting-Schaback class'
includes 'normal mixture'
'normal mixture'
includes 'completely monotone'
finiterange
:if TRUE
, the covariance of the
model has finite range
maxdim
:if a positive integer, maxdim
gives the
maximum dimension in which the model is a valid covariance model,
can be Inf
;
maxdim=-1
means that the actual maxdim depends on the
parameters; maxdim=-2
means that the actual maxdim depends on
the submodel(s)
vdim
:if a positive integer, vdim
gives the
dimension of the random field, i.e. univariate, bi-variate, ...;
vdim=-1
means that the actual vdim depends on the
parameters; vdim=-2
means that the actual vdim depends on
the submodel(s)
Alexander Malinowski, Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. (1999) Radial positive definite functions generated by Euclid's hat, J. Multivariate Anal., 69, 88-119.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames()
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames()
RMmodels
Various classes of models RMxxx
are implemented in
RandomFields, that have their own man pages. Here, an overview over
these man pages are given.
Beginners should start with RMmodels, then go for RMmodelsAdvanced if more information is needed.
RMmodels | general introduction and a collection of simple models |
RMmodelsAdvanced | includes more advanced stationary and isotropic models, variogram models, non-stationary models and trend models |
Bayesian | hierarchical models |
RMmodelsMultivariate | multivariate covariance models and multivariate trend models |
RMmodelsNonstationary | non-stationary covariance models |
RMmodelsSpaceTime | space-time covariance models |
Spherical models | models based on the polar coordinate system, usually used in earth models |
Tail correlation functions | models related to max-stable random fields |
trend modelling | how to pass trend specifications |
Mathematical functions | simple mathematical functions that are typically used to build non-stationary covariance models and arbitrary trends |
RMmodelsAuxiliary | rather specialized models, most of them not having positive definiteness property, but used internally in certain simulation algorithms, for instance. |
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames(type="positive definite", domain="single variable", isotropy="isotropic", operator=!FALSE) ## RMmodel.Rd
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames(type="positive definite", domain="single variable", isotropy="isotropic", operator=!FALSE) ## RMmodel.Rd
Here, further models and advanced comments for RMmodel
are given. See also RFgetModelNames
.
Further stationary and isotropic models
RMaskey |
Askey model (generalized test or triangle model) |
RMbcw |
bridging model between
RMcauchy and RMgenfbm |
RMbessel |
Bessel family |
RMcircular |
circular model |
RMconstant |
spatially constant model |
RMcubic |
cubic model (see Chiles and Delfiner) |
RMdagum |
Dagum model |
RMdampedcos |
exponentially damped cosine |
RMqexp |
variant of the exponential model |
RMfractdiff |
fractionally differenced process |
RMfractgauss |
fractional Gaussian noise |
RMgengneiting |
generalized Gneiting model |
RMgneitingdiff |
Gneiting model for tapering |
RMhyperbolic |
generalized hyperbolic model |
RMlgd |
Gneiting's local-global distinguisher |
RMlsfbm |
locally stationary fractal Brownian motion |
RMpenta |
penta model (see Chiles and Delfiner) |
RMpower |
Golubov's model |
RMwave |
cardinal sine |
Variogram models (stationary increments/intrinsically stationary)
RMbcw |
bridging model between
RMcauchy and RMgenfbm |
RMdewijsian |
generalized version of the DeWijsian model |
RMgenfbm |
generalized fractal Brownian motion |
RMflatpower |
similar to fractal Brownian motion but always smooth at the origin |
General composed models (operators)
Here, composed models are given that can be of any kind (stationary/non-stationary), depending on the submodel.
RMbernoulli |
Correlation function of a binary field based on a Gaussian field |
RMexponential |
exponential of a covariance model |
RMintexp |
integrated exponential of a covariance model (INCLUDES ma2 ) |
RMpower |
powered variograms |
RMqam |
Porcu's quasi-arithmetic-mean model |
RMS |
details on the optional transformation
arguments (var , scale , Aniso , proj )
|
Stationary and isotropic composed models (operators)
RMcutoff |
Gneiting's modification towards finite range |
RMintrinsic |
Stein's modification towards finite range |
RMnatsc |
practical range |
RMstein |
Stein's modification towards finite range |
RMtbm
|
Turning bands operator |
Stationary space-time models
See RMmodelsSpaceTime.
Non-stationary models
See RMmodelsNonstationary.
Negative definite models that are not variograms
RMsum |
a non-stationary variogram model |
Models related to max-stable random fields (tail correlation
functions)
See RMmodelsTailCorrelation.
Other covariance models
RMcov |
covariance structure given by a variogram |
RMfixcov |
User defined covariance structure |
RMuser |
User defined model |
Trend models
Aniso |
for space transformation (not really trend, but similar) |
RMcovariate |
spatial covariates |
RMprod |
to model variability of the variance |
RMpolynome |
easy modelling of polynomial trends |
RMtrend |
for explicit trend modelling |
R.models |
for implicit trend modelling |
R.c |
for multivariate trend modelling |
Auxiliary models
See Auxiliary RMmodels.
Note that, instead of the named arguments, a single argument k
can be passed. This is possible if all the arguments
are scalar. Then k
must have a length equal to the number of
arguments.
If an argument equals NULL
the
argument is not set (but must have a valid name).
Aniso
can be given also by RMangle
or any other RMmodel
instead of a matrix
Note also that a completely different possibility exists to define a
model, namely by a list. This format allows for easy flexible models
and modifications (and some few more options, as well as some
abbreviations to the model names, see PrintModelList()
).
Here, the argument var
, scale
,
Aniso
and proj
must be passed by the model
RMS
.
For instance,
model <- RMexp(scale=2, var=5)
is equivalent to
model <- list("RMS", scale=2, var=5, list("RMexp"))
The latter definition can be also obtained by
print(RMexp(scale=2, var=5))
model <- RMnsst(phi=RMgauss(var=7), psi=RMfbm(alpha=1.5),
scale=2, var=5)
is equivalent to
model <- list("RMS", scale=2, var=5,
list("RMnsst", phi=list("RMS", var=7, list("RMgauss")),
psi=list("RMfbm", alpha=1.5))
)
.
All models have secondary names that stem from
RandomFields versions 2 and earlier and
that can also be used as strings in the list notation.
See RFgetModelNames(internal=FALSE)
for
the full list.
Alexander Malinowski; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., Space-Time Processes and Challenges Related to Environmental Problems. New York: Springer.
Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package RandomFields. Journal of Statistical Software, 63 (8), 1-25, url = ‘http://www.jstatsoft.org/v63/i08/’
‘multivariate’, the corresponding vignette.
Yaglom, A.M. (1987) Correlation Theory of Stationary and Related Random Functions I, Basic Results. New York: Springer.
Wackernagel, H. (2003) Multivariate Geostatistics. Berlin: Springer, 3nd edition.
RFformula
,
RM,
RMmodels
,
RMmodelsAuxiliary
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## a non-stationary field with a sharp boundary ## of the differentiabilities x <- seq(-0.6, 0.6, len=50) model <- RMwhittle(nu=0.8 + 1.5 * R.is(R.p(new="isotropic"), "<=", 0.5)) z <- RFsimulate(model=model, x, x, n=4) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## a non-stationary field with a sharp boundary ## of the differentiabilities x <- seq(-0.6, 0.6, len=50) model <- RMwhittle(nu=0.8 + 1.5 * R.is(R.p(new="isotropic"), "<=", 0.5)) z <- RFsimulate(model=model, x, x, n=4) plot(z)
Here, multivariate and vector-valued covariance models are presented.
Bivariate covariance models
RMbicauchy |
a bivariate Cauchy model |
RMbiwm |
full bivariate Whittle-Matern model (stationary and isotropic) |
RMbigneiting |
bivariate Gneiting model (stationary and isotropic) |
RMbistable |
a bivariate stable model |
Physically motivated, vector valued covariance and variogram models
RMcurlfree |
curlfree (spatial) vector-valued field (stationary and anisotropic) |
RMdivfree |
divergence free (spatial) vector-valued field (stationary and anisotropic) |
RMkolmogorov |
Kolmogorov's model of turbulence |
RMvector |
vector-valued field (combining RMcurlfree and RMdivfree )
|
Multivariate covariance models
RMdelay |
delay effect model (stationary) |
RMderiv |
field and its gradient |
RMmatrix |
linear model of coregionalization |
RMparswm |
multivariate Whittle-Matern model (stationary and isotropic) |
Operators
RMcov |
covariance structure given by a multivariate variogram |
RMexponential |
functional returning
|
RMmatrix |
linear model of coregionalization |
RMmqam |
multivariate quasi-arithmetic mean (stationary) |
RMschur |
element-wise product with a positive definite matrix |
RMtbm |
turning bands operator |
Trend models
RMtrend |
for explicit trend modelling |
R.models |
for implicit trend modelling |
R.c |
binding univariate trend models into a vector |
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., Space-Time Processes and Challenges Related to Environmental Problems. New York: Springer.
Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, simulation and prediction of multivariate random fields with package RandomFields. Journal of Statistical Software, 63 (8), 1-25, url = ‘http://www.jstatsoft.org/v63/i08/’
Wackernagel, H. (2003) Multivariate Geostatistics. Berlin: Springer, 3rd edition.
RFformula
, RMmodels
,
RM
,
RMmodelsAdvanced
‘multivariate’, a vignette for multivariate geostatistics
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 100 x <- runif(n=n, min=1, max=50) y <- runif(n=n, min=1, max=50) rho <- matrix(nc=2, c(1, -0.8, -0.8, 1)) model <- RMparswmX(nudiag=c(0.5, 0.5), rho=rho) ## generation of artifical data dta <- RFsimulate(model = model, x=x, y=y, grid=FALSE) ## introducing some NAs ... dta@data$variable1[1:10] <- NA if (interactive()) dta@data$variable2[90:100] <- NA plot(dta) ## co-kriging x <- y <- seq(0, 50, 1) k <- RFinterpolate(model, x=x, y=y, data= dta) plot(k, dta) ## conditional simulation z <- RFsimulate(model, x=x, y=y, data= dta) ## takes a while plot(z, dta)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again n <- 100 x <- runif(n=n, min=1, max=50) y <- runif(n=n, min=1, max=50) rho <- matrix(nc=2, c(1, -0.8, -0.8, 1)) model <- RMparswmX(nudiag=c(0.5, 0.5), rho=rho) ## generation of artifical data dta <- RFsimulate(model = model, x=x, y=y, grid=FALSE) ## introducing some NAs ... dta@data$variable1[1:10] <- NA if (interactive()) dta@data$variable2[90:100] <- NA plot(dta) ## co-kriging x <- y <- seq(0, 50, 1) k <- RFinterpolate(model, x=x, y=y, data= dta) plot(k, dta) ## conditional simulation z <- RFsimulate(model, x=x, y=y, data= dta) ## takes a while plot(z, dta)
Here, non-stationary covariance models are presented.
Covariance models
RMnonstwm |
one of Stein's non-stationary Whittle-Matern models |
RMprod |
scalar product |
Aniso |
for space transformation, see the example in R.models. |
scale , cf. RMS , can be any non-negative
function for any scale mixture model, such as
the whittle-matern-classes,
the powered exponential family, and the
RMgencauchy model.
|
Trend models See RMmodelsTrend.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFformula
, RMmodels
,
RM
,
RMmodelsAdvanced
‘nonstationary’, a vignette for non-stationary geostatistics
# to do
# to do
Here, a collection of implemented space-time models is given.
Stationary space-time models
Here, most of the models are composed models (operators).
Note that in space-time modelling the argument proj
may also take the values "space"
for the projection on the space
and "time"
for the projection onto the time axis.
separable models | are easily constructed using
+ , * ,
and proj, see also the example below
|
RMave |
space-time moving average model |
RMcoxisham |
Cox-Isham model |
RMcurlfree |
curlfree (spatial) field (stationary and anisotropic) |
RMdivfree |
divergence free (spatial) vector-valued field (stationary and anisotropic) |
RMgennsst |
generalization of Gneiting's non-separable space-time model |
RMiaco |
non-separable space-time model |
RMmastein |
Ma-Stein model |
RMnsst |
Gneiting's non-separable space-time model |
RMstein |
Stein's non-separable space-time model |
RMstp |
Single temporal process |
RMtbm |
Turning bands operator |
Alexander Malinowski; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., Space-Time Processes and Challenges Related to Environmental Problems. New York: Springer.
RFformula
,
RM,
RMmodels
,
RMmodelsAdvanced
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## multiplicative separable model with exponential model in space ## and Gaussian in time model <- RMexp(proj = "space") * RMgauss(proj = "time") x <- T <- seq(0, 10, 0.1) z <- RFsimulate(model, x=x, T=T) plot(z) ## additive separable model with exponential model in space ## and Gaussian in time. The structure is getting rather simple, ## see the function stopifnot below model <- RMexp(proj = "space") + RMgauss(proj = "time") x <- T <- seq(0, 10, 0.1) z <- RFsimulate(model, x=x, T=T) stopifnot(sum(abs(apply(apply(z, 1, diff), 1, diff))) < 1e-14) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## multiplicative separable model with exponential model in space ## and Gaussian in time model <- RMexp(proj = "space") * RMgauss(proj = "time") x <- T <- seq(0, 10, 0.1) z <- RFsimulate(model, x=x, T=T) plot(z) ## additive separable model with exponential model in space ## and Gaussian in time. The structure is getting rather simple, ## see the function stopifnot below model <- RMexp(proj = "space") + RMgauss(proj = "time") x <- T <- seq(0, 10, 0.1) z <- RFsimulate(model, x=x, T=T) stopifnot(sum(abs(apply(apply(z, 1, diff), 1, diff))) < 1e-14) plot(z)
RMmppplus
is a multivariate covariance model which depends on
up to 10 submodels .
Used together with RPsmith
, it allows for mixed
moving maxima with a finite number of shape functions.
RMmppplus(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, p)
RMmppplus(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, p)
C0 |
an |
C1 , C2 , C3 , C4 , C5 , C6 , C7 , C8 , C9
|
optional; each an |
p |
vector of probabilities for the shape functions. The probabilities should add up to 1. The length of the vector equals the number of given submodels. |
RMmppplus
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMplus
,
RMmodel
,
RFsimulate
,
RFfit
,
RPsmith
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RMmqam
is a multivariate stationary covariance model depending
on a submodel such that
is completely monotone, and depending on further stationary
covariance models
. The covariance is given by
where is a completely monotone function,
are
suitable covariance functions and
such that
.
RMmqam(phi, C1, C2, C3, C4, C5, C6, C7, C8, C9, theta, var, scale, Aniso, proj)
RMmqam(phi, C1, C2, C3, C4, C5, C6, C7, C8, C9, theta, var, scale, Aniso, proj)
phi |
a valid covariance |
C1 , C2 , C3 , C4 , C5 , C6 , C7 , C8 , C9
|
optional further stationary |
theta |
is a vector of values in |
var , scale , Aniso , proj
|
optional arguments; same meaning for any |
Note that is completely monotone if and only if
is a valid covariance function for all dimensions,
e.g.
RMstable
, RMgauss
, RMexponential
.
Warning: RandomFields
cannot check whether the combination
of and
is valid.
RMmqam
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Porcu, E., Mateu, J. & Christakos, G. (2009) Quasi-arithmetic means of covariance functions with potential applications to space-time data. Journal of Multivariate Analysis, 100, 1830–1844.
RMqam
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(modus_operandi="sloppy") model <- RMmqam(phi=RMgauss(),RMgauss(),RMexp(),theta=c(0.4, 0.6), scale=0.5) x <- seq(0, 10, 0.02) plot(model) z <- RFsimulate(model=model, x=x) plot(z) RFoptions(modus_operandi="normal")
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(modus_operandi="sloppy") model <- RMmqam(phi=RMgauss(),RMgauss(),RMexp(),theta=c(0.4, 0.6), scale=0.5) x <- seq(0, 10, 0.02) plot(model) z <- RFsimulate(model=model, x=x) plot(z) RFoptions(modus_operandi="normal")
RMmult
is a multivariate covariance model which depends on
up to 10 submodels .
In general, realizations of the created
RMmodel
are pointwise
products of independent realizations of the submodels.
In particular, if all submodels are given through a covariance function, the resulting model is defined through its covariance function, which is the product of the submodels' covariances.
RMmult(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, var, scale, Aniso, proj)
RMmult(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, var, scale, Aniso, proj)
C0 |
an |
C1 , C2 , C3 , C4 , C5 , C6 , C7 , C8 , C9
|
optional; each an |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMmodel
s can also be multiplied via the
*
-operator, e.g. C0 * C1.
The global arguments scale,Aniso,proj
of RMmult
are multiplied to the corresponding argument of the submodels
(from the right side). E.g.,
RMmult(Aniso=A1, RMexp(Aniso=A2), RMspheric(Aniso=A3))
equals
RMexp(Aniso=A2 %*% A1) * RMspheric(Aniso=A3 %*% A1)
In case that all submodels are given through a covariance function,
the global argument var
of RMmult
is multiplied to the product covariance of RMmult
.
RMmult
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMplus
,
RMmodel
,
RMprod
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # separable, multiplicative model model <- RMgauss(proj=1) * RMexp(proj=2, scale=5) z <- RFsimulate(model=model, 0:10, 0:10, n=4) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # separable, multiplicative model model <- RMgauss(proj=1) * RMexp(proj=2, scale=5) z <- RFsimulate(model=model, 0:10, 0:10, n=4) plot(z)
RMmultiquad
is an isotropic covariance model. The
corresponding covariance function, the multiquadric family, only
depends on the angle
between two points on the sphere and is given by
where and
.
RMmultiquad(delta, tau, var, scale, Aniso, proj)
RMmultiquad(delta, tau, var, scale, Aniso, proj)
delta |
a numerical value in |
tau |
a numerical value greater than |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
Special cases (cf. Gneiting, T. (2013), p.1333) are known for fixed parameter
which leads to the covariance function called
'inverse multiquadric'
and for fixed parameter
which gives the covariance function called 'Poisson spline'
For a more general form, see RMchoquet
.
RMmultiquad
returns an object of class RMmodel
.
Christoph Berreth, Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. (2013) Strictly and non-strictly positive definite functions on spheres Bernoulli, 19(4), 1327-1349.
RMmodel
,
RFsimulate
,
RFfit
,
RMchoquet
,
spherical models
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(coord_system="sphere") model <- RMmultiquad(delta=0.5, tau=1) plot(model, dim=2) ## the following two pictures are the same x <- seq(0, 0.12, 0.01) z1 <- RFsimulate(model, x=x, y=x) plot(z1) x2 <- x * 180 / pi z2 <- RFsimulate(model, x=x2, y=x2, coord_system="earth") plot(z2) stopifnot(all.equal(as.array(z1), as.array(z2))) RFoptions(coord_system="auto")
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(coord_system="sphere") model <- RMmultiquad(delta=0.5, tau=1) plot(model, dim=2) ## the following two pictures are the same x <- seq(0, 0.12, 0.01) z1 <- RFsimulate(model, x=x, y=x) plot(z1) x2 <- x * 180 / pi z2 <- RFsimulate(model, x=x2, y=x2, coord_system="earth") plot(z2) stopifnot(all.equal(as.array(z1), as.array(z2))) RFoptions(coord_system="auto")
RMnatsc
is a stationary isotropic covariance model that
depends on a stationary isotropic covariance model .
The covariance is given by
where the argument s
is chosen by RMnatsc
such that the practical range or the mathematical range, if finite, is 1.
RMnatsc(phi, var, scale, Aniso, proj)
RMnatsc(phi, var, scale, Aniso, proj)
phi |
a stationary isotropic covariance |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
For internal use only.
RMnatsc
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMnatsc(RMexp()) x <- seq(0, 10, 0.02) plot(RMexp(), model=model) RFcov(model, 1)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMnatsc(RMexp()) x <- seq(0, 10, 0.02) plot(RMexp(), model=model) RFcov(model, 1)
The non-stationary Whittle-Matern model
is given by
where , and
must be a positive function.
is the
covariance of the
RMwhittle
model or the
RMmatern
model.
The non-stationary Whittle-Matern models are obtained by
the respective stationary model, replacing the
real-valued argument for nu
by a non-negative function.
It cannot be checked whether nu
only takes positive values. So
the responsibility is completely left to the user.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Stein, M. (2005) Nonstationary Spatial Covariance Functions. Tech. Rep., 2005
RMwhittle
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(-1.2, 1.2, len=50) model <- RMwhittle(nu=RMgauss()) z <- RFsimulate(model=model, x, x, n=4) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(-1.2, 1.2, len=50) model <- RMwhittle(nu=RMgauss()) z <- RFsimulate(model=model, x, x, n=4) plot(z)
RMnsst
is a univariate stationary spaceisotropic covariance model
whose corresponding covariance is given by
RMnsst(phi, psi, delta, var, scale, Aniso, proj)
RMnsst(phi, psi, delta, var, scale, Aniso, proj)
phi |
is a normal mixture |
psi |
is a variogram |
delta |
a numerical value; must be greater than or equal to the spatial dimension of the field. |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This model is used for space-time modelling where the spatial component is isotropic.
RMnsst
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. (1997) Normal scale mixtures and dual probability densitites, J. Stat. Comput. Simul. 59, 375-384.
Gneiting, T. (2002) Nonseparable, stationary covariance functions for space-time data, JASA 97, 590-600.
Gneiting, T. and Schlather, M. (2001) Space-time covariance models. In El-Shaarawi, A.H. and Piegorsch, W.W.: The Encyclopedia of Environmetrics. Chichester: Wiley.
Schlather, M. (2010) On some covariance models based on normal scale mixtures. Bernoulli, 16, 780-797.
RMgennsst
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMnsst(phi=RMgauss(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.25) plot(model, dim=2) plot(RFsimulate(model, x=x, y=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMnsst(phi=RMgauss(), psi=RMfbm(alpha=1), delta=2) x <- seq(0, 10, 0.25) plot(model, dim=2) plot(RFsimulate(model, x=x, y=x))
RMnugget
is a multivariate stationary isotropic covariance model
called “nugget effect”.
The corresponding covariance function only depends on the distance
between two points and is given for
in
vdim
by
where if
and
otherwise.
RMnugget(tol, vdim, var, Aniso, proj)
RMnugget(tol, vdim, var, Aniso, proj)
tol |
Only for advanced users. See |
vdim |
Must be set only for multivariate models (advanced). |
var |
optional argument; same meaning for any
|
Aniso , proj
|
(zonal modelling and repeated
measurements(advanced)); see |
The nugget effect belongs to Gaussian white noise and is used for modeling measurement errors or to model spatial ‘nuggets’.
RMnugget
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmodel
,
RFsimulate
,
RFfit
,
RPnugget
(advanced users).
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- 1:2 xy <- as.matrix(expand.grid(x, y)) ## we get 4 locations ## Standard use of the nugget effect model <- RMnugget(var = 100) RFcovmatrix(model, x=xy) as.vector(RFsimulate(model, x=x, y=x, tol=1e-10))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- y <- 1:2 xy <- as.matrix(expand.grid(x, y)) ## we get 4 locations ## Standard use of the nugget effect model <- RMnugget(var = 100) RFcovmatrix(model, x=xy) as.vector(RFsimulate(model, x=x, y=x, tol=1e-10))
RMparswm
is a multivariate stationary isotropic
covariance model
whose corresponding covariance function only depends on the distance
between
two points and is given for
by
Here is the covariance of the
RMwhittle
model.
RMparswmX
ist defined as
where is any covariance matrix.
RMparswm(nudiag, var, scale, Aniso, proj) RMparswmX(nudiag, rho, var, scale, Aniso, proj)
RMparswm(nudiag, var, scale, Aniso, proj) RMparswmX(nudiag, rho, var, scale, Aniso, proj)
nudiag |
a vector of arbitrary length of positive values; the vector |
rho |
any positive definite |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
In the equation above we have
and
where is the Gamma function and
is the dimension
of the space.
Note that the definition of RMparswmX
is
RMschur(M=rho, RMparswm(nudiag, var, scale, Aniso, proj))
.
RMparswm
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T., Kleiber, W., Schlather, M. (2010) Matern covariance functions for multivariate random fields JASA
RMbiwm
,
RMwhittle
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again rho <- matrix(nc=3, c(1, 0.5, 0.2, 0.5, 1, 0.6, 0.2, 0.6, 1)) model <- RMparswmX(nudiag=c(1.3, 0.7, 2), rho=rho) plot(model) x.seq <- y.seq <- seq(-10, 10, 0.1) z <- RFsimulate(model = model, x=x.seq, y=y.seq) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again rho <- matrix(nc=3, c(1, 0.5, 0.2, 0.5, 1, 0.6, 0.2, 0.6, 1)) model <- RMparswmX(nudiag=c(1.3, 0.7, 2), rho=rho) plot(model) x.seq <- y.seq <- seq(-10, 10, 0.1) z <- RFsimulate(model = model, x=x.seq, y=y.seq) plot(z)
RMpenta
is a stationary isotropic covariance model, which is only valid for dimensions
.
The corresponding covariance function only depends on the distance
between
two points and is given by
RMpenta(var, scale, Aniso, proj)
RMpenta(var, scale, Aniso, proj)
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model is only valid for dimensions .
It has a 4 times differentiable covariance function with compact support (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 84).
RMpenta
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMpenta() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMpenta() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMplus
is an additive covariance model which depends on
up to 10 submodels .
In general, realizations of the created
RMmodel
are pointwise
sums of independent realizations of the submodels.
In particular, if all submodels are given through a covariance function, the resulting model is defined through its covariance function, which is the sum of the submodels' covariances. Analogously, if all submodels are given through a variogram.
RMplus(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, var, scale, Aniso, proj)
RMplus(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, var, scale, Aniso, proj)
C0 |
an |
C1 , C2 , C3 , C4 , C5 , C6 , C7 , C8 , C9
|
optional; each an |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMmodel
s can also be summed up via the
+
-operator, e.g. C0 + C1.
The global arguments var,scale,Aniso,proj
of RMplus
are multiplied to the corresponding arguments of the submodels
(from the right side).
RMplus
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmult
,
RMmodel
,
RMsum
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMplus(RMgauss(), RMnugget(var=0.1)) model2<- RMgauss() + RMnugget(var=0.1) plot(model, "model.+"=model2, type=c("p", "l"), pch=20, xlim=c(0,3)) # the same
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMplus(RMgauss(), RMnugget(var=0.1)) model2<- RMgauss() + RMnugget(var=0.1) plot(model, "model.+"=model2, type=c("p", "l"), pch=20, xlim=c(0,3)) # the same
RMpolygon
refers to the indicator function of
a typical Poisson polygon, used for instance in the
(mixed) Storm process.
RMpolygon(lambda)
RMpolygon(lambda)
lambda |
intensity of the hyperplane process creating the random shape function. The default value is |
Felix Ballani, https://tu-freiberg.de/fakult1/sto/ballani
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Poisson polygons / Poisson hyperplane tessellation
Lantuejoul, C. (2002) Geostatistical Simulation: Models and Algorithms. Springer.
Poisson storm process
Lantuejoul, C., Bacro, J.N., Bel L. (2011) Storm processes and stochastic geometry. Extremes, 14(4), 413-428.
Mixed Poisson storm process
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
RMball
,
RMspheric
,
RFsimulate
,
RMmodel
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
Polynomials, mainly used in trend models, can be created easily with this function.
RMpolynome(degree, dim, value=NA, coordnames = c("x", "y", "z", "T"), proj=1:4)
RMpolynome(degree, dim, value=NA, coordnames = c("x", "y", "z", "T"), proj=1:4)
degree |
degree of the polynome |
dim |
number of variables in the polynome |
value |
values of the coefficients. See Details. |
coordnames |
the names of the variables |
proj |
the projection to certain dimensions |
If the length of value
is smaller than the number of monomials,
the remaining terms are filled with NA
s. If the length is
larger, the vector is cut.
RMpolynome
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
## For examples see the help page of 'RFformula' ## RMpolynome(1, 1) RMpolynome(1, 2) RMpolynome(2, 1) RMpolynome(2, 2) RMpolynome(3, 3)
## For examples see the help page of 'RFformula' ## RMpolynome(1, 1) RMpolynome(1, 2) RMpolynome(2, 1) RMpolynome(2, 2) RMpolynome(3, 3)
RMpower
yields a variogram or covariance model
from a given variogram or covariance model.
The variogram of the model is given by
if is a variogram model.
The covariance
of the model is given by
if is a covariance model.
RMpower(phi, alpha, var, scale, Aniso, proj)
RMpower(phi, alpha, var, scale, Aniso, proj)
phi |
a valid |
alpha |
a numerical value in the interval [0,1] |
var , scale , Aniso , proj
|
optional arguments; same meaning for any |
If is a variogram, then
is a valid
variogram for
in the interval [0,1].
RMpower
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (2012) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J. M., Schlather, M. Advances and Challenges in Space-time Modelling of Natural Events, Springer, New York.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMpower(RMgauss(), alpha=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMpower(RMgauss(), alpha=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMprod
is a non-stationary covariance model given by
RMprod(phi, var, scale, Aniso, proj)
RMprod(phi, var, scale, Aniso, proj)
phi |
any function of class |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
In general, this model defines a positive definite kernel and hence a covariance model for all functions with values in an arbitrary Hilbert space. However, as already mentioned above,
should stem from a covariance or variogram model, here.
RMprod
returns an object of class RMmodel
.
Do not mix up this model with RMmult
.
See also RMS
for a simple, alternative method to set
an arbitrary, i.e. location dependent, univariate variance.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Wendland, H. Scattered Data Approximation (2005) Cambridge: Cambridge University Press.
RMid
,
RMid
,
RMsum
,
RMmodel
,
RMmult
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFcov(RMprod(RMid()), as.matrix(1:10), as.matrix(1:10), grid=FALSE) ## C(x,y) = exp(-||x|| + ||y||) RFcov(RMprod(RMexp()), as.matrix(1:10), as.matrix(1:10), grid=FALSE) ## C(x,y) = exp(-||x / 10|| + ||y / 10 ||) model <- RMprod(RMexp(scale=10)) x <- seq(0,10,len=100) z <- RFsimulate(model=model, x=x, y=x) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFcov(RMprod(RMid()), as.matrix(1:10), as.matrix(1:10), grid=FALSE) ## C(x,y) = exp(-||x|| + ||y||) RFcov(RMprod(RMexp()), as.matrix(1:10), as.matrix(1:10), grid=FALSE) ## C(x,y) = exp(-||x / 10|| + ||y / 10 ||) model <- RMprod(RMexp(scale=10)) x <- seq(0,10,len=100) z <- RFsimulate(model=model, x=x, y=x) plot(z)
RMqam
is a univariate stationary covariance model depending
on a submodel such that
is completely monotone, and depending on further stationary
covariance models
. The covariance is given by
RMqam(phi, C1, C2, C3, C4, C5, C6, C7, C8, C9, theta, var, scale, Aniso, proj)
RMqam(phi, C1, C2, C3, C4, C5, C6, C7, C8, C9, theta, var, scale, Aniso, proj)
phi |
a valid covariance |
C1 , C2 , C3 , C4 , C5 , C6 , C7 , C8 , C9
|
optional further univariate
stationary |
theta |
a vector with positive entries |
var , scale , Aniso , proj
|
optional arguments; same meaning for any |
Note that is completely monotone if and only if
is a valid covariance function for all dimensions,
e.g.
RMstable
, RMgauss
, RMexponential
.
Warning: RandomFields
cannot check whether the combination
of and
is valid.
RMqam
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Porcu, E., Mateu, J. & Christakos, G. (2007) Quasi-arithmetic means of covariance functions with potential applications to space-time data. Submitted to Journal of Multivariate Analysis.
RMmqam
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMqam(phi=RMgauss(), RMexp(), RMgauss(), theta=c(0.3, 0.7), scale=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMqam(phi=RMgauss(), RMexp(), RMgauss(), theta=c(0.3, 0.7), scale=0.5) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
The covariance function is
RMqexp(alpha, var, scale, Aniso, proj)
RMqexp(alpha, var, scale, Aniso, proj)
alpha |
value in |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMqexp
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
?
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMqexp(alpha=0.95, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMqexp(alpha=0.95, scale=0.2) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
Defines a simple rational function.
where
RMrational(A, a)
RMrational(A, a)
A |
a |
a |
a vector of one or two components; the second component has default value zero. |
RMrational
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
# see S10
# see S10
RMrotat
and RMrotation
are
auxiliary space-time functions that create some rotation
and
respectively.
RMrotat(speed, phi) RMrotation(phi)
RMrotat(speed, phi) RMrotation(phi)
speed |
real value |
phi |
angle |
RMrotat
and RMrotation
are
space-time models for
two-dimensional space.
RMrotat
and RMrotation
return an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
# see S10
# see S10
RMS
is an operator that modifies the variance and the
coordinates or distances of a submodel by
Most users will never call RMS
directly, see
Details. However, the following describes the arguments
var
, scale
, Aniso
, proj
that are common to
nearly all models. See RMSadvanced
for advanced use of
these arguments.
RMS(phi, var, scale, Aniso, proj, anisoT)
RMS(phi, var, scale, Aniso, proj, anisoT)
phi |
submodel |
var |
is the optional variance parameter |
scale |
scaling parameter |
Aniso |
matrix or |
proj |
is the optional projection vector which defines a diagonal
matrix of zeros and ones and |
anisoT |
the transpose of the anisotropy matrix |
The call in the usage section is equivalent to
phi(..., var, scale, anisoT, Aniso, proj)
, where phi
has
to be replaced by a valid RMmodel
.
Most users will never call RMS
directly.
RMS
returns an object of class RMmodel
.
At most one of the arguments Aniso
, anisoT
and proj
may be given at the same time.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMprod
for an alternative way to define
an arbitrary, location dependent variance. There, the standard
deviation is given so that RMprod
might be used
even in the multivariate case.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model1 <- RMS(RMexp(), scale=2) model2 <- RMexp(scale=2) x <- seq(0, 10, 0.02) print(all(RFcov(model1, x) == RFcov(model2, x))) # TRUE
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model1 <- RMS(RMexp(), scale=2) model2 <- RMexp(scale=2) x <- seq(0, 10, 0.02) print(all(RFcov(model1, x) == RFcov(model2, x))) # TRUE
Here advances uses are given for the arguments
var
, scale
, Aniso
, proj
that are available
to most of the models
RMS(phi, var, scale, Aniso, proj, anisoT)
submodel
Instead of a constant it can be
also an arbitrary non-negative function, see R.
and RMuser
for defining arbitrary functions.
instead of a positive constant it can be an arbitrary,
positive
deterministic function. In case of the latter, the scale should be
given by one of the functions RMbubble
or
RMscale
. In case none of them are given,
RMscale
is assumed with scale penality
for the square of the norm.
The scale can be also a random variable in case of Bayesian modelling.
matrix or RMmodel
.
Instead of a matrix, Aniso
can be an arbitrary, vector-valued
function .
is the optional projection vector which defines a diagonal
matrix of zeros and ones and proj
gives the
positions of the ones (integer values between 1 and the dimension of
). It also allows for the values
'space'
and
'time'
in case of space-time modelling.
the transpose of the anisotropy matrix ,
multiplied from the left by a distance vector
, i.e.
.
See the reference for Gneitings nsst model used for modelling scales. See also the example below.
RMSadvanced
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Bonat, W.H. , Ribeiro, P. Jr. and Schlather, M. (2019) Modelling non-stationarity in scale. In preparation.
RMS
,
RMblend
for a different approach on modelling
different scales
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, if (interactive()) 0.01 else 0.5) d <- sqrt(rowSums(as.matrix(expand.grid(x-0.5, x-0.5))^2)) d <- matrix(d < 0.25, nc=length(x)) image(d) scale <- RMcovariate(data=as.double(d) * 2 + 0.5, raw=TRUE) S <- RMexp(scale = scale) plot(zS <- RFsimulate(S, x, x)) CS <- RFcovmatrix(S, x, x)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, if (interactive()) 0.01 else 0.5) d <- sqrt(rowSums(as.matrix(expand.grid(x-0.5, x-0.5))^2)) d <- matrix(d < 0.25, nc=length(x)) image(d) scale <- RMcovariate(data=as.double(d) * 2 + 0.5, raw=TRUE) S <- RMexp(scale = scale) plot(zS <- RFsimulate(S, x, x)) CS <- RFcovmatrix(S, x, x)
Let the scaling at location
and
a bijective penalizing function for (different) scales.
Then covariance function is given by
RMscale(phi, scaling, penalty, var, scale, Aniso, proj)
RMscale(phi, scaling, penalty, var, scale, Aniso, proj)
phi |
isotropic submodel |
scaling |
model that gives the non-stationary scaling |
penalty |
bijective function |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMscale
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Bonat, W.H. , Ribeiro, P. Jr. and Schlather, M. (2019) Modelling non-stationarity in scale. In preparation.
RMSadvanced
,
RMblend
,
RMbubble
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, 0.01) scale <- RMcovariate(x=c(0,1), y=c(1,0),#2 areas separated by the 1st bisector grid=FALSE, data=c(1, 3)) model <- RMscale(RMexp(), scaling = scale, penalty=RMid() / 2) plot(z <- RFsimulate(model, x, x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0,1, 0.01) scale <- RMcovariate(x=c(0,1), y=c(1,0),#2 areas separated by the 1st bisector grid=FALSE, data=c(1, 3)) model <- RMscale(RMexp(), scaling = scale, penalty=RMid() / 2) plot(z <- RFsimulate(model, x, x))
RMschlather
gives
the tail correlation function of the extremal Gaussian
process, i.e.
where is the covariance of a stationary Gaussian field.
RMschlather(phi, var, scale, Aniso, proj)
RMschlather(phi, var, scale, Aniso, proj)
phi |
covariance function of class |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This model yields the tail correlation function of the field
that is returned by RPschlather
.
RMschlather
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RPschlather
,
RMmodel
,
RFsimulate
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## This example considers an extremal Gaussian random field ## with Gneiting's correlation function. ## first consider the covariance model and its corresponding tail ## correlation function model <- RMgneiting() plot(model, model.tail.corr.fct=RMschlather(model), xlim=c(0, 5)) ## the extremal Gaussian field with the above underlying ## correlation function that has the above tail correlation function x <- seq(0, 10, 0.1) z <- RFsimulate(RPschlather(model), x) plot(z) ## Note that in RFsimulate R-P-schlather was called, not R-M-schlather. ## The following lines give a Gaussian random field with correlation ## function equal to the above tail correlation function. z <- RFsimulate(RMschlather(model), x) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## This example considers an extremal Gaussian random field ## with Gneiting's correlation function. ## first consider the covariance model and its corresponding tail ## correlation function model <- RMgneiting() plot(model, model.tail.corr.fct=RMschlather(model), xlim=c(0, 5)) ## the extremal Gaussian field with the above underlying ## correlation function that has the above tail correlation function x <- seq(0, 10, 0.1) z <- RFsimulate(RPschlather(model), x) plot(z) ## Note that in RFsimulate R-P-schlather was called, not R-M-schlather. ## The following lines give a Gaussian random field with correlation ## function equal to the above tail correlation function. z <- RFsimulate(RMschlather(model), x) plot(z)
The covariance function is
where ‘*’ denotes the Schur product, i.e. elementwise multiplication.
RMschur(phi, M, diag, rhored, var, scale, Aniso, proj)
RMschur(phi, M, diag, rhored, var, scale, Aniso, proj)
phi |
covariance function of class |
M |
constant |
diag , rhored
|
alternative way of passing |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMschur
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
?
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMschur(M=matrix(c(2, 1, 1, 1), ncol=2), RMparswm(nudiag=c(0.5, 2))) plot(model) x <- seq(0, 10, 0.02) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMschur(M=matrix(c(2, 1, 1, 1), ncol=2), RMparswm(nudiag=c(0.5, 2))) plot(model) x <- seq(0, 10, 0.02) plot(RFsimulate(model, x=x))
RMsign
defines a random sign. It can be used as part of the
model definition of a Poisson field.
RMsign(phi, p)
RMsign(phi, p)
phi |
shape function of class |
p |
probability of keeping the sign |
RMsign
changes the sign of the shape function phi
with probability 1-p
and keeps it otherwise.
RMsign
returns an object of class RMmodel
.
Random univariate or multivariate objects usually start with RR
, not with RM
.
This is an exception here, as it operates on shape functions.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPpoisson(RMsign(RMtent(), p=0.8)) x <- seq(0, 10, 0.02) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPpoisson(RMsign(RMtent(), p=0.8)) x <- seq(0, 10, 0.02) plot(RFsimulate(model, x=x))
RMsinepower
is an isotropic covariance model. The
corresponding covariance function, the sine power function of
Soubeyrand, Enjalbert and Sache, only depends on the angle between two points on the sphere and is given by
where .
RMsinepower(alpha, var, scale, Aniso, proj)
RMsinepower(alpha, var, scale, Aniso, proj)
alpha |
a numerical value in |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
For the sine power function of Soubeyrand, Enjalbert and Sache, see
Gneiting, T. (2013), equation (17). For a more general form see RMchoquet
.
RMsinepower
returns an object of class RMmodel
.
Christoph Berreth; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gneiting, T. (2013) Strictly and non-strictly positive definite functions on spheres Bernoulli, 19(4), 1327-1349.
RMmodel
,
RFsimulate
,
RFfit
,
spherical models
,
RMchoquet
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(coord_system="sphere") model <- RMsinepower(alpha=1.7) plot(model, dim=2) ## the following two pictures are the same x <- seq(0, 0.4, 0.01) z1 <- RFsimulate(model, x=x, y=x) plot(z1) x2 <- x * 180 / pi z2 <- RFsimulate(model, x=x2, y=x2, coord_system="earth") plot(z2) stopifnot(all.equal(as.array(z1), as.array(z2))) RFoptions(coord_system="auto")
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFoptions(coord_system="sphere") model <- RMsinepower(alpha=1.7) plot(model, dim=2) ## the following two pictures are the same x <- seq(0, 0.4, 0.01) z1 <- RFsimulate(model, x=x, y=x) plot(z1) x2 <- x * 180 / pi z2 <- RFsimulate(model, x=x2, y=x2, coord_system="earth") plot(z2) stopifnot(all.equal(as.array(z1), as.array(z2))) RFoptions(coord_system="auto")
RMspheric
is a stationary isotropic covariance model
which is only valid up to dimension 3.
The corresponding covariance function only depends on the distance
between two points and is given by
RMspheric(var, scale, Aniso, proj)
RMspheric(var, scale, Aniso, proj)
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
This covariance model is valid only for dimensions less than or equal to 3.
The covariance function has a finite range.
RMspheric
returns an object of class RMmodel
.
Although this model is valid on a sphere, do not mix up this model with valid models on a sphere; see spherical models for a list of the latter.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
RMmodel
,
RFsimulate
,
RFfit
,
spherical models.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMspheric() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMspheric() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMstable
is a stationary isotropic covariance model
belonging to the so called stable family.
The corresponding covariance function only depends on the distance
between two points and is given by
where .
RMstable(alpha, var, scale, Aniso, proj) RMpoweredexp(alpha, var, scale, Aniso, proj)
RMstable(alpha, var, scale, Aniso, proj) RMpoweredexp(alpha, var, scale, Aniso, proj)
alpha |
a numerical value; should be in the interval (0,2] to provide a valid covariance function for a random field of any dimension. |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The parameter determines the fractal dimension
of the Gaussian sample paths:
where is the dimension of the random field.
For
the Gaussian sample paths are not
differentiable (cf. Gelfand et al., 2010, p. 25).
Each covariance function of the stable family is a normal scale mixture.
The stable family includes the exponential model (see
RMexp
) for and the Gaussian
model (see
RMgauss
) for .
The model is called stable, because in the 1-dimensional case the covariance is the characteristic function of a stable random variable (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 90).
RMstable
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Covariance function
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
Diggle, P. J., Tawn, J. A. and Moyeed, R. A. (1998) Model-based geostatistics (with discussion). Applied Statistics 47, 299–350.
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
Tail correlation function (for )
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
RMbistable
,
RMexp
,
RMgauss
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstable(alpha=1.9, scale=0.4) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstable(alpha=1.9, scale=0.4) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMstein
is a univariate stationary covariance model
whose corresponding covariance function only depends on the difference
between two points and is given by
Here, is the covariance of the
RMwhittle
model with
smoothness parameter ;
is the norm of the vector
,
is the dimension of the space on which the random field is considered.
RMstein(nu, z, var, scale, Aniso, proj)
RMstein(nu, z, var, scale, Aniso, proj)
nu |
numerical value; greater than 1; smoothness parameter of the RMwhittle model |
z |
a vector; the norm of |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
See Stein (2005).
RMstein
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Stein, M.L. (2005) Space-time covariance functions. J. Amer. Statist. Assoc. 100, 310-321. Equation (8).
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstein(nu=1.5, z=0.9) x <- seq(0, 10, 0.05) plot(RFsimulate(model, x=x, y=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstein(nu=1.5, z=0.9) x <- seq(0, 10, 0.05) plot(RFsimulate(model, x=x, y=x))
RMstp
is a univariate covariance model which depends on
a normal mixture submodel .
The covariance is given by
where
RMstp(xi, phi, S, z, M, var, scale, Aniso, proj)
RMstp(xi, phi, S, z, M, var, scale, Aniso, proj)
xi |
arbitrary univariate function on |
phi |
an |
S |
functions that returns strictly positive definite
|
z |
arbitrary vector, |
M |
an arbitrary, symmetric |
var , scale , Aniso , proj
|
optional arguments; same meaning for any |
See Schlather (2008) formula (13). The model allows for mimicking cyclonic behaviour.
RMstp
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Paciorek C.J., and Schervish, M.J. (2006) Spatial modelling using a new class of nonstationary covariance functions, Environmetrics 17, 483-506.
Schlather, M. (2010) Some covariance models based on normal scale mixtures. Bernoulli, 16, 780-797.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstp(xi = RMrotat(phi= -2 * pi, speed=1), phi = RMwhittle(nu = 1), M=matrix(nc=3, rep(0, 9)), S=RMetaxxa(E=rep(1, 3), alpha = -2 * pi, A=t(matrix(nc=3, c(2, 0, 0, 1, 1 , 0, 0, 0, 0)))) ) x <- seq(0, 10, 0.7) plot(RFsimulate(model, x=x, y=x, z=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMstp(xi = RMrotat(phi= -2 * pi, speed=1), phi = RMwhittle(nu = 1), M=matrix(nc=3, rep(0, 9)), S=RMetaxxa(E=rep(1, 3), alpha = -2 * pi, A=t(matrix(nc=3, c(2, 0, 0, 1, 1 , 0, 0, 0, 0)))) ) x <- seq(0, 10, 0.7) plot(RFsimulate(model, x=x, y=x, z=x))
RMsum
is given by
It is a negative definite function although not a variogram.
RMsum(phi, var, scale, Aniso, proj)
RMsum(phi, var, scale, Aniso, proj)
phi |
any function of class |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
RMsum
returns an object of class RMmodel
.
Do not mix up this model with RMplus
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RMtbm
is a univariate or multivaraiate stationary isotropic covariance
model in dimension reduceddim
which depends on a univariate or
multivariate stationary
isotropic covariance in a bigger dimension
fulldim
.
For formulas for the covariance function see details.
RMtbm(phi, fulldim, reduceddim, layers, var, scale, Aniso, proj)
RMtbm(phi, fulldim, reduceddim, layers, var, scale, Aniso, proj)
phi , fulldim , reduceddim , layers
|
See |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The turning bands method stems from the 1:1 correspondence between the isotropic covariance functions of different dimensions. See Gneiting (1999) and Strokorb and Schlather (2014).
The standard case is reduceddim=1
and fulldim=3
.
If only one of the arguments is given, then the difference of the two
arguments equals 2.
For d == n + 2
, where n=reduceddim
and
d==fulldim
the original dimension, we have
which for n=1
reduces to the standard TBM operator
For d == 2 && n == 1
we have
‘Turning layers’ is a generalization of the turning bands method, see Schlather (2011).
RMtbm
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Turning bands
Gneiting, T. (1999) On the derivatives of radial positive definite function. J. Math. Anal. Appl, 236, 86-99
Matheron, G. (1973). The intrinsic random functions and their applications. Adv . Appl. Probab., 5, 439-468.
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
Turning layers
Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., Space-Time Processes and Challenges Related to Environmental Problems. New York: Springer.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.02) model <- RMspheric() plot(model, model.on.the.line=RMtbm(RMspheric()), xlim=c(-1.5, 1.5)) z <- RFsimulate(RPtbm(model), x, x) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.02) model <- RMspheric() plot(model, model.on.the.line=RMtbm(RMspheric()), xlim=c(-1.5, 1.5)) z <- RFsimulate(RPtbm(model), x, x) plot(z)
The functions transform a coordinate system into another coordinate system. Currently, essentially only from the earth system to cartesian.
RMtrafo
is the internal basic function that also allows
to reduce vectors to their norm.
RMtrafo(phi, new) RFearth2cartesian(coord, units=NULL, system="cartesian", grid=FALSE) RFearth2dist(coord, units=NULL, system="cartesian", grid=FALSE, ...)
RMtrafo(phi, new) RFearth2cartesian(coord, units=NULL, system="cartesian", grid=FALSE) RFearth2dist(coord, units=NULL, system="cartesian", grid=FALSE, ...)
new |
integer or character. One of the values
or the corresponding Note that Default: |
phi |
optional submodel |
coord |
matrix or vector of earth coordinates |
units |
"km" or "miles"; if not given and
|
system |
integer or character. The coordinate system, e.g.
|
grid |
logical. Whether the given coordinates are considered to
be on a grid given by Default: |
... |
the optional arguments of |
The functions transform between different coordinate systems.
The function RMtrafo
returns a matrix, in general. For
fixed column,
the results, applied to each row of the matrix, are returned.
The function RFearth2cartesian
returns a matrix in
one-to-one correspondence with coord
assuming that the
earth is an ellipsoid.
The function RFearth2dist
calculates distances, cf.
dist
, assuming that the
earth is an ellipsoid.
Important options are units
and coordinate_system
, see
RFoptions
.
Note also that the zenit must be given explicitly for projection onto a plane. See the examples below.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
For calculating the earth coordinates as ellipsoid:
constants,
RMangle
,
RMid
,
RMidmodel
.
data(weather) (coord <- weather[1:5, 3:4]) (z <- RFfctn(RMtrafo(new=RC_CARTESIAN_COORD), coord)) (z1 <- RFearth2cartesian(coord)) ## equals z z1 - z ## 0, i.e., z1 and t(z) are the same dist(z) (d <- RFearth2dist(coord)) d - dist(z) ## 0, i.e., d and dist(z) are the same ## projection onto planes RFoptions(zenit=c(-122, 47)) RFearth2cartesian(coord, system="gnomonic") RFearth2cartesian(coord, system="orthographic")
data(weather) (coord <- weather[1:5, 3:4]) (z <- RFfctn(RMtrafo(new=RC_CARTESIAN_COORD), coord)) (z1 <- RFearth2cartesian(coord)) ## equals z z1 - z ## 0, i.e., z1 and t(z) are the same dist(z) (d <- RFearth2dist(coord)) d - dist(z) ## 0, i.e., d and dist(z) are the same ## projection onto planes RFoptions(zenit=c(-122, 47)) RFearth2cartesian(coord, system="gnomonic") RFearth2cartesian(coord, system="orthographic")
RMtrend
is a pure trend model with covariance 0.
RMtrend(mean)
RMtrend(mean)
mean |
numeric or RMmodel.
If it is numerical, it should be a vector of length |
Note that this function refers to trend surfaces in the geostatistical
framework. Fixed effects in the mixed models framework are also being
implemented, see RFformula
.
RMtrend
returns an object of class RMmodel
.
Using uncapsulated subtraction to build up a covariance
function is ambiguous, see the examples below.
Best to define the trend separately, or to use
R.minus
.
Marco Oesting, [email protected], https://www.isa.uni-stuttgart.de/institut/team/Oesting/; Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J. P., Delfiner, P. (1999) Geostatistics: Modelling Spatial Uncertainty. New York: John Wiley & Sons.
RMmodel
,
RFformula
,
RFsimulate
,
RMplus
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## first simulate some data with a sine and a mean as trend repet <- 100 x <- seq(0, pi, len=10) trend <- 2 * sin(R.p(new="isotropic")) + 3 model1 <- RMexp(var=2, scale=1) + trend dta <- RFsimulate(model1, x=x, n=repet) ## now, let us estimate variance, scale, and two parameters of the trend model2 <- RMexp(var=NA, scale=NA) + NA * sin(R.p(new="isotropic")) + NA print(RFfit(model2, data=dta)) ## model2 can be made explicit by enclosing the trend parts by ## 'RMtrend' model3 <- RMexp(var=NA, scale=NA) + NA * RMtrend(sin(R.p(new="isotropic"))) + RMtrend(NA) print(RFfit(model2, data=dta)) ## IMPORTANT: subtraction is not a way to combine definite models ## with trends trend <- -1 (model0 <- RMexp(var=0.4) + trend) ## exponential covariance with mean -1 (model1 <- RMexp(var=0.4) + -1) ## same as model0 (model2 <- RMexp(var=0.4) + RMtrend(-1)) ## same as model0 (model3 <- RMexp(var=0.4) - 1) ## this is a purely deterministic model ## with exponential trend plot(RFsimulate(model=model0, x=x, y=x)) ## exponential covariance ## and mean -1 plot(RFsimulate(model=model1, x=x, y=x)) ## dito plot(RFsimulate(model=model2, x=x, y=x)) ## dito plot(RFsimulate(model=model3, x=x, y=x)) ## purely deterministic model!
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## first simulate some data with a sine and a mean as trend repet <- 100 x <- seq(0, pi, len=10) trend <- 2 * sin(R.p(new="isotropic")) + 3 model1 <- RMexp(var=2, scale=1) + trend dta <- RFsimulate(model1, x=x, n=repet) ## now, let us estimate variance, scale, and two parameters of the trend model2 <- RMexp(var=NA, scale=NA) + NA * sin(R.p(new="isotropic")) + NA print(RFfit(model2, data=dta)) ## model2 can be made explicit by enclosing the trend parts by ## 'RMtrend' model3 <- RMexp(var=NA, scale=NA) + NA * RMtrend(sin(R.p(new="isotropic"))) + RMtrend(NA) print(RFfit(model2, data=dta)) ## IMPORTANT: subtraction is not a way to combine definite models ## with trends trend <- -1 (model0 <- RMexp(var=0.4) + trend) ## exponential covariance with mean -1 (model1 <- RMexp(var=0.4) + -1) ## same as model0 (model2 <- RMexp(var=0.4) + RMtrend(-1)) ## same as model0 (model3 <- RMexp(var=0.4) - 1) ## this is a purely deterministic model ## with exponential trend plot(RFsimulate(model=model0, x=x, y=x)) ## exponential covariance ## and mean -1 plot(RFsimulate(model=model1, x=x, y=x)) ## dito plot(RFsimulate(model=model2, x=x, y=x)) ## dito plot(RFsimulate(model=model3, x=x, y=x)) ## purely deterministic model!
RMtruncsupport
may be used to truncate the support of a shape function when
Poisson fields or M3 processes are created.
RMtruncsupport(phi, radius)
RMtruncsupport(phi, radius)
phi |
function of class |
radius |
truncation at |
RMtruncsupport
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (2002) Models for stationary max-stable random fields. Extremes 5, 33-44.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss() model1 <- RMtruncsupport(model, radius=1) plot(model) lines(model1, col="red") ## For a real application of 'RMtruncsupport' see example 2 of 'RPpoisson'.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss() model1 <- RMtruncsupport(model, radius=1) plot(model) lines(model1, col="red") ## For a real application of 'RMtruncsupport' see example 2 of 'RPpoisson'.
RMuser
allows for a user-defined covariance function, variogram
model, or arbitrary function.
RMuser is very slow – users should avoid this model whenever possible.
RMuser(type, domain, isotropy, vdim, beta, coordnames = c("x", "y", "z", "T"), fctn, fst, snd, envir, var, scale, Aniso, proj)
RMuser(type, domain, isotropy, vdim, beta, coordnames = c("x", "y", "z", "T"), fctn, fst, snd, envir, var, scale, Aniso, proj)
type |
See Default: |
domain |
See Default: |
isotropy |
See
Default:
|
vdim |
multivariability. Default: |
beta |
a fixed matrix that is multiplied to the return value of the
given function; the dimension must match.
Defining a vector valued function and |
coordnames |
Just the names of the variables. More variable names might be given here than used in the function. See Details for the interpretation of variables. |
fctn , fst , snd
|
a user-defined function and its first,
second and third derivative, given as
|
envir |
the environment where the given function shall be evaluated |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
Primarily, a function is expected that depends on
a vector whose components, , are given separately as
scalar quantities.
Alternatively, the function might depend only on the first argument
given by coordnames
.
A kernel should depend on the first two arguments
given by coordnames
.
RMuser
returns an object of class
RMmodel
.
The use of RMuser
is completely on the risk of the
user. There is no
way to check whether the expressions of the user are
correct in any sense.
Note that x
, y
, z
and T
are reserved
argument names that define solely the coordinates.
Hence, none of these names might be used for
other arguments within these functions.
In user-defined functions, the models of RandomFields are not recognized, so they cannot be included in the function definitions.
RMuser
may not be used in connection with obsolete
commands of RandomFields.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMcovariate
,
RMfixcov
,
RFfit
,
RMmodelgenerator
,
RMmodel
,
RFsimulate
,
RC_ISO_NAMES, RC_DOMAIN_NAMES.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Alternatively to 'model <- RMexp()' one may define the following ## (which is, however, much slower and cannot use all features of ## RandomFields) ## user-defined exponential covariance model model <- RMuser(type="positive definite", domain="single variable", iso="isotropic", fctn=exp(-x)) x <- y <- seq(1, 10, len=100) plot(model) z <- RFsimulate(model, x=x, y=y) plot(z) ## the kernel, which is the scalar product (see RMprod) model <- RMnugget(var=1e-5) + RMuser(type="positive definite", domain="kernel", iso="symmetric", fctn=sum(x * y)) x <- y <- seq(1, 10, len=35) z <- RFsimulate(model, x=x, y=y, n=6, svdtol=1e-9) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Alternatively to 'model <- RMexp()' one may define the following ## (which is, however, much slower and cannot use all features of ## RandomFields) ## user-defined exponential covariance model model <- RMuser(type="positive definite", domain="single variable", iso="isotropic", fctn=exp(-x)) x <- y <- seq(1, 10, len=100) plot(model) z <- RFsimulate(model, x=x, y=y) plot(z) ## the kernel, which is the scalar product (see RMprod) model <- RMnugget(var=1e-5) + RMuser(type="positive definite", domain="kernel", iso="symmetric", fctn=sum(x * y)) x <- y <- seq(1, 10, len=35) z <- RFsimulate(model, x=x, y=y, n=6, svdtol=1e-9) plot(z)
RMvector
is a multivariate covariance model which depends on
a univariate covariance model that is stationary in the first
coordinates
and where the covariance function phi(h,t)
is twice differentiable in the first component
.
The corresponding matrix-valued covariance function C of the model
only depends on the difference between two points in the
first component.
It is given by
where the operator is applied to the first component only.
RMvector(phi, a, Dspace, var, scale, Aniso, proj)
RMvector(phi, a, Dspace, var, scale, Aniso, proj)
phi |
an |
a |
a numerical value; should be in the interval |
Dspace |
an integer; either 2 or 3; the first |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
is either a spatio-temporal model (then
is the
time component) or it is an isotropic model. Then, the first
coordinates are considered as
coordinates and the remaining
ones as
coordinates. By default,
equals the
dimension of the field (and there is no
component).
If
then the field is curl free; if
then the field is
divergence free.
RMvector
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Scheuerer, M. and Schlather, M. (2012) Covariance Models for Divergence-Free and Curl-Free Random Vector Fields. Stochastic Models 28:3.
RMcurlfree
,
RMdivfree
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMvector(RMgauss(), scale=0.3) x <- seq(0, 10, 0.4) plot(RFsimulate(model, x=x, y=x, z=0), select.variables=list(1:2))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMvector(RMgauss(), scale=0.3) x <- seq(0, 10, 0.4) plot(RFsimulate(model, x=x, y=x, z=0), select.variables=list(1:2))
RMwave
is a stationary isotropic covariance model, which is valid only for dimensions
.
The corresponding covariance function only depends on the distance
between
two points and is given by
It is a special case of RMbessel
.
RMwave(var, scale, Aniso, proj) RMcardinalsine(var, scale, Aniso, proj)
RMwave(var, scale, Aniso, proj) RMcardinalsine(var, scale, Aniso, proj)
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The model is only valid for dimensions . It is a
special case of
RMbessel
for .
This covariance models a hole effect (cf. Chiles, J.-P. and Delfiner, P. (1999), p. 92).
RMwave
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
RMbessel
,
RMmodel
,
RFsimulate
,
RFfit
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMwave(scale=0.1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMwave(scale=0.1) x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x))
RMmatern
is a stationary isotropic covariance model
belonging to the Matern family.
The corresponding covariance function only depends on the distance
between two points.
The Whittle model is given by
where and
is the modified
Bessel function of second kind.
The Matern model is given by
The Handcock-Wallis parametrisation is given by
RMwhittle(nu, notinvnu, var, scale, Aniso, proj) RMmatern(nu, notinvnu, var, scale, Aniso, proj) RMhandcock(nu, notinvnu, var, scale, Aniso, proj)
RMwhittle(nu, notinvnu, var, scale, Aniso, proj) RMmatern(nu, notinvnu, var, scale, Aniso, proj) RMhandcock(nu, notinvnu, var, scale, Aniso, proj)
nu |
a numerical value called “smoothness parameter”; should be greater than 0. |
notinvnu |
logical. If |
var , scale , Aniso , proj
|
optional arguments; same meaning for any
|
The three models are alternative parametrizations of the same covariance function. The Matern model or the Handcock-Wallis parametrisation should be preferred as they seperate the effects of the scaling parameter and the shape parameter.
The Whittle-Matern model is the model of choice if the smoothness of a
random field is to be parametrized: the sample paths of a Gaussian
random field with this covariance structure are times
differentiable if and only if
(see Gelfand et
al., 2010, p. 24).
Furthermore, the fractal dimension (see also RFfractaldim
)
D of the Gaussian sample paths
is determined by : We have
and for
where
is
the dimension of the random field (see Stein, 1999, p. 32).
If the Matern model equals
RMexp
.
For tending to
a rescaled Gaussian
model
RMgauss
appears as limit of the above Handcock-Wallis parametrisation.
For generalizations see section ‘See Also’.
The functions return an object of class RMmodel
.
The Whittle-Matern model is a normal scale mixture.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Covariance function
Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.
Gelfand, A. E., Diggle, P., Fuentes, M. and Guttorp, P. (eds.) (2010) Handbook of Spatial Statistics. Boca Raton: Chapman & Hall/CRL.
Guttorp, P. and Gneiting, T. (2006) Studies in the history of probability and statistics. XLIX. On the Matern correlation family. Biometrika 93, 989–995.
Handcock, M. S. and Wallis, J. R. (1994) An approach to statistical spatio-temporal modeling of meteorological fields. JASA 89, 368–378.
Stein, M. L. (1999) Interpolation of Spatial Data – Some Theory for Kriging. New York: Springer.
Tail correlation function (for )
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
RMexp
, RMgauss
for special
cases of the model (for and
, respectively)
RMhyperbolic
for a univariate
generalization
RMbiwm
for a multivariate generalization
RMnonstwm
, RMstein
for anisotropic (space-time) generalizations
RMmodel
,
RFsimulate
,
RFfit
for general use.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 1, len=100) model <- RMwhittle(nu=1, Aniso=matrix(nc=2, c(1.5, 3, -3, 4))) plot(model, dim=2, xlim=c(-1,1)) z <- RFsimulate(model=model, x, x) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 1, len=100) model <- RMwhittle(nu=1, Aniso=matrix(nc=2, c(1.5, 3, -3, 4))) plot(model, dim=2, xlim=c(-1,1)) z <- RFsimulate(model=model, x, x) plot(z)
Indicator or binary field which has the value 1, if an underfield field exceeds a given threshold, 0 otherwise.
RPbernoulli(phi, stationary_only, threshold)
RPbernoulli(phi, stationary_only, threshold)
phi |
the |
stationary_only |
optional arguments; same meaning as for
|
threshold |
real valued.
|
RPbernoulli
can be applied to any field. If only
a covariance model is given, a Gaussian field is simulated as
underlying field.
The function returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Auxiliary RMmodels
,
RP,
RMbernoulli
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.1) model <- RPbernoulli(RMexp(), threshold=0) z <- RFsimulate(model, x, x, n=4) plot(z) model <- RPbernoulli(RPbrownresnick(RMexp(), xi=1), threshold=1) z <- RFsimulate(model, x, x, n=4) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.1) model <- RPbernoulli(RMexp(), threshold=0) z <- RFsimulate(model, x, x, n=4) plot(z) model <- RPbernoulli(RPbrownresnick(RMexp(), xi=1), threshold=1) z <- RFsimulate(model, x, x, n=4) plot(z)
RPchi2
defines a chi2 field.
RPchi2(phi, boxcox, f)
RPchi2(phi, boxcox, f)
phi |
the |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
f |
integer. Degree of freedom. |
The function returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Auxiliary RMmodels
,
RP
,
RPgauss
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPchi2(RMexp(), f=2) x <- seq(0, 10, 0.1) z <- RFsimulate(model=model, x, x, n=4) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPchi2(RMexp(), f=2) x <- seq(0, 10, 0.1) z <- RFsimulate(model=model, x, x, n=4) plot(z)
This function is used to specify a Gaussian random field that
is to be simulated or estimated.
Returns an object of class RMmodel
.
RPgauss(phi, boxcox, stationary_only)
RPgauss(phi, boxcox, stationary_only)
phi |
the |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
stationary_only |
Logical or NA. Used for the automatic choice of methods.
Default: |
The function returns an object of class RMmodel
.
In most cases, RPgauss
need not be given explicitly as
Gaussian random fields are assumed as default.
RPgauss
may not find the fastest
method neither the most precise one. It just finds any method
among the available methods. (However, it guesses what is a good
choice.)
See RFgetMethodNames
for further information.
Note that some of the methods do not work for all covariance
or variogram models, see RFgetModelNames(intern=FALSE)
.
By default, all Gaussian random fields have zero mean.
Simulating with trend can be done by including RMtrend
in the model.
RPgauss
allows to simulate different classes of random fields,
controlled by the wrapping model:
If the submodel is a pure covariance or
variogram model, i.e. of class RMmodel
, a
corresponding centered Gaussian field is simulated.
Not only stationary fields but also non-stationary and anisotropic
models can be used, e.g. zonal anisotropy, geometrical
anisotropy, separable models, non-separable space-time models,
multiplicative or nested models;
see RMmodel
for a list of all available models.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RP,
Gaussian,
RMmodel
,
RFoptions
,
RPbrownresnick
,
RPchi2
,
RPopitz
,
RPt
,
RPschlather
.
Do not mix up with RMgauss
or RRgauss
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x, seed=0)) plot(RFsimulate(RPgauss(model), x=x, seed=0), col=2) ## the same
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMexp() x <- seq(0, 10, 0.02) plot(model) plot(RFsimulate(model, x=x, seed=0)) plot(RFsimulate(RPgauss(model), x=x, seed=0), col=2) ## the same
Shot noise model, which is also called moving average model, trigger process, dilution random field, and by several other names.
RPpoisson(phi, intensity)
RPpoisson(phi, intensity)
phi |
the model, |
intensity |
the intensity of the underlying stationary Poisson point process |
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # example 1: Posson field based on disks with radius 1 x <- seq(0,25, 0.02) model <- RMball() z <- RFsimulate(RPpoisson(model), x, intensity = 2) plot(z) par(mfcol=c(2,1)) plot(z@data[,1:min(length(z@data), 1000)], type="l") hist(z@data[,1], breaks=0.5 + (-1 : max(z@data))) # example 2: Poisson field based on the normal density function # note that # (i) the normal density as unbounded support that has to be truncated # (ii) the intensity is high so that the CLT holds x <- seq(0, 10, 0.01) model <- RMtruncsupport(radius=5, RMgauss()) z <- RFsimulate(RPpoisson(model), x, intensity = 100) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # example 1: Posson field based on disks with radius 1 x <- seq(0,25, 0.02) model <- RMball() z <- RFsimulate(RPpoisson(model), x, intensity = 2) plot(z) par(mfcol=c(2,1)) plot(z@data[,1:min(length(z@data), 1000)], type="l") hist(z@data[,1], breaks=0.5 + (-1 : max(z@data))) # example 2: Poisson field based on the normal density function # note that # (i) the normal density as unbounded support that has to be truncated # (ii) the intensity is high so that the CLT holds x <- seq(0, 10, 0.01) model <- RMtruncsupport(radius=5, RMgauss()) z <- RFsimulate(RPpoisson(model), x, intensity = 100) plot(z)
Here, all classes of random fields are described that can be simulated.
Gaussian Random Fields | see Gaussian |
Max-stable Random Fields | see Maxstable |
Other Random Fields | Binary field |
chi2 field | |
composed Poisson (shot noise, random coin) | |
t field | |
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.1) model <- RMexp() ## a Gaussian field with exponential covariance function z <- RFsimulate(model, x) plot(z) ## a binary field obtained as a thresholded Gaussian field b <- RFsimulate(RPbernoulli(model), x) plot(b) sum( abs((z@data$variabl1 >=0 ) - b@data$variable1)) == 0 ## TRUE, ## i.e. RPbernoulli is indeed a thresholded Gaussian process
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(0, 10, 0.1) model <- RMexp() ## a Gaussian field with exponential covariance function z <- RFsimulate(model, x) plot(z) ## a binary field obtained as a thresholded Gaussian field b <- RFsimulate(RPbernoulli(model), x) plot(b) sum( abs((z@data$variabl1 >=0 ) - b@data$variable1)) == 0 ## TRUE, ## i.e. RPbernoulli is indeed a thresholded Gaussian process
RPt
defines a t field.
RPt(phi, boxcox, nu)
RPt(phi, boxcox, nu)
phi |
the |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
nu |
non-negative number. Degree of freedom. |
The function returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Related to the extremal t process
T. Opitz (2012) A spectral construction of the extremal t process. arxiv 1207.2296.
Auxiliary RMmodels
,
RP
,
RPgauss
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPt(RMexp(), nu=2) x <- seq(0, 10, 0.1) z <- RFsimulate(model, x, x, n=4) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPt(RMexp(), nu=2) x <- seq(0, 10, 0.1) z <- RFsimulate(model, x, x, n=4) plot(z)
RRdeterm
refers to the distribution of a deterministic variable.
RRdeterm(mean)
RRdeterm(mean)
mean |
the deterministic value |
RRdeterm
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(-2, 2, 0.001) p <- RFpdistr(RRdeterm(mean=1), q=x) plot(x, p, type="l")
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again x <- seq(-2, 2, 0.001) p <- RFpdistr(RRdeterm(mean=1), q=x) plot(x, p, type="l")
RRdistr
defines a distribution family given by fct
.
It is used to introduce random parameters based on
distributions defined on R.
RRdistr(name, nrow, ncol, envir, ...)
RRdistr(name, nrow, ncol, envir, ...)
name |
an arbitrary family of distributions. E.g.
|
nrow , ncol
|
The matrix size (or vector if |
envir |
an environment; defaults to
|
... |
Second possibility to pass the distribution family is to
pass a character string as |
RRdistr
returns an object of class RMmodel
.
RRdistr
is the generic model introduced
automatically when distribution families in R are used in the model
definition. See the examples below.
See Bayesian Modelling for a less technical introduction to hierarchical modelling.
The use of RRdistr
is completely on the risk of the user. There is no
way to check whether the expressions of the user are mathematically
correct.
Further, RRdistr
may not be used in connection with obsolete
commands of RandomFields.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmodel
,
RR,
RFsimulate
,
RFdistr
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## here a model with random scale parameter model <- RMgauss(scale=exp(rate=1)) x <- seq(0,10,0.02) n <- 10 for (i in 1:n) { readline(paste("Simulation no.", i, ": press return", sep="")) plot(RFsimulate(model, x=x, seed=i)) } ## another possibility to define exactly the same model above is ## model <- RMgauss(scale=exp()) ## note that however, the following two definitions lead ## to covariance models with fixed scale parameter: ## model <- RMgauss(scale=exp(1)) # fixed to 2.7181 ## model <- RMgauss(scale=exp(x=1)) # fixed to 2.7181 ## here, just two other examples: ## fst model <- RMmatern(nu=unif(min=0.1, max=2)) # random for (i in 1:n) { readline(paste("Simulation no.", i, ": press return", sep="")) plot(RFsimulate(model, x=x, seed=i)) } ## snd, part 1 ## note that the fist 'exp' refers to the exponential function, ## the second to the exponential distribution. (model1 <- RMgauss(var=exp(3), scale=exp(rate=1))) x <- 1:100/10 plot(z1 <- RFsimulate(model=model, x=x)) ## snd, part 2 ## exactly the same result as in the previous example (model2 <- RMgauss(var=exp(3), scale=RRdistr("exp", rate=1))) plot(z2 <- RFsimulate(model=model, x=x)) all.equal(model1, model2)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## here a model with random scale parameter model <- RMgauss(scale=exp(rate=1)) x <- seq(0,10,0.02) n <- 10 for (i in 1:n) { readline(paste("Simulation no.", i, ": press return", sep="")) plot(RFsimulate(model, x=x, seed=i)) } ## another possibility to define exactly the same model above is ## model <- RMgauss(scale=exp()) ## note that however, the following two definitions lead ## to covariance models with fixed scale parameter: ## model <- RMgauss(scale=exp(1)) # fixed to 2.7181 ## model <- RMgauss(scale=exp(x=1)) # fixed to 2.7181 ## here, just two other examples: ## fst model <- RMmatern(nu=unif(min=0.1, max=2)) # random for (i in 1:n) { readline(paste("Simulation no.", i, ": press return", sep="")) plot(RFsimulate(model, x=x, seed=i)) } ## snd, part 1 ## note that the fist 'exp' refers to the exponential function, ## the second to the exponential distribution. (model1 <- RMgauss(var=exp(3), scale=exp(rate=1))) x <- 1:100/10 plot(z1 <- RFsimulate(model=model, x=x)) ## snd, part 2 ## exactly the same result as in the previous example (model2 <- RMgauss(var=exp(3), scale=RRdistr("exp", rate=1))) plot(z2 <- RFsimulate(model=model, x=x)) all.equal(model1, model2)
RRgauss
defines
the d-dimensional vector of independent Gaussian random
variables.
RRgauss(mu, sd, log)
RRgauss(mu, sd, log)
mu , sd , log
|
see Normal. Here, the components can be vectors, leading to multivariate distibution with independent components. |
It has the same effect as
RRdistr(norm(mu=mu, sd=sd, log=log))
.
RRgauss
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Do not mix up RRgauss
with RMgauss
or
RPgauss
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again r <- RFrdistr(RRgauss(mu=c(1,5)), n=1000, dim=2) plot(r[1,], r[2, ])
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again r <- RFrdistr(RRgauss(mu=c(1,5)), n=1000, dim=2) plot(r[1,], r[2, ])
RRloc
modifies location and scale of a distribution.
RRloc(phi, mu, scale, pow)
RRloc(phi, mu, scale, pow)
phi |
distribution |
mu |
location shift |
scale |
scale modification |
pow |
argument for internal use only |
It has the same effect as
RRdistr(norm(mu=mu, sd=sd, log=log))
RRloc
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## empirical density of the distribution 'RRspheric' model <- RRspheric(balldim=2) hist(RFrdistr(model, n=1000), 50) ## empirical density of the distribution 'RRspheric', shifted by 3 model <- RRloc(mu=3, RRspheric(balldim=2)) hist(RFrdistr(model, n=1000), 50)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## empirical density of the distribution 'RRspheric' model <- RRspheric(balldim=2) hist(RFrdistr(model, n=1000), 50) ## empirical density of the distribution 'RRspheric', shifted by 3 model <- RRloc(mu=3, RRspheric(balldim=2)) hist(RFrdistr(model, n=1000), 50)
RRmcmc
draws a random sample from the
modulus of any given function (provided the integral is finite).
RRmcmc(phi, mcmc_n, sigma, normed, maxdensity, rand.loc, gibbs)
RRmcmc(phi, mcmc_n, sigma, normed, maxdensity, rand.loc, gibbs)
phi |
an arbitrary integrable function |
mcmc_n |
positive integer. Every |
sigma |
positive real number.
The MCMC update is done by adding a normal variable with
standard deviation |
normed |
logical.
Only used if the value of the density is calculated.
If Default: |
maxdensity |
positive real number.
The given density is truncated at Default: 1000. |
rand.loc |
logical. Internal. Do not change the value. Default: |
gibbs |
logical. If Default: |
RRmcmc
returns an object of class RMmodel
.
The use of RRmcmc
is completely on the risk of the user. There is no
way to check whether the integral of the modulus is finite.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## here a model with random scale parameter ## not exponential, but the Laplace distribution as symmetry is assumed z <- RFrdistr(RRmcmc(RMexp(), sigma=1), n=10000, cores=1) hist(z, 100, freq=FALSE) curve(0.5 * exp(-abs(x)), add=TRUE, col="blue") ## Laplace distribution
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## here a model with random scale parameter ## not exponential, but the Laplace distribution as symmetry is assumed z <- RFrdistr(RRmcmc(RMexp(), sigma=1), n=10000, cores=1) hist(z, 100, freq=FALSE) curve(0.5 * exp(-abs(x)), add=TRUE, col="blue") ## Laplace distribution
Approximates an isotropic decreasing density function
by a density function that is isotropic with respect to the norm.
RRrectangular(phi, safety, minsteplen, maxsteps, parts, maxit, innermin, outermax, mcmc_n, normed, approx, onesided)
RRrectangular(phi, safety, minsteplen, maxsteps, parts, maxit, innermin, outermax, mcmc_n, normed, approx, onesided)
phi |
a shape function; it is the user's responsibility that it is non-negative. See Details. |
safety , minsteplen , maxsteps , parts , maxit , innermin , outermax , mcmc_n
|
Technical arguments to run an algorithm to simulate from this
distribution. See |
normed |
logical. If |
approx |
logical.
Default is |
onesided |
logical.
Only used for univariate distributions.
If |
This model defines an isotropic density function $f$ with respect to the
norm, i.e.
with some function
.
Here,
is a norming constant so that the integral of
equals one.
In case that is monotonically decreasing then rejection sampling
is used, else MCMC.
The function might have a polynomial pole at the origin
and asymptotical decreasing of the form
.
RRrectangular
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # simulation of Gaussian variables (in a not very straightforward way): distr <- RRrectangular(RMgauss(), approx=FALSE) z <- RFrdistr(distr, n=1000000) hist(z, 200, freq=!TRUE) x <- seq(-10, 10, 0.1) lines(x, dnorm(x, sd=sqrt(0.5))) #creation of random variables whose density is proportional # to the spherical model: distr <- RRrectangular(RMspheric(), approx=FALSE) z <- RFrdistr(distr, n=1000000) hist(z, 200, freq=!TRUE) x <- seq(-10, 10, 0.01) lines(x, 4/3 * RFcov(RMspheric(), x))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again # simulation of Gaussian variables (in a not very straightforward way): distr <- RRrectangular(RMgauss(), approx=FALSE) z <- RFrdistr(distr, n=1000000) hist(z, 200, freq=!TRUE) x <- seq(-10, 10, 0.1) lines(x, dnorm(x, sd=sqrt(0.5))) #creation of random variables whose density is proportional # to the spherical model: distr <- RRrectangular(RMspheric(), approx=FALSE) z <- RFrdistr(distr, n=1000000) hist(z, 200, freq=!TRUE) x <- seq(-10, 10, 0.01) lines(x, 4/3 * RFcov(RMspheric(), x))
This model delivers the distribution
of the radius of a ball
obtained by the
intersection of a balldim
-dimensional ball
with diameter R by a -dimensional
hyperplane that has uniform
distance from the center.
RRspheric(spacedim, balldim, R)
RRspheric(spacedim, balldim, R)
spacedim |
dimension of the hyperplane; defaults to 1. |
balldim |
the dimension of the ball |
R |
radius. Default: 1. |
RRspheric
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again hist(RFrdistr(RRspheric(balldim=2), n=1000), 50)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again hist(RFrdistr(RRspheric(balldim=2), n=1000), 50)
The model refers to the d-dimensional uniform distribution on a rectangular window.
RRunif(min, max, normed)
RRunif(min, max, normed)
min , max
|
lower and upper corner of a rectangular window |
normed |
logical with default value Advanced. If |
In the one-dimensional case it has the same effect as
RRdistr(unif(min=min, max=max, log=log))
.
RRunif
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RMmodel
,
RRdistr
,
RRgauss
,
RRspheric
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## uniform distribution on [0,2] x [-2, -1] RFrdistr(RRunif(c(0, -2), c(2, -1)), n=5, dim=2) RFpdistr(RRunif(c(0, -2), c(2, -1)), q=c(1, -1.5), dim=2) RFddistr(RRunif(c(0, -2), c(2, -1)), x=c(1, -1.5), dim=2)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## uniform distribution on [0,2] x [-2, -1] RFrdistr(RRunif(c(0, -2), c(2, -1)), n=5, dim=2) RFpdistr(RRunif(c(0, -2), c(2, -1)), q=c(1, -1.5), dim=2) RFddistr(RRunif(c(0, -2), c(2, -1)), x=c(1, -1.5), dim=2)
Here, the code of the paper on ‘Models for stationary max-stable random fields’ is given.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (2002) Models for stationary max-stable random fields. Extremes 5, 33-44.
RFoptions(seed=0, xi=1) ## seed = 0 : *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## xi = 0.5: Frechet margins with alpha=2 ## Due to change in the handling the seeds here are different from the ## seeds in the paper. x <- seq(0, 10, length=128) # Fig. 1-4 ## Not run: \dontshow{plot(RFsimulate(RPsmith(RMgauss(s=1.5)), x, x)) # < 1 sec plot(RFsimulate(RPsmith(RMball(s=RRspheric(2, 3, R=3.3))), x, x)) # 30 sec plot(RFsimulate(RPschlather(RMexp()), x, x)) # 1 sec plot(RFsimulate(RPschlather(RMgauss()), x, x)) # 17 sec } ## End(Not run)
RFoptions(seed=0, xi=1) ## seed = 0 : *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## xi = 0.5: Frechet margins with alpha=2 ## Due to change in the handling the seeds here are different from the ## seeds in the paper. x <- seq(0, 10, length=128) # Fig. 1-4 ## Not run: \dontshow{plot(RFsimulate(RPsmith(RMgauss(s=1.5)), x, x)) # < 1 sec plot(RFsimulate(RPsmith(RMball(s=RRspheric(2, 3, R=3.3))), x, x)) # 30 sec plot(RFsimulate(RPschlather(RMexp()), x, x)) # 1 sec plot(RFsimulate(RPschlather(RMgauss()), x, x)) # 17 sec } ## End(Not run)
Here, the code of the paper on ‘On some covariance models based on normal scale mixtures’ is given.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (2010) On some covariance models based on normal scale mixtures. Bernoulli, 16, 780-797.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ### Example 10 in Schlather (2010). ## The field below has more than 80 million points. So the simulation ## takes a while y <- x <- seq(0, 10, len=256) ## currently does not work T <- c(0, 0.02, 1275) col <- c(topo.colors(300)[1:100], cm.colors(300)[c((1:50) * 2, 101:150)]) y <- x <- seq(0, 10, len=5) T <- c(0, 0.02, 4) model <- RMcoxisham(mu=c(1, 1), D=matrix(nr=2, c(1, 0.5, 0.5, 1)), RMwhittle(nu=1)) z <- RFsimulate(model, x, y, T=T, sp_lines=1500, every=10) plot(z, MARGIN.slices=3, col=col) plot(z, MARGIN.movie=3) # add 'file="ci.avi"' to get it stored
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ### Example 10 in Schlather (2010). ## The field below has more than 80 million points. So the simulation ## takes a while y <- x <- seq(0, 10, len=256) ## currently does not work T <- c(0, 0.02, 1275) col <- c(topo.colors(300)[1:100], cm.colors(300)[c((1:50) * 2, 101:150)]) y <- x <- seq(0, 10, len=5) T <- c(0, 0.02, 4) model <- RMcoxisham(mu=c(1, 1), D=matrix(nr=2, c(1, 0.5, 0.5, 1)), RMwhittle(nu=1)) z <- RFsimulate(model, x, y, T=T, sp_lines=1500, every=10) plot(z, MARGIN.slices=3, col=col) plot(z, MARGIN.movie=3) # add 'file="ci.avi"' to get it stored
Here, the code of the paper on ‘On some covariance models based on normal scale mixtures’ is given.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Strokorb, K., Ballani, F. and Schlather, M. (2014) Systematic co-occurrence of tail correlation functions among max-stable processes. Work in progress.
Sequential method relying on square roots of the covariance matrix
RPsequential(phi, boxcox, back_steps, initial)
RPsequential(phi, boxcox, back_steps, initial)
phi |
object of class |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
back_steps |
Number of previous instances on which
the algorithm should condition.
If less than one then the number of previous instances
equals Default: |
initial |
First, N=(number of spatial points) * Default: |
RPsequential
is programmed for spatio-temporal models
where the field is modelled sequentially in the time direction
conditioned on the previous instances.
For
the method has its limits for about 1000 spatial
points. It is an approximative method. The larger
the
better.
It also works for certain grids where the last dimension should
contain the highest number of grid points.
RPsequential
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss(var=10, s=10) + RMnugget(var=0.01) plot(model, xlim=c(-25, 25)) z <- RFsimulate(model=RPsequential(model), 0:10, 0:10, n=4) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss(var=10, s=10) + RMnugget(var=0.01) plot(model, xlim=c(-25, 25)) z <- RFsimulate(model=RPsequential(model), 0:10, 0:10, n=4) plot(z)
RPsmith
defines a moving maximum process or a mixed moving
maximum process with finite number of shape functions.
RPsmith(shape, tcf, xi, mu, s)
RPsmith(shape, tcf, xi, mu, s)
shape |
an |
tcf |
an |
xi , mu , s
|
the extreme value index, the location parameter and the scale parameter, respectively, of the generalized extreme value distribution. See Details. |
The argument xi
is always a number, i.e. is constant in space. In contrast,
and
might be constant numerical values or (in future!) be given by an
RMmodel
, in particular by an RMtrend
model.
For , the default values of
and
are
and
, respectively. For
, the default values of
and
are
and
, respectively, so that it defaults to the standard Frechet case if
.
It simulates max-stable processes that are referred to as
“Smith model”.
where are the points of a Poisson point process on
with intensity
and
are iid measurable
random functions with
.
The constant
is chosen such that
has standard Frechet
margins.
IMPORTANT: For consistency reasons with the geostatistical definitions in this package the scale argument differs froms the original definition of the Smith model! See the example below.
RPsmith
depends on RRrectangular
and its arguments.
Advanced options
are maxpoints
and max_gauss
, see
RFoptions
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Haan, L. (1984) A spectral representation for max-stable processes. Ann. Probab., 12, 1194-1204.
Smith, R.L. (1990) Max-stable processes and spatial extremes Unpublished Manuscript.
Advanced RMmodels
,
Auxiliary RMmodels
,
RMmodel
,
RPbernoulli
,
RPgauss
,
maxstable,
maxstableAdvanced
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMball() x <- seq(0, 1000, 0.2) z <- RFsimulate(RPsmith(model, xi=0), x) plot(z) hist(z@data$variable1, 50, freq=FALSE) curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE) ## 2-dim x <- seq(0, 10, 0.1) z <- RFsimulate(RPsmith(model, xi=0), x, x) plot(z) ## original Smith model x <- seq(0, 10, 0.05) model <- RMgauss(scale = sqrt(2)) # !! cf. definition of RMgauss z <- RFsimulate(RPsmith(model, xi=0), x, x) plot(z) ## for some more sophisticated models see 'maxstableAdvanced'
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMball() x <- seq(0, 1000, 0.2) z <- RFsimulate(RPsmith(model, xi=0), x) plot(z) hist(z@data$variable1, 50, freq=FALSE) curve(exp(-x) * exp(-exp(-x)), from=-3, to=8, add=TRUE) ## 2-dim x <- seq(0, 10, 0.1) z <- RFsimulate(RPsmith(model, xi=0), x, x) plot(z) ## original Smith model x <- seq(0, 10, 0.05) model <- RMgauss(scale = sqrt(2)) # !! cf. definition of RMgauss z <- RFsimulate(RPsmith(model, xi=0), x, x) plot(z) ## for some more sophisticated models see 'maxstableAdvanced'
Soil physical and chemical data collected on a field in the Weissenstaedter Becken, Germany
data(soil)
data(soil)
This data frame contains the following columns:
x coordinates given in cm
y coordinates given in cm
number of the samples, which were taken in this order
moisture content [Kg/Kg * 100%]
nitrate nitrogen [mg/Kg]
total nitrogen [mg/Kg]
ammonium nitrogen [mg/Kg]
dissolved organic carbon [mg/Kg]
nitrous oxide [mg/Kg dried substance]
For technical reasons some of the data were obtained as differences of two measurements (which are not available anymore). Therefore, some of the data have negative values.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
The data were collected by Wolfgang Falk, Soil Physics Group, University of Bayreuth, Germany.
Falk, W. (2000) Kleinskalige raeumliche Variabilitaet von Lachgas und bodenchemischen Parameters [Small Scale Spatial Variability of Nitrous Oxide and Pedo-Chemical Parameters], Master thesis, University of Bayreuth, Germany.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ################################################################ ## ## ## a geostatistical analysis that demonstrates ## ## features of the package 'RandomFields' ## ## ## ################################################################ data(soil) str(soil) soil <- RFspatialPointsDataFrame( coords = soil[ , c("x.coord", "y.coord")], data = soil[ , c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] ## plot the data first colour <- rainbow(100) plot(dta, col=colour) ## fit by eye gui.model <- RFgui(dta) ## fit by ML model <- ~1 + RMwhittle(scale=NA, var=NA, nu=NA) + RMnugget(var=NA) (fit <- RFfit(model, data=dta)) plot(fit, method=c("ml", "plain", "sqrt.nr", "sd.inv"), model = gui.model, col=1:8) ## Kriging ... x <- seq(min(dta@coords[, 1]), max(dta@coords[, 1]), l=121) k <- RFinterpolate(fit, x=x, y=x, data=dta) plot(x=k, col=colour) plot(x=k, y=dta, col=colour) ## what is the probability that at no point of the ## grid given by x and y the moisture is greater than 24 percent? cs <- RFsimulate(model=fit@ml, x=x, y=x, data=dta, n=50) plot(cs, col=colour) plot(cs, y=dta, col=colour) Print(mean(apply(as.array(cs) <= 24, 3, all))) ## about 40 percent ...
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ################################################################ ## ## ## a geostatistical analysis that demonstrates ## ## features of the package 'RandomFields' ## ## ## ################################################################ data(soil) str(soil) soil <- RFspatialPointsDataFrame( coords = soil[ , c("x.coord", "y.coord")], data = soil[ , c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] ## plot the data first colour <- rainbow(100) plot(dta, col=colour) ## fit by eye gui.model <- RFgui(dta) ## fit by ML model <- ~1 + RMwhittle(scale=NA, var=NA, nu=NA) + RMnugget(var=NA) (fit <- RFfit(model, data=dta)) plot(fit, method=c("ml", "plain", "sqrt.nr", "sd.inv"), model = gui.model, col=1:8) ## Kriging ... x <- seq(min(dta@coords[, 1]), max(dta@coords[, 1]), l=121) k <- RFinterpolate(fit, x=x, y=x, data=dta) plot(x=k, col=colour) plot(x=k, y=dta, col=colour) ## what is the probability that at no point of the ## grid given by x and y the moisture is greater than 24 percent? cs <- RFsimulate(model=fit@ml, x=x, y=x, data=dta, n=50) plot(cs, col=colour) plot(cs, y=dta, col=colour) Print(mean(apply(as.array(cs) <= 24, 3, all))) ## about 40 percent ...
The function transforms an 'sp' object to an 'RFsp' object.
This explicit transformation is only necessary if several variables and repeated measurements are given.
sp2RF(sp, param=list(n=1, vdim=1))
sp2RF(sp, param=list(n=1, vdim=1))
sp |
an ‘sp’ object |
param |
|
sp2RF
returns an object of class
RFsp
.
The two options varnames
and coordnames
,
cf. section ‘coords’ in RFoptions
,
might be useful.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again p <- 100 n <- 5 x <- runif(p, 0, 1) y <- runif(p, 0, 1) z <- RFsimulate(RMexp(), x=x, y=y, n=n) z1 <- z2 <- as.data.frame(z) coordinates(z2) <- ~coords.x1 + coords.x2 (emp.var <- RFvariogram(data=z)) (emp.var1 <- RFvariogram(data=z1)) (emp.var2 <- RFvariogram(data=sp2RF(z2, param=list(n=n, vdim=1)))) stopifnot(all.equal(emp.var, emp.var1)) stopifnot(all.equal(emp.var, emp.var2))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again p <- 100 n <- 5 x <- runif(p, 0, 1) y <- runif(p, 0, 1) z <- RFsimulate(RMexp(), x=x, y=y, n=n) z1 <- z2 <- as.data.frame(z) coordinates(z2) <- ~coords.x1 + coords.x2 (emp.var <- RFvariogram(data=z)) (emp.var1 <- RFvariogram(data=z1)) (emp.var2 <- RFvariogram(data=sp2RF(z2, param=list(n=n, vdim=1)))) stopifnot(all.equal(emp.var, emp.var1)) stopifnot(all.equal(emp.var, emp.var2))
This model determines that the (Gaussian) random field should be modelled by a particular method that is specific to the given covariance model.
RPspecific(phi, boxcox)
RPspecific(phi, boxcox)
phi |
object of class |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
RPspecific
is used for specific algorithms or specific features
for simulating certain covariance functions.
RMplus
is able to simulate separately
the fields given by its summands. This is necessary, e.g., when
a trend model RMtrend
is involved.
RMmult
for Gaussian random fields only.
RMmult
simulates the random fields
of all the components and multiplies them. This is repeated
several times and averaged.
RMS
Then, for instance,
sqrt(var)
is multiplied onto the (Gaussian) random
field after the field has been simulated.
Hence, when var
is random, then for each realization
of the Gaussian field (for n>1
in RFsimulate
)
a new realization of var
is used.
Further, new coordinates are created where the old coordinates
have been divided by the scale
and/or multiplied with the
Aniso
matrix or a proj
ection has been performed.
RPspecific(RMS())
is called internally when
the user wants to simulate Aniso
tropic fields with
isotropic methods, e.g. RPtbm
.
Note that RPspecific
applies only to the first model or
operator in the argument phi
.
RPspecific
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## example for implicit use model <- RMgauss(var=10, s=10) + RMnugget(var=0.1) plot(model) plot(RFsimulate(model=model, 0:10, 0:10, n=4)) ## The following function shows the internal structure of the model. ## In particular, it can be seen that RPspecific is applied to RMplus. RFgetModelInfo(level=0, which="internal") ## example for explicit use: every simulation has a different variance model <- RPspecific(RMS(var=unif(min=0, max=100), RMgauss())) x <- seq(0,50,0.02) plot(RFsimulate(model, x=x, n=4), ylim=c(-15,15))
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## example for implicit use model <- RMgauss(var=10, s=10) + RMnugget(var=0.1) plot(model) plot(RFsimulate(model=model, 0:10, 0:10, n=4)) ## The following function shows the internal structure of the model. ## In particular, it can be seen that RPspecific is applied to RMplus. RFgetModelInfo(level=0, which="internal") ## example for explicit use: every simulation has a different variance model <- RPspecific(RMS(var=unif(min=0, max=100), RMgauss())) x <- seq(0,50,0.02) plot(RFsimulate(model, x=x, n=4), ylim=c(-15,15))
The spectral turning bands method is
a simulation method for stationary
Gaussian random fields (Mantoglou and Wilson, 1982).
It makes use of
Bochners's theorem and the corresponding spectral measure
for a given covariance function
. For
,
the field
with and
is a random field with
covariance function
.
A scaled superposition of many independent realizations of
gives a Gaussian field according to the central limit theorem. For details
see Lantuejoul (2002). The standard method
allows for the simulation of 2-dimensional random
fields defined on arbitrary points or arbitrary grids.
RPspectral(phi, boxcox, sp_lines, sp_grid, prop_factor, sigma)
RPspectral(phi, boxcox, sp_lines, sp_grid, prop_factor, sigma)
phi |
object of class |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
sp_lines |
Number of lines used (in total for all additive components of the covariance function). Default: |
sp_grid |
Logical.
The angle of the lines is random if
Default: |
prop_factor |
positive real value.
Sometimes, the spectral density must be sampled by MCMC.
Let Default: |
sigma |
real. Considered if the Metropolis
algorithm is used. It gives the standard deviation of the
multivariate normal distribution of the proposing
distribution.
If Default: |
RPspectral
returns an object of class
RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Lantuejoul, C. (2002) Geostatistical Simulation: Models and Algorithms. Springer.
Mantoglou, A. and J. L. Wilson (1982), The Turning Bands Method for simulation of random fields using line generation by a spectral method. Water Resour. Res., 18(5), 1379-1394.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPspectral(RMmatern(nu=1)) y <- x <- seq(0,10, len=400) z <- RFsimulate(model, x, y, n=2) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RPspectral(RMmatern(nu=1)) y <- x <- seq(0,10, len=400) z <- RFsimulate(model, x, y, n=2) plot(z)
This page summarizes the covariance models that can be used for spherical coordinates (and earth coordinates).
The following models are available:
Completely monotone functions allowing for arbitrary scale
RMbcw |
Model bridging stationary and
intrinsically stationary processes for
and
|
RMcubic |
cubic model |
RMdagum |
Dagum model with
and
|
RMexp |
exponential model |
RMgencauchy |
generalized Cauchy family with
(and arbitrary ) |
RMmatern |
Whittle-Matern model with
|
RMstable |
symmetric stable family or powered
exponential model with
|
RMwhittle |
Whittle-Matern model, alternative
parametrization with
|
Other isotropic models with arbitrary scale
RMconstant |
spatially constant model |
RMnugget |
nugget effect model |
Compactly supported covariance functions allowing for scales up to
(or
degrees)
RMaskey |
Askey's model |
RMcircular |
circular model |
RMgengneiting |
Wendland-Gneiting model; differentiable models with compact support |
RMgneiting |
differentiable model with compact support |
RMspheric |
spherical model |
Anisotropic models
None up to now. |
Basic Operators
RMmult , * |
product of covariance models |
RMplus , + |
sum of covariance models or variograms |
See RMmodels for cartesian models.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
coordinate systems,
RMmodels
,
RMtrafo
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames(isotropy=c("spherical isotropic")) ## an example of a simple model valid on a sphere model <- RMexp(var=1.6, scale=0.5) + RMnugget(var=0) #exponential + nugget plot(model) ## a simple simulation l <- seq(0, 85, 1.2) coord <- cbind(lon=l, lat=l) z <- RFsimulate(RMwhittle(s=30, nu=0.45), coord, grid=TRUE) # takes 1 min plot(z) z <- RFsimulate(RMwhittle(s=500, nu=0.5), coord, grid=TRUE, new_coord_sys="orthographic", zenit=c(25, 25)) plot(z) z <- RFsimulate(RMwhittle(s=500, nu=0.5), coord, grid=TRUE, new_coord_sys="gnomonic", zenit=c(25, 25)) plot(z) ## space-time modelling on the sphere sigma <- 5 * sqrt((R.lat()-30)^2 + (R.lon()-20)^2) model <- RMprod(sigma) * RMtrafo(RMexp(s=500, proj="space"), "cartesian") * RMspheric(proj="time") z <- RFsimulate(model, 0:10, 10:20, T=seq(0, 1, 0.1), coord_system="earth", new_coordunits="km") plot(z, MARGIN.slices=3)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames(isotropy=c("spherical isotropic")) ## an example of a simple model valid on a sphere model <- RMexp(var=1.6, scale=0.5) + RMnugget(var=0) #exponential + nugget plot(model) ## a simple simulation l <- seq(0, 85, 1.2) coord <- cbind(lon=l, lat=l) z <- RFsimulate(RMwhittle(s=30, nu=0.45), coord, grid=TRUE) # takes 1 min plot(z) z <- RFsimulate(RMwhittle(s=500, nu=0.5), coord, grid=TRUE, new_coord_sys="orthographic", zenit=c(25, 25)) plot(z) z <- RFsimulate(RMwhittle(s=500, nu=0.5), coord, grid=TRUE, new_coord_sys="gnomonic", zenit=c(25, 25)) plot(z) ## space-time modelling on the sphere sigma <- 5 * sqrt((R.lat()-30)^2 + (R.lon()-20)^2) model <- RMprod(sigma) * RMtrafo(RMexp(s=500, proj="space"), "cartesian") * RMspheric(proj="time") z <- RFsimulate(model, 0:10, 10:20, T=seq(0, 1, 0.1), coord_system="earth", new_coordunits="km") plot(z, MARGIN.slices=3)
Methods relying on square roots of the covariance matrix
RPdirect(phi, boxcox)
RPdirect(phi, boxcox)
phi |
object of class |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
RPdirect
is based on the well-known method for simulating
any multivariate Gaussian distribution, using the square root of the
covariance matrix. The method is pretty slow and limited to
about 12000 points, i.e. a 20x20x20 grid in three dimensions.
This implementation can use the Cholesky decomposition and
the singular value decomposition.
It allows for arbitrary points and arbitrary grids.
RPdirect
returns an object of class RMmodel
.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss(var=10, s=10) + RMnugget(var=0.01) plot(model, xlim=c(-25, 25)) z <- RFsimulate(model=RPdirect(model), 0:10, 0:10, n=4) plot(z)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMgauss(var=10, s=10) + RMnugget(var=0.01) plot(model, xlim=c(-25, 25)) z <- RFsimulate(model=RPdirect(model), 0:10, 0:10, n=4) plot(z)
Here, the code of the paper on ‘Covariance Models for Random Vector Fields’ is given.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Scheuerer, M. and Schlather, M. (2012) Covariance Models for Random Vector Fields. Stochastic Models, 82, 433-451.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again
The models define various shape functions for max-stable processes for a given tail correlation function.
RMm2r(phi) RMm3b(phi) RMmps(phi)
RMm2r(phi) RMm3b(phi) RMmps(phi)
phi |
a model for a tail correlation function belonging to the
Gneiting class |
RMm2r
used with RPsmith
defines
a monotone shape function that corresponds to a tail correlation
function belonging to Gneiting's class . Currently, the
function is implemented for dimensions 1 and 3.
Called as such it returns the corresponding monotone function.
RMm3b
used with RPsmith
defines
balls with random radius that corresponds to a tail correlation
function belonging to Gneiting's class . Currently, the
function is implemented for dimensions 1 and 3.
(Note that in Strokorb et al. (2014) the density function for twice
the radius is considered.)
Called as such it returns the corresponding density function for the
radius of the balls.
RMmps
used with RPsmith
defines
random hyperplane polygons
that correspond to a tail correlaton
function belonging to Gneiting's class .
It currently only allows for
RMbrownresnick(RMfbm(alpha=1))
and dimension 2.
Called as such it returns the tcf defined by the submodel – this
definition may change in future.
object of class RMmodel
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Strokorb, K. (2013) Properties of the Extremal Coefficient Functions. Univ. Goettingen. PhD thesis.
Strokorb, K., Ballani, F. and Schlather, M. (2014) In Preparation.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbrownresnick(RMfbm(alpha=1.5, s=0.2)) plot(RMm2r(model)) x <- seq(0, 10, 0.005) z <- RFsimulate(RPsmith(RMm2r(model), xi=0), x) plot(z, type="p", pch=20)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again model <- RMbrownresnick(RMfbm(alpha=1.5, s=0.2)) plot(RMm2r(model)) x <- seq(0, 10, 0.005) z <- RFsimulate(RPsmith(RMm2r(model), xi=0), x) plot(z, type="p", pch=20)
This page summarizes the models that can be used for tail correlation functions.
The following models are available:
Completely monotone functions allowing for arbitrary scale
RMbcw |
Model bridging stationary and
intrinsically stationary processes for alpha <= 1
and beta < 0
|
RMdagum |
Dagum model with
and
|
RMexp |
exponential model |
RMgencauchy |
generalized Cauchy family with
(and arbitrary ) |
RMmatern |
Whittle-Matern model with
|
RMstable |
symmetric stable family or powered
exponential model with
|
RMwhittle |
Whittle-Matern model, alternative
parametrization with
|
Other isotropic models with arbitrary scale
RMnugget |
nugget effect model |
Compactly supported covariance functions
RMaskey |
Askey's model |
RMcircular |
circular model |
RMconstant
|
identically constant |
RMcubic |
cubic model |
RMgengneiting |
Wendland-Gneiting model; differentiable models with compact support |
RMgneiting |
differentiable model with compact support |
RMspheric |
spherical model |
Anisotropic models
None up to now. |
Basic Operators
RMmult , * |
product of covariance models |
RMplus , + |
sum of covariance models or variograms |
Operators related to process constructions
RMbernoulli |
correlation of binary fields |
RMbrownresnick
|
tcf of a Brown-Resnick process |
RMschlather
|
tcf of an extremal Gaussian process / Schlather process |
RMm2r
|
M2 process with monotone shape function |
RMm3b
|
M3 process with balls of random radius |
RMmps
|
M3 process with hyperplane polygons |
See RMmodels for cartesian models.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Strokorb, K., Ballani, F., and Schlather, M. (2015) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, 18, 241-271
coordinate systems,
RM,
RMmodels
,
RMtrafo
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames(type="tail") ## an example of a simple model model <- RMexp(var=1.6, scale=0.5) + RMnugget(var=0) #exponential + nugget plot(model)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again RFgetModelNames(type="tail") ## an example of a simple model model <- RMexp(var=1.6, scale=0.5) + RMnugget(var=0) #exponential + nugget plot(model)
The Turning Bands method is a simulation method for stationary, isotropic
(univariate or multivariate)
random fields in any dimension and defined on arbitrary points or
arbitrary grids. It performs a multidimensional simulation
by superposing lower-dimensional fields. In fact, the Turning Bands
method is called with the Turning Bands model, see
RMtbm
.
For details see RMtbm
.
RPtbm(phi, boxcox, fulldim, reduceddim, layers, lines, linessimufactor, linesimustep, center, points)
RPtbm(phi, boxcox, fulldim, reduceddim, layers, lines, linessimufactor, linesimustep, center, points)
phi |
object of class |
boxcox |
the one or two parameters of the box cox transformation.
If not given, the globally defined parameters are used.
See |
fulldim |
a positive integer. The dimension of the space of the random field to be simulated. |
reduceddim |
a positive integer; less than |
layers |
a boolean value; for space-time model. If Default: |
lines |
Number of lines used.
Default: |
linessimufactor |
Default: |
linesimustep |
If Default: |
center |
Scalar or vector.
If not Default: |
points |
integer. If greater than 0,
Default: |
2-dimensional case
It is generally difficult to use the turning bands method
(RPtbm
) directly in the 2-dimensional space.
Instead, 2-dimensional random fields are frequently obtained
by simulating a 3-dimensional random field (using
RPtbm
) and taking a 2-dimensional cross-section.
See also the arguments fulldim
and reduceddim
.
4-dimensional case
The turning layers can be used for the simulations with a (formal)
time component. It works for all isotropic models,
some special models such as RMnsst
, and
multiplicative models that separate the time component.
RPtbm
returns an object of class RMmodel
.
Both the precision and the simulation time
depend heavily on linesimustep
and
linessimufactor
.
For covariance models with larger values of the scale parameter,
linessimufactor=2
is too small.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
Turning bands
Lantuejoul, C. (2002) Geostatistical Simulation: Models and Algorithms. Springer.
Matheron, G. (1973). The intrinsic random functions and their applications. Adv. Appl. Probab., 5, 439-468.
Strokorb, K., Ballani, F., and Schlather, M. (2014) Tail correlation functions of max-stable processes: Construction principles, recovery and diversity of some mixing max-stable processes with identical TCF. Extremes, Submitted.
Turning layers
Schlather, M. (2011) Construction of covariance functions and unconditional simulation of random fields. In Porcu, E., Montero, J.M. and Schlather, M., Space-Time Processes and Challenges Related to Environmental Problems. New York: Springer.
Gaussian,
RP,
RPspectral
.
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## isotropic example that forces the use of the turning bands method model <- RPtbm(RMstable(s=1, alpha=1.8)) x <- seq(-3, 3, 0.1) z <- RFsimulate(model=model, x=x, y=x) plot(z) ## anisotropic example that forces the use of the turning bands method model <- RPtbm(RMexp(Aniso=matrix(nc=2, rep(1,4)))) z <- RFsimulate(model=model, x=x, y=x) plot(z) ## isotropic example that uses the turning layers method model <- RMgneiting(orig=FALSE, scale=0.4) x <- seq(0, 10, 0.1) z <- RFsimulate(model, x=x, y=x, z=x, T=c(1,1,5)) plot(z, MARGIN.slices=4, MARGIN.movie=3)
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## isotropic example that forces the use of the turning bands method model <- RPtbm(RMstable(s=1, alpha=1.8)) x <- seq(-3, 3, 0.1) z <- RFsimulate(model=model, x=x, y=x) plot(z) ## anisotropic example that forces the use of the turning bands method model <- RPtbm(RMexp(Aniso=matrix(nc=2, rep(1,4)))) z <- RFsimulate(model=model, x=x, y=x) plot(z) ## isotropic example that uses the turning layers method model <- RMgneiting(orig=FALSE, scale=0.4) x <- seq(0, 10, 0.1) z <- RFsimulate(model, x=x, y=x, z=x, T=c(1,1,5)) plot(z, MARGIN.slices=4, MARGIN.movie=3)
The coding of trends, in particular multivariate trends, will be described here.
See RFcalc, RMtrend and also the examples below for some insight on the possibilities of trend modelling.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
RFcalc, RM, RMmodels, RMtrend, RMmodelsMultivariate.
data(ca20) ## data set originally from geoR head(ca20.df) RFoptions(coordnames=c("east", "north"), varnames="data") ## covariance model with variance, scale and nugget to be estimated; ## just to abbreviate later on M <- RMexp(var=NA, scale=NA) + RMnugget(var=NA) ## short definition of a trend using the fact that ca20.df is a ## data.frame ca20.RFmod02 <- ~ 1 + altitude + M (ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df, M=M)) ## long definition which also allows for more general constructions ca20.RFmod02 <- NA + NA*RMcovariate(ca20.df$altitude) + M (ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df)) ## Not run: ## Note that the following also works. ## Here, the covariance model must be the first summand ca20.RFmod02 <- M + NA + ca20.df$altitude print(ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df)) ### The following does NOT work, as R assumes (NA + ca20.df$altitude) + M ### In particular, the model definition gives a warning, and the ### RFfit call gives an error: (ca20.RFmod02 <- NA + ca20.df$altitude + M) try(ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df)) ### error ... ## factors: ca20.RFmod03 <- ~ 1 + area + M ### (ca20.fit03.RF <- RFfit(ca20.RFmod03, data=ca20.df, M=M)) ## End(Not run)
data(ca20) ## data set originally from geoR head(ca20.df) RFoptions(coordnames=c("east", "north"), varnames="data") ## covariance model with variance, scale and nugget to be estimated; ## just to abbreviate later on M <- RMexp(var=NA, scale=NA) + RMnugget(var=NA) ## short definition of a trend using the fact that ca20.df is a ## data.frame ca20.RFmod02 <- ~ 1 + altitude + M (ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df, M=M)) ## long definition which also allows for more general constructions ca20.RFmod02 <- NA + NA*RMcovariate(ca20.df$altitude) + M (ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df)) ## Not run: ## Note that the following also works. ## Here, the covariance model must be the first summand ca20.RFmod02 <- M + NA + ca20.df$altitude print(ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df)) ### The following does NOT work, as R assumes (NA + ca20.df$altitude) + M ### In particular, the model definition gives a warning, and the ### RFfit call gives an error: (ca20.RFmod02 <- NA + ca20.df$altitude + M) try(ca20.fit02.RF <- RFfit(ca20.RFmod02, data=ca20.df)) ### error ... ## factors: ca20.RFmod03 <- ~ 1 + area + M ### (ca20.fit03.RF <- RFfit(ca20.RFmod03, data=ca20.df, M=M)) ## End(Not run)
Meteorological dataset, which consists of differences between forecasts and observations (forecasts minus observations) of temperature and pressure at 157 locations in the North American Pacific Northwest.
data(weather)
data(weather)
The data frame weather
contains the following columns:
in units of Pascal
in units of degree Celcius
longitudinal coordinates of the locations
latitude coordinates of the locations
Furthermore, some results obtained from the data analysis in
jss14
are delivered that are
pars.model
, pars
, whole.model
, whole
.
Finally, the variable information
contains packing information
(the date and the version of RandomFields).
The forecasts are from the GFS member of the University of Washington regional numerical weather prediction ensemble (UWME; Grimit and Mass 2002; Eckel and Mass 2005); they were valid on December 18, 2003 at 4 pm local time, at a forecast horizon of 48 hours.
Martin Schlather, [email protected], https://www.wim.uni-mannheim.de/schlather/
The data were obtained from Cliff Mass and Jeff Baars from the University of Washington Department of Atmospheric Sciences.
Eckel, A. F. and Mass, C. F. (2005) Aspects of effective mesoscale, short-range ensemble forecasting Wea. Forecasting 20, 328-350.
Gneiting, T., Kleiber, W. and Schlather, M. (2010) Matern cross-covariance functions for multivariate random fields J. Amer. Statist. Assoc. 105, 1167-1177.
Grimit, E. P. and Mass, C. F. (2002) Initial results of a mesoscale short-range forecasting system over the Pacific Northwest Wea. Forecasting 17, 192-205.
A reanalysis has been performed in Section 5 of the jss14 paper.
## See 'jss14'.
## See 'jss14'.