rtopSim: Spatial simulation of data with spatial support

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/zzz.R

Description

rtopSim will conditionally or unconditionally simulate data with areal support.

Usage

1
2
3
4
5
6
7
8
  
## S3 method for class 'rtop'
rtopSim(object, varMatUpdate = FALSE, beta = NA, 
      largeFirst = TRUE, replace = FALSE, params = list(), 
      dump = NULL, logdist = FALSE, ...) 
## Default S3 method:
rtopSim(object = NULL, predictionLocations,
    varMatObs,  varMatPredObs, varMatPred, variogramModel, ...) 

Arguments

object

object of class rtop or SpatialPolygonsDataFrame or NULL

varMatUpdate

logical; if TRUE, also existing variance matrices will be recomputed, if FALSE, only missing variance matrices will be computed, see also varMat

beta

The expected mean of the data, for unconditional simulations

largeFirst

Although the simulation method follows a random path around the predictionLocations, simulating the largest area first will assure that the true mean of the simulated values will be closer to beta

replace

logical; if observation locations are also present as predictions, should they be replaced? This is particularly when doing conditional simulations for a set of observations with uncertainty.

params

a set of parameters, used to modify the standard parameters for the rtop package, set in getRtopParams. The argument params can also be used for the other methods, through the ...-argument.

dump

file name for saving the updated object, after adding variance matrices. Useful if there are problems with the simulation, particularly if it for some reason crashes.

logdist

logical; whether to sample from a lognormal distribution

predictionLocations

SpatialPolygons or SpatialPolygonsDataFrame with locations for simulations.

varMatObs

covariance matrix of possible observations, where diagonal must consist of internal variance, typically generated from call to varMat

varMatPredObs

covariance matrix between possible observation locations and simulation locations, typically generated from call to varMat

varMatPred

covariance matrix between simulation locations, typically generated from a call to varMat

variogramModel

a variogram model of type rtopVariogramModel

...

possible modification of the object parameters or default parameters.

Details

This function can do constrained or unconstrained simulation for areas. The simplest way of calling the function is with an rtop-object that contains the fitted variogram model and all the other necessary data (see createRtopObject or rtop-package). rtopSim is the only function in rtop which does not need observations. However, a variogram model is still necessary to perform simulations.

The arguments beta and largeFirst are only used for unconditional simulations.

Value

If called with SpatialPolygons as predictionLocations and either
SpatialPolygonsDataFrame or NULL for observations, the function returns a
SpatialPolygonsDataFrame with simulations at the locations defined in
predictionLocations

If called with an rtop-object, the function returns the same object with the simulations added to the object.

Author(s)

Jon Olav Skoien

References

Skoien J. O., R. Merz, and G. Bloschl. Top-kriging - geostatistics on stream networks. Hydrology and Earth System Sciences, 10:277-287, 2006.

See Also

rtop-package

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
31
32
33
34
35
36
37
38
39
40
41
## Not run: 
library(rgdal)
# The following command will download  the complete example data set
# downloadRtopExampleData() 

rpath = system.file("extdata",package="rtop")
observations = readOGR(rpath,"observations")
predictionLocations = readOGR(rpath,"predictionLocations")

# Setting some parameters; nclus > 1 will start a cluster with nclus 
# workers for parallel processing
params = list(gDist = TRUE, cloud = FALSE, nclus = 1, rresol = 25)

# Create a column with the specific runoff:
observations$obs = observations$QSUMMER_OB/observations$AREASQKM

# Build an object
rtopObj = createRtopObject(observations, predictionLocations, 
                           params = params)

# Fit a variogram (function also creates it)
rtopObj = rtopFitVariogram(rtopObj)

# Conditional simulations for two new locations 
rtopObj10 = rtopSim(rtopObj, nsim = 5)
rtopObj11 = rtopObj

# Unconditional simulation at the observation locations
# (These are moved to the predictionLocations)
rtopObj11$predictionLocations = rtopObj11$observations
rtopObj11$observations = NULL
# Setting varMatUpdate to TRUE, to make sure that covariance
# matrices are recomputed
rtopObj12 = rtopSim(rtopObj11, nsim = 10, beta = 0.01, 
                    varMatUpdate = TRUE)

rtopObj10$simulations@data
rtopObj12$simulations@data


## End(Not run)

rtop documentation built on May 2, 2019, 6:48 p.m.