Learn R Programming

RandomFields (version 3.0.32)

RMuser: User Defined Function

Description

RMuser allows for a user defined covariance function, variogram model, or arbitrary function

Usage

RMuser(type, domain, isotropy, vdim, beta,
       variab.names = c("x", "y", "z", "T"), fctn, fst, snd, envir,  
       var, scale, Aniso, proj)

Arguments

type, domain, isotropy, vdim
The default value of type is "shape function". The default value for the domain is XONLY. The default value of isotropy is 'isotropic' if type equal
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 beta as a vector, an arbitrary linear model can be defined. Estimation of beta
variab.names
Just the namees of the variables. More variable names might be given here than used in the function. See Detail for the interpretation of variables.
fctn, fst, snd
a user defined function and its first, second and third derivative, given as quote(myfunction(x)) or as quote(myfunction(x, y)), see Details an Examples below.
envir
the environment where the given function shall be evaluated
var,scale,Aniso,proj
optional arguments; same meaning for any RMmodel. If not passed, the above covariance function remains unmodified.

Value

Details

Primarily, a function is expected that depends on a vector whose components, $x, y, z, T$, are given separately as scalar quantities. Alternatively, the function might depend only on the first argument given by variab.names.

A kernel should depend on the first two arguments given by variab.names.

See Also

RFfit, RMmodelgenerator RMmodel, RFsimulate, RC_ISOTROPY, RC_DOMAIN

Examples

Run this code
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)

if (RFoptions()$general$storing)
cat("This examples requires 'RFoptions(storing=FALSE)', what is set now.\n");
RFoptions(storing=FALSE)

model <- RMuser(type="positive definite", domain="single variable",
                iso="isotropic", fctn=exp(-x))
x <- y <- seq(1, 10, len=10^(1+interactive()))
plot(model)
z <- RFsimulate(RPcirculant(model), x=x, y=y, grid=TRUE)
plot(z)
model <- RMnugget(var=1e-5) +
         RMuser(type="positive definite", domain="kernel",
                iso="symmetric", fctn=sum(x * y))
x <- y <- seq(1, 10, len=7^(1+interactive()))
z <- RFsimulate(model, x=x, y=y, grid=TRUE, n=6)
plot(z)
FinalizeExample()

Run the code above in your browser using DataLab