Learn R Programming

RandomFields (version 3.0.10)

RFoptions: Setting control parameters

Description

RFoptions sets and returns control parameters for the analysis and the simulation of random fields

Usage

RFoptions(..., no.readonly = TRUE)

Arguments

...
arguments in tag = value form, or a list of tagged values.
no.readonly
If RFoptions is called without parameter then all parameters are returned in a list. If no.readonly=TRUE then only rewritable parameters are returned.

Value

  • NULL if any parameter is given, and the full list of parameters, otherwise.

    if no.readonly=FALSE then additionally, the last element of the list is itself a list containing * covnr: number of currently implemented variogram/covariance models (-1 means that none of the functions like RFsimulate, RFfit , etc., have been called yet.) * distrmaxchar: max. name length for a distribution * distrnr: number of currently implemented distributions * maxdim: maximum number of dimensions for a random field * maxmodels: maximum number of elementary models in definition of a complex covariance model * methodmaxchar: max. name length for methods * methodnr: number of currently implemented simulation methods

bold

16. Options for calculating the empirical variogram

Details

The subsections below comment on options for 1. General options 2. Gaussian random field simulation (RFsimulate) 3. Kriging (RFinterpolate) 4. Circulant embedding methods RPcirculant, RPcutoff, RPintrinsic 5. Matrix decomposition RPdirect 6. Nugget effect RPnugget 7. Sequential method RPsequential 8. Spectral (turning bands) method RPspectral 9. Turning band RPtbm 10. Random coins (shot noise) RPcoins, RPaverage 11. Hyperplane tessellations RPhyperplane 12. Max-stable random fields (RFsimulate) 13. BRmethods 14. RRrectangular 15. RFfit, RFratiotest 16. RFempiricalvariogram 17. RFgui 18. Graphics 19. Warnings and messages General comments 1. General options [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] 2. Gaussian random field simulation

[object Object],[object Object],[object Object],[object Object],[object Object]

3. Options for Kriging [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] 4. Options for simulating with the standard circulant embedding method, including cutoff, intrinsic [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] 5. Options for simulating by simple matrix decomposition [object Object],[object Object],[object Object] 6. Options for simulating nugget effects 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. [object Object] 7. Options for using the sequential method [object Object],[object Object],[object Object] 8. Options for simulating with spectral (turning bands) method [object Object],[object Object],[object Object],[object Object],[object Object] 9. Options for simulating with a turning bands method [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] 10. Options for simulating by random coins (shot noise) [object Object],[object Object],[object Object] 11. Options for simulating hyperplane tessellations [object Object],[object Object],[object Object],[object Object] 12. Options specific to simulating max-stable random fields [object Object],[object Object],[object Object],[object Object],[object Object],[object Object] 13. Specific method options for Brown-Resnick Fields [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] 14. Technical options for RRrectangular [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] 15. Options for RFfit and RFratiotest The following comments on RFfit apply also to RFratiotest.

[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Default: 'respect bound'. shortnamelength{ The names of the variables in the returned table are abbreviated by taking the first shortnamelength letters.

Default: 4. } use_spam{ Should the package spam (sparse matrices) be used for matrix calculations? Default: NA. } split{logical. If TRUE 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: TRUE. } scale_ratio{ RFfit uses parscale and fnscale in the calls of optim. As these parameters 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. } 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 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< code=""> then none of the refined methods are performed. Default: TRUE. }

n_crit{integer. The approximate profiles that are considered. Default: 10. } max_neighbours{integer. Maximum number of locations (with depending values) that are allowed. Default: 5000. } splitn_neighbours{integer. In case the maximum number of locations maxn is exceeded, then RFfit tries to split the data set into parts of size split or less, but never more than maxn. Default: c(3000, 200, 1000). } splitfactor_neighbours{Default: 2. } smalldataset{ Default: 2000. } min_diag{ Default: 1e-7. }

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. } optimiser{Default: 0. } algorithm{ Default: -1. }

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

RFsimulate, RandomFields, and RFgetMethodNames.

Examples

Run this code
RFoptions(seed=0)
RFoptions(storing=TRUE)
str(RFoptions())


############################################################
## ##
## use of exactness ##
## ## 
############################################################
x <- seq(0, 1, if (interactive()) 1/30 else 0.5)
model <- RMgauss()

for (exactness in c(NA, FALSE, TRUE)) { 
  readline(paste("exactness: `", exactness, "'; press return"))
  z <- RFsimulate(model, x, x, grid=TRUE, exactness=exactness,
                  stationary_only=NA, storing=TRUE)
  Print(RFgetModelInfo(which="keys")$key$name)
}


\dontrun{
 #############################################################
 ## The following gives a tiny example on the advantage of  ##
 ## local.dependent=TRUE (and dependent=TRUE) 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 independentent repetitions ##
 ## and 2*n locally dependent 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

x <- seq(0, 1, len=10)
y <- seq(0, 1, len=10)
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)))
#(RMmodel(matrix(c(1, -1), ncol=2), model=model)) 

m <- if (interactive()) 100 else 2
n <- if (interactive()) 100 else 10

# using local.dependent=FALSE (which is the default)
c1 <- numeric(m)
time <- unix.time(
  for (i in 1:m) {
    cat("", i)
    z <- RFsimulate(meth(model), x, y, grid=TRUE, n=n, pch="", 
                    dependent=FALSE, spConform=FALSE, trials=5)
    c1[i] <- cov(z[1,length(y), ], z[length(x), 1, ])
}) # many times slower than with local.dependent=TRUE below
Print(time, mean(c1), sd(c1))

# using local.dependent=TRUE...
c2 <- numeric(m)
time <- unix.time(
  for (i in 1:m) {
    cat("", i)
    z <- RFsimulate(meth(model), x, y, grid=TRUE, n=2 * n, pch="", 
                    dependent=TRUE, spConform=FALSE, trials=5)
    c2[i] <- cov(z[1,length(y),], z[length(x), 1 , ])
})
Print(time, mean(c2), sd(c2))
# the sd is samller (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.
}



\dontrun{
############################################################
## ##
## use of points and center ##
## ##
############################################################
## The following example shows that the same realisation 
## can be obtained on different grid geometries (or point 
## configurations, i.e. grid, non-grid) using TBM3 (or TBM2)



x1 <- seq(-150,150,1)
y1 <- seq(-15, 15, 1)
x2 <- seq(-50, 50, 1)
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, grid=TRUE, center=0, seed=0,
                 points=points, storing=TRUE, spConform=FALSE)
do.call(getOption("device"), list(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, grid=TRUE, register=1, seed=0,
                 center=0, points=points, spConform=FALSE)
do.call(getOption("device"), list(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(RFsimulate)$loc$totpts
Print(tbm.points, empty.lines=0) # number of points on the line
}

RFoptions(seed=NA)

Run the code above in your browser using DataLab