Description Usage Arguments Details Value Author(s) References See Also Examples
This page documents the function condsim
that
simulates (un)conditional realizations of Gaussian processes from the
parameters of a spatial linear model estimated by the function
georob
.
1 2 3 4 5 6 7 8 9 | condsim(object, newdata, nsim, seed,
type = c("response", "signal"), locations, trend.coef = NULL,
variogram.model = NULL, param = NULL, aniso = NULL, variogram.object = NULL,
control = control.condsim(), verbose = 0)
control.condsim(use.grid = FALSE, grid.refinement = 2.,
condsim = TRUE, include.data.sites = FALSE, means = FALSE,
trend.covariates = FALSE, covariances = FALSE,
ncores = detectCores(), pcmp = control.pcmp())
|
object |
an object of class |
newdata |
a mandatory data frame,
|
nsim |
number of (condititional) realizations to compute (mandatory argument). |
seed |
integer seed to initialize random number generation,
see |
type |
character keyword defining what target quantity should be simulated. Possible values are
see |
locations |
an optional one-sided formula specifying what variables
of |
trend.coef |
an optional numeric vector with the coefficients of the trend model to be used for computing the (conditional) mean function of the random process see Details. |
variogram.model |
an optional character keyword defining the
variogram model to be used for the simulations, see |
param |
an optional named numeric vector with values of the
variogram parameters used for the simulations, see |
aniso |
an optional named numeric vector with values of anisotropy
parameters of a variogram used for the simulations, see
|
variogram.object |
an optional list that defines a possibly nested
variogram model used for the simulations, see |
control |
a list with the components |
verbose |
positive integer controlling logging of diagnostic
messages to the console. |
use.grid |
logical scalar (default |
grid.refinement |
numeric scalar that defines a factor by which the
minimum differences of the coordinates between any pair of points in
|
condsim |
logical scalar (default |
include.data.sites |
logical scalar, to control whether (conditionally) simulated values are returned also for the points of the original data set used to estimate the model parameters. |
means |
logical scalar, to control whether the (un)conditional means are included in the output. |
trend.covariates |
logical scalar, to control whether the covariates required for the trend model are included in the output. |
covariances |
logical scalar, to control whether the covariances
between the points of the original data set used to estimate the model
parameters ( |
ncores |
positive integer controlling how many cores are used for parallelized computations, defaults to all cores. |
pcmp |
a list of arguments, passed e.g. to |
condsim
(conditionally) simulates from a
Gaussian process that has a linear mean function with parameters
β and an
auto-correlation structure characterized by a parametric variogram
model and variogram parameters τ^2 and
θ (see
georobIntro
for the employed parametrization of the
spatial linear model). The parameters of the mean and
auto-correlation function are either taken from the the spatial linear
model estimated by georob
and passed by the argument
object
to condsim
or from the optional arguments
trend.coef
(β)
and variogram.model
, param
, aniso
or
variogram.object
(τ^2,
θ). Note that in the
former case the uncertainty in the estimated mean and auto-correlation
parameters is not taken into account.
Simulated values are computed for the points in newdata
by the
function RFsimulate
of the package
RandomFields. Both unconditional and conditional simulations
can be computed. In the latter cases, the simulated values are always
conditioned to the response data used to fit the spatial linear model
by georob
and contained in object
.
Unconditional realizations are either computed for the exact locations of
the points in newdata
(use.grid == FALSE
), irrespective of
the fact whether these are arranged on a regular grid, or for the
(approximate) locations of the points in newdata
matched to a
rectangular simulation grid (use.grid == TRUE
). The latter
approach may be substantially faster for large problems because the
simulation algorithm implemented in
RFsimulate
for grids is faster than for
arbitrary geometries of the simulation points.
For use.grid == TRUE
, a rectangular grid is constructed from the
coordinates of the points in newdata
and object
. The
spacing of the grid is equal to the minimum distance between any pair of
points in newdata
, divided by grid.refinement
. The data
related to the points in newdata
(covariates for the trend model)
and of the data in object
(response values, covariates) are then
assigned to the nodes of the grid that are closest to the respective
points. If the same grid node is assigned to several points in
newdata
(or in object
) then the data of the respective
points are averaged. If the same node is assigned to a point in
object
and newdata
then the point in object
is kept
and the concerned point in newdata
is omitted.
Simulations are conditioned to data either by exploiting the respective
built-in functionality of RFsimulate
(use.grid == FALSE
) or by the Kriging method (use.grid ==
TRUE
, see Chilès and Delfiner, 1999, sec. 7.3). The
latter approach may again be faster for large problems because it
exploits the larger speed of unconditional simulations for rectangular
grids.
condsim
uses the packages parallel, snow and
snowfall for parallelized computation of simulations. If there
are m realizations to simulate, the task is split into
ceiling(m/ncores)
sub-tasks that are then distributed to
ncores
CPUs. Evidently, ncores = 1
suppresses parallel
execution. By default, the function uses all available CPUs as returned
by detectCores
.
The output generated by condsim
is an object of a “similar”
class as newdata
(data frame,
SpatialPointsDataFrame
,
SpatialPixelsDataFrame
,
SpatialGridDataFrame
,
SpatialPolygonsDataFrame
).
The data frame or the
data
slot of the Spatial...DataFrame
objects
have the following components:
the coordinates of the prediction points (only present if
newdata
is a data frame).
expct
: optionally the (un)conditional means.
optionally the covariates required for the trend model.
sim.1
, sim.2
, ...: the (un)conditionally
simulated realizations.
Andreas Papritz andreas.papritz@env.ethz.ch.
Chilès, J.-P. and Delfiner, P. (1999) Geostatistics: Modeling Spatial Uncertainty, John Wiley & Sons, New York.
georobIntro
for a description of the model and a brief summary of the algorithms;
georob
for (robust) fitting of spatial linear models;
georobObject
for a description of the class georob
;
profilelogLik
for computing profiles of Gaussian likelihoods;
plot.georob
for display of RE(ML) variogram estimates;
control.georob
for controlling the behaviour of georob
;
georobModelBuilding
for stepwise building models of class georob
;
cv.georob
for assessing the goodness of a fit by georob
;
georobMethods
for further methods for the class georob
;
predict.georob
for computing robust Kriging predictions;
lgnpp
for unbiased back-transformation of Kriging prediction
of log-transformed data;
sample.variogram
and fit.variogram.model
for robust estimation and modelling of sample variograms.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | ## Not run:
data(meuse)
data(meuse.grid)
## convert to SpatialGridDataFrame
meuse.grid.sgdf <- meuse.grid
coordinates(meuse.grid.sgdf) <- ~ x + y
gridded(meuse.grid.sgdf) <- TRUE
fullgrid(meuse.grid.sgdf) <- TRUE
## Gaussian REML fit
r.logzn.reml <- georob(log(zinc) ~ sqrt(dist), data = meuse, locations = ~ x + y,
variogram.model = "RMexp",
param = c(variance = 0.15, nugget = 0.05, scale = 200),
tuning.psi = 1000)
## Conditional simulations
r.sim <- condsim(r.logzn.reml, newdata = meuse.grid.sgdf, nsim = 100, seed = 1,
control = control.condsim(ncores = 1))
## using multiple cores
## r.sim <- condsim(r.logzn.reml, newdata = meuse.grid.sgdf, nsim = 100, seed = 1)
str(r.sim, max=2)
## Display
spplot(r.sim, zcol = "sim.1", at = seq(3.5, 8.5, by = 0.5))
spplot(r.sim, zcol = "sim.2", at = seq(3.5, 8.5, by = 0.5))
library(lattice)
levelplot(sim.1 ~ x + y, as.data.frame(r.sim), aspect = "iso", at = seq(3.5, 8.5, by = 0.5),
panel = function(x, y, z, subscripts, data.points, ... ){
panel.levelplot( x, y, z, subscripts, ...)
panel.xyplot(data.points$x, data.points$y, col = 1)
}, data.points = meuse[, c("x", "y")]
)
levelplot(sim.2 ~ x + y, as.data.frame(r.sim), aspect = "iso", at = seq(3.5, 8.5, by = 0.5),
panel = function(x, y, z, subscripts, data.points, ... ){
panel.levelplot( x, y, z, subscripts, ...)
panel.xyplot(data.points$x, data.points$y, col = 1)
}, data.points = meuse[, c("x", "y")]
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.