genSample.MarginalCategoricalSpatial {spup} | R Documentation |
Generating Monte Carlo sample from an uncertain object of a class 'MarginalCategoricalSpatial'
Description
Generating Monte Carlo sample from an uncertain object of a class 'MarginalCategoricalSpatial'
Usage
## S3 method for class 'MarginalCategoricalSpatial'
genSample(UMobject, n, samplemethod, p = 0, asList = TRUE, ...)
Arguments
UMobject |
uncertain object defined using defineUM(). |
n |
Integer. Number of Monte Carlo realizations. |
samplemethod |
not in use for categorical variables. |
p |
not in use for categorical variables. |
asList |
logical. If asList = TRUE returns list of all samples as a list. If asList = FALSE returns samples in a format of distribution parameters in UMobject. |
... |
additional parameters |
Value
A Monte Carlo sample of a categorical spatial variable.
Author(s)
Kasia Sawicka
Examples
set.seed(12345)
# load data
data(woon)
woonUM <- defineUM(TRUE, categories = c(1,2,3), cat_prob = woon[, c(4:6)])
woon_sample <- genSample(woonUM, 10, asList = FALSE)
class(woon_sample)
str(woon_sample@data)
woon_sample <- genSample(woonUM, 10)
class(woon_sample)
# analyse probability of having snow
# load data
data(dem30m, dem30m_sd)
# generate dummy probabilities for categories "snow" and "no snow"
dem30m$snow_prob <- NA
dem30m$snow_prob[dem30m$Elevation > 1000] <- 0.75
dem30m$snow_prob[dem30m$Elevation <= 1000] <- 0.25
dem30m$no_snow_prob <- 1 - dem30m$snow_prob
summary(dem30m@data)
snowUM <- defineUM(uncertain = TRUE, categories = c("snow", "no snow"), cat_prob = dem30m[2:3])
class(snowUM)
snow_sample <- genSample(snowUM, 10, asList = FALSE)
head(snow_sample@data)
[Package spup version 1.4-0 Index]