Last data update: 2014.03.03

R: Methods relying on square roots of the covariance matrix
Square rootsR Documentation

Methods relying on square roots of the covariance matrix

Description

Methods relying on square roots of the covariance matrix

Usage

RPdirect(phi, boxcox, max_variab) 

RPsequential(phi, boxcox, max_variables, back_steps, initial)

Arguments

phi

object of class RMmodel; specifies the covariance model to be simulated.

boxcox

the one or two parameters of the box cox transformation. If not given, the globally defined parameters are used. see RFboxcox for Details.

max_variab

integer less than 30000. If the number of variables to generate is greater than max_variab, neither SVD nor Cholesky decomposition are performed. If the given covariance structure has finite range and use_spam != false then spam is tried.

It is important that this option is set conveniently to avoid great losses of time during the internal search of an appropriate method by RPgauss.

Default: 8192

max_variables

The maximum size of the conditional covariance matrix (default to 5000)

back_steps

Number of previous instances on which the algorithm should condition. If less than one then the number of previous instances equals max / (number of spatial points).

Default: 10 .

initial

First, N=(number of spatial points) * back_steps number of points are simulated. Then, sequentially, all spatial points for the next time instance are simulated at once, based on the previous back_steps instances. The distribution of the first N points is the correct distribution, but differs, in general, from the distribution of the sequentially simulated variables. We prefer here to have the same distribution all over (although only approximatively the correct one), hence do some initial sequential steps first. If initial is non-negative, then initial first steps are performed. If initial is negative, then back_steps - initial initial steps are performed. The latter ensures that none of the very first N variables are returned.

Default: -10 .

Details

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

RPsequential is programmed for spatio-temporal models where the field is modelled sequentially in the time direction conditioned on the previous k instances. For k=5 the method has its limits for about 1000 spatial points. It is an approximative method. The larger k the better. It also works for certain grids where the last dimension should contain the highest number of grid points.

Value

RPsequential returns an object of class RMmodel

Author(s)

Martin Schlather, schlather@math.uni-mannheim.de

References

  • 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 Also

Gaussian, RP,

Examples

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)


Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(RandomFields)
Loading required package: sp
Loading required package: RandomFieldsUtils
This is RandomFieldsUtils Version: 0.2.1
This is RandomFields Version: 3.1.16

Attaching package: 'RandomFields'

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

    RFoptions

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

    abs, acosh, asin, asinh, atan, atan2, atanh, cos, cosh, exp, expm1,
    floor, gamma, lgamma, log, log1p, log2, logb, max, min, round, sin,
    sinh, sqrt, tan, tanh, trunc

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RandomFields/RPsequential.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Square roots
> ### Title: Methods relying on square roots of the covariance matrix
> ### Aliases: Direct RPdirect Sequential RPsequential
> ### Keywords: methods
> 
> ### ** Examples
> 
> 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))
NULL
> 
> z <- RFsimulate(model=RPdirect(model), 0:10, 0:10, n=4)
NOTE: simulation is performed with fixed random seed 0.
Set 'RFoptions(seed=NA)' to make the seed arbitrary.
....
New output format of RFsimulate: S4 object of class 'RFsp';
for a bare, but faster array format use 'RFoptions(spConform=FALSE)'.
> plot(z)
> 
> ## Don't show: 
> FinalizeExample()
> ## End(Don't show)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>