genSample.JointNumericSpatial: Generating Monte Carlo sample from a list of uncertain...

Description Usage Arguments Details Value Author(s) Examples

View source: R/genSample.JointNumericSpatial.R

Description

Uncertain objects are described by joint PDF or a list from independent objects. Sampling can be done via three different sampling methods:

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## S3 method for class 'JointNumericSpatial'
genSample(
  UMobject,
  n,
  samplemethod,
  p = 0,
  asList = TRUE,
  debug.level = 1,
  ...
)

Arguments

UMobject

object of a class JointNumericSpatial. Output of defineMUM().

n

Integer. Number of Monte Carlo realizations.

samplemethod

"ugs" for spatially cross-correlated errors, "randomSampling" for joint PDF of non-spatial variables, "lhs" if no correlation of errors is considered.

p

A vector of quantiles. Optional. Only required if sample method is "lhs".

asList

Logical. If TRUE return sample in a form of a list, if FALSE returnsample in a format of distribution parameters.

debug.level

integer; set gstat internal debug level, see below for useful values. If set to -1 (or any negative value), a progress counter is printed.

...

Additional parameters that may be passed, e.g. in the "ugs" method. See examples.

Details

"ugs" Unconditional gaussian simulation of spatially cross-correlated errors.

"randomSampling" Sampling multivariate distribution using eigenvalue decomposition (based on 'mvtnorm' package).

"lhs" Not implemented yet. Sampling method for at least two uncertain inputs. The uncertain.object is then a list of two or more. It uses startified sampling method to generate the inputs for the latin hypercude algorithm, hence number of samples (n) must be dividable by the number of quantiles to assure each quantile is evenly represented.

NOTE. Version 1.3-1 includes bug fixing related to derivation of cross-correlation matrix for multivariate uncertainty propagation analysis.

Value

A Monte Carlo sample of the variables of interest. If asList = TRUE returns list of all samples as lists.

Author(s)

Kasia Sawicka, Stefan van Dam, Gerard Heuvelink

Examples

 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
set.seed(12345)
# "ugs" method example
# load data
data(OC, OC_sd, TN, TN_sd)

# Test for SpatialGridDataFrames
OC <- as(OC, 'SpatialGridDataFrame')
TN <- as(TN, 'SpatialGridDataFrame')
OC_sd <- as(OC_sd, 'SpatialGridDataFrame')
TN_sd <- as(TN_sd, 'SpatialGridDataFrame')

# define marginal UMs
OC_crm <- makeCRM(acf0 = 0.6, range = 5000, model = "Sph")
OC_UM <- defineUM(TRUE, distribution = "norm", distr_param = c(OC, OC_sd), crm = OC_crm, id = "OC")
TN_crm <- makeCRM(acf0 = 0.4, range = 5000, model = "Sph")
TN_UM <- defineUM(TRUE, distribution = "norm", distr_param = c(TN, TN_sd), crm = TN_crm, id = "TN")

# define joint UM
soil_prop <- list(OC_UM, TN_UM)
mySpatialMUM <- defineMUM(soil_prop, matrix(c(1,0.7,0.7,1), nrow=2, ncol=2))

# sample - "ugs" method
# toy example
my_cross_sample <- genSample(mySpatialMUM, n = 3, "ugs", nmax = 24, asList = TRUE)
class(my_cross_sample)
## Not run: 
my_cross_sample <- genSample(mySpatialMUM, n = 50, "ugs", nmax = 24, asList = TRUE)
class(my_cross_sample)

## End(Not run)

spup documentation built on May 1, 2020, 1:07 a.m.