View source: R/indexCalculationPerBSunit.R
indexCalculationPerBSunit | R Documentation |
Calculates, for each unit in a set of BSunits, a sample of nsim
draws
from the distribution of the Nature index or a thematic index.
indexCalculationPerBSunit(
ICunits = NULL,
BSWeights = NULL,
scaledBootmat = NULL,
nsim = NULL
)
ICunits |
numeric BSunit x indicator matrix describing the
occurrence of indicators in BSunits. |
BSWeights |
A numeric BSunit x indicator matrix |
scaledBootmat |
numeric |
nsim |
integer - number of bootstrap simulations. |
indexCalculationPerBSunit
draws a sample of size nsim
from the distribution
of the Nature index or a thematic index for each unit in a set of BSunits.
Each draw is a weighted average of a bootstrap sample of corresponding draws
from the distributions of a set of indicator observations.
Weights are entered per BSunit x indicator combination. For each indicator observation the delineation of the corresponding ICunit must be provided in the input.
A BSunit x nsim
numeric matrix, where each row
contains nsim
draws from the BSunit's index distribution.
Indices are calculated for a set of BSunits, while scaled indicator
observations refer to indicator specific ICunits that
may vary in geographical extent among indicators, and will in general not
correspond to single BSunits. Thus, indexCalculationPerBSunit
needs
input about the spatial extent of ICunits in terms of which BSunits they
include.
Bård Pedersen
Index calculations and associated terminology are explained in the
vignette NatureIndexCalculation
.
Functions
calculateIndex
, calculateBSunitWeights
,
and scaleObsMat
.
## Not run:
# Calculate a thematic index for each BSunit based on the themeData set for 2019
# Preparing bootstrap sample as input to indexCalculationPerBSunit:
bootmat <- sampleObsMat(ICunitId = themeData$indicatorValues[["2019"]]$ICunitId,
value = themeData$indicatorValues[["2019"]]$expectedValue,
distrib = themeData$indicatorValues[["2019"]]$distributionFamilyName,
mu = themeData$indicatorValues[["2019"]]$distParameter1,
sig = themeData$indicatorValues[["2019"]]$distParameter2,
customDistribution = themeData$indicatorValues[["2019"]]$customDistribution,
imputations = NULL,
obsMethod = "sample",
obsType = "tradObs",
nsim = 10)
refmat <- sampleObsMat( ICunitId = themeData$referenceValues$ICunitId,
value = themeData$referenceValues$expectedValue,
distrib = themeData$referenceValues$distributionFamilyName,
mu = themeData$referenceValues$distParameter1,
sig = themeData$referenceValues$distParameter2,
customDistribution = themeData$referenceValues$customDistribution,
imputations = NULL,
obsMethod = "constant",
obsType = "tradObs",
nsim = 10)
scaleVec <- themeData$indicatorValues[["2019"]]$scalingModel
names(scaleVec) <- themeData$indicatorValues[["2019"]]$ICunitId
scaleVec <- scaleVec[dimnames(bootmat)[[1]]]
scaledBootmat <- scaleObsMat(bootmat = bootmat,
refmat = refmat,
scalingModel = scaleVec)
# BSunit weights as input to indexCalculationPerBSunit:
BSWeights <- calculateBSunitWeights(ICunits = themeData$ICunits,
indicators = themeData$indicators$name,
fids = FALSE,
tgroups = FALSE)
# Calculate index for each BSunit
indices <- indexCalculationPerBSunit(ICunits = themeData$ICunits,
BSWeights = BSWeights,
scaledBootmat = scaledBootmat,
nsim = 10)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.