rgrf {spam} | R Documentation |
Draw From a Gaussian Random Field
Description
Fast and intuitive ways to draw from a Gaussian random field.
Usage
rgrf( n,
locs, nx, ny=nx, xlim=c(0,1), ylim=c(0,1), tau=0,
Covariance, theta, beta=0, X,
method=c('chol'), method.args=list(sparse=FALSE),
eps = getOption("spam.eps"), drop=TRUE, attributes=TRUE, ...)
Arguments
n |
number of observations. |
locs |
locations, the result of |
nx , ny |
if no locations are specified, at least one of these to specify the grid dimension. |
xlim , ylim |
Domain, see ‘Details’. |
tau |
perturbation degree, see ‘Details’. |
Covariance |
covariance function name. |
theta |
covariance parameter. |
beta |
mean or vector for regression-type mean. |
X |
design matrix for regression-type mean. |
method |
based on Choleski factorization. |
method.args |
list of arguments that can be passed to the corresponding approach.
For |
eps |
small value, anything smaller is considered a collocation. |
drop |
logical, if a single realization should be returned as a vector. |
attributes |
logical, if should attributes be passed back. |
... |
currently not used. |
Details
If no locations are given, the function constructs these
according a regular or a regular perturbed grid. The perturbation is
determined by tau
, which has to be greater than zero (no
perturbation) and strictly smaller than 1/2 (max perturbation).
The regular grid has spacing (here for x) dx=diff(xlim)/nx
and runs
from xlim[1]+dx/2
to xlim[2]-dx/2
.
The locations are at least (1/nx-2*tau*dx)
separated.
Currently, the only method implemented is a Cholesky factorization
routine, (much as in rmvnorm
).
The rdist()
from the fields
package is awefully
fast. Unless one has very sparse covariance matrices, a sparse
approach is not bringing a lot of improvements.
The methods may use different covariance construction approaches and
thus the nesting of cov.args
in method.args
.
Author(s)
Reinhard Furrer
See Also
Examples
require(fields)
# Regular grid with constant mean:
nx <- 10
field <- rgrf(1, nx=nx, Covariance="cov.wend2", theta=c(.5, 1), beta=5)
quilt.plot(cbind(attr(field,"locs"),z=field), nx=nx, ny=nx)
points(attr(field,"locs"))
# Irregluar grid:
field <- rgrf(1, nx=10, tau=0.3, Covariance="cov.mat", theta=c(.2, 1, 1.5))
fields::quilt.plot(attr(field,"locs"), field)