View source: R/indexCalculation.R
indexCalculation | R Documentation |
Calculates, for each unit in a set of NIunits, a sample of nsim
draws
from the distribution of the Nature index or a thematic index.
indexCalculation(
ICunits = NULL,
NIWeights = NULL,
scaledBootmat = NULL,
nsim = NULL
)
ICunits |
numeric BSunit x indicator matrix describing the
occurrence of indicators in BSunits. |
NIWeights |
A named list of numeric BSunit x indicator matrices |
scaledBootmat |
numeric |
nsim |
integer - number of bootstrap simulations. |
indexCalculation
draws a sample of size nsim
from the distribution
of the Nature index or a thematic index for each unit in a set of NIunits.
Each draw is a weighted average of a bootstrap sample of corresponding draws
from the distributions of a set of indicator observations.
For each NIunit, 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 named list of numeric vectors, one vector for each NIunit, where each
vector contains nsim
draws from the NIunit's index distribution.
Indices are calculated for a set of NIunits, while scaled indicator
observations, on the other hand, refer to indicator specific ICunits that may
vary in geographical extent among indicators, and will in general not
correspond to the NIunits. Thus, indexCalculation
needs input about
the spatial extent of each ICunit and NIunit. The spatial extent of NIunits
are indirectly provided by the weights as Bsunits not included in the NIunit
are given zero weight.
Bård Pedersen
The vignette NatureIndexCalculation
for a description of the
framework for calculating the Nature index,
and functions
calculateIndex
, calculateWeights
,
and scaleObsMat
.
## Not run:
# Calculate thematic indices based on the themeData set for 2019 for the NIunits
# defined in themeData$NIunits
# Preparing bootstrap sample as input to indexCalculation:
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)
# NIunit weights as input to indexCalculation:
xxx <- calculateBSunitWeights(ICunits = themeData$ICunits,
indicators = themeData$indicators$name,
fids = FALSE,
tgroups = FALSE)
yyy <- calculateNIunitWeights(BSunits = themeData$BSunits$name,
NIunits = themeData$NIunits,
awBSunit = themeData$BSunits$Skog)
NIWeights <- calculateWeights(BSunitWeights = xxx,NIunitWeights = yyy)
# Calculate thematic index for each NIunit
indices <- indexCalculation(ICunits = themeData$ICunits,
NIWeights = NIWeights,
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.