grf | R Documentation |
grf()
generates (unconditional)
simulations of Gaussian random fields for
given covariance parameters.
grf(n, grid = "irreg", nx, ny, xlims = c(0, 1), ylims = c(0, 1),
borders, nsim = 1, cov.model = "matern",
cov.pars = stop("missing covariance parameters sigmasq and phi"),
kappa = 0.5, nugget = 0, lambda = 1, aniso.pars,
mean = 0, method, messages)
n |
number of points (spatial locations) in each simulations. |
grid |
optional. An |
nx |
optional. Number of points in the X direction. |
ny |
optional. Number of points in the Y direction. |
xlims |
optional. Limits of the area in the X direction. Defaults
to |
ylims |
optional. Limits of the area in the Y direction. Defaults
to |
borders |
optional. Typically a two coluns matrix especifying a polygon. See DETAILS below. |
nsim |
Number of simulations. Defaults to 1. |
cov.model |
correlation function. See |
cov.pars |
a vector with 2 elements or an |
kappa |
additional smoothness parameter required only for the
following correlation
functions: |
nugget |
the value of the nugget effect parameter |
lambda |
value of the Box-Cox transformation parameter. The value |
aniso.pars |
geometric anisotropy parameters. By default an
isotropic field is assumed and this argument is ignored.
If a vector with 2 values is provided, with values for the
anisotropy angle |
mean |
a numerical vector, scalar or the same length of the data to be simulated. Defaults to zero. |
method |
simulation method with options for
|
messages |
logical, indicating
whether or not status messages are printed on the screen (or output device)
while the function is running. Defaults to |
For the methods "cholesky"
, "svd"
and "eigen"
the
simulation consists of multiplying a vector of standardized
normal deviates by a square root of the covariance matrix.
The square root of a matrix is not uniquely defined. These
three methods differs in the way they compute the
square root of the (positive definite) covariance matrix.
The argument borders
, if provides takes a
polygon data set following argument poly
for the splancs' function csr
, in case of
grid="reg"
or gridpts
, in case of
grid="irreg"
. For the latter the simulation will have
approximately “n” points.
grf
returns a list with the components:
coords |
an |
data |
a vector (if |
cov.model |
a string with the name of the correlation function. |
nugget |
the value of the nugget parameter. |
cov.pars |
a vector with the values of |
kappa |
value of the parameter |
lambda |
value of the Box-Cox transformation parameter
|
aniso.pars |
a vector with values of the anisotropy parameters, if provided in the function call. |
method |
a string with the name of the simulation method used. |
sim.dim |
a string "1d" or "2d" indicating the spatial dimension of the simulation. |
.Random.seed |
the random seed by the time the function was called. |
messages |
messages produced by the function describing the simulation. |
call |
the function call. |
Paulo Justiniano Ribeiro Jr. paulojus@leg.ufpr.br,
Peter J. Diggle p.diggle@lancaster.ac.uk.
Wood, A.T.A. and Chan, G. (1994) Simulation of stationary Gaussian
process in [0,1]^d
.
Journal of Computatinal and Graphical Statistics, 3, 409–432.
Schlather, M. (1999) Introduction to positive definite functions and to unconditional simulation of random fields. Tech. Report ST–99–10, Dept Maths and Stats, Lancaster University.
Schlather, M. (2001) Simulation and Analysis of Random Fields. R-News 1 (2), p. 18-20.
Further information on the package geoR can be found at:
http://www.leg.ufpr.br/geoR/.
plot.grf
and image.grf
for graphical output,
coords.aniso
for anisotropy coordinates transformation and chol
,
svd
and eigen
for methods of matrix
decomposition.
sim1 <- grf(100, cov.pars = c(1, .25))
# a display of simulated locations and values
points(sim1)
# empirical and theoretical variograms
plot(sim1)
## alternative way
plot(variog(sim1, max.dist=1))
lines.variomodel(sim1)
#
# a "smallish" simulation
sim2 <- grf(441, grid = "reg", cov.pars = c(1, .25))
image(sim2)
##
## 1-D simulations using the same seed and different noise/signal ratios
##
set.seed(234)
sim11 <- grf(100, ny=1, cov.pars=c(1, 0.25), nug=0)
set.seed(234)
sim12 <- grf(100, ny=1, cov.pars=c(0.75, 0.25), nug=0.25)
set.seed(234)
sim13 <- grf(100, ny=1, cov.pars=c(0.5, 0.25), nug=0.5)
##
par.ori <- par(no.readonly = TRUE)
par(mfrow=c(3,1), mar=c(3,3,.5,.5))
yl <- range(c(sim11$data, sim12$data, sim13$data))
image(sim11, type="l", ylim=yl)
image(sim12, type="l", ylim=yl)
image(sim13, type="l", ylim=yl)
par(par.ori)
## simulating within borders
data(parana)
pr1 <- grf(100, cov.pars=c(200, 40), borders=parana$borders, mean=500)
points(pr1)
pr1 <- grf(100, grid="reg", cov.pars=c(200, 40), borders=parana$borders)
points(pr1)
pr1 <- grf(100, grid="reg", nx=10, ny=5, cov.pars=c(200, 40), borders=parana$borders)
points(pr1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.