indexCalculation: Weighted Average per NIunit of Scaled Indicator Observations

View source: R/indexCalculation.R

indexCalculationR Documentation

Weighted Average per NIunit of Scaled Indicator Observations

Description

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.

Usage

indexCalculation(
  ICunits = NULL,
  NIWeights = NULL,
  scaledBootmat = NULL,
  nsim = NULL
)

Arguments

ICunits

numeric BSunit x indicator matrix describing the occurrence of indicators in BSunits. NAs in a column should represent BSunits where the indicator is not observed.

NIWeights

A named list of numeric BSunit x indicator matrices zi, one matrix for each NIunit. Each matrix zi containing weights for each combination of BSunit and indicator, and satisfying sum(zi,na.rm = TRUE) = 1.

scaledBootmat

numeric nObs x nsim matrix with nsim bootstrap samples from each of nObs scaled indicator observations.

nsim

integer - number of bootstrap simulations.

Details

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.

Value

A named list of numeric vectors, one vector for each NIunit, where each vector contains nsim draws from the NIunit's index distribution.

Note

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.

Author(s)

Bård Pedersen

See Also

The vignette NatureIndexCalculation for a description of the framework for calculating the Nature index,
and functions calculateIndex, calculateWeights, and scaleObsMat.

Examples

## 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)


NINAnor/NIcalc documentation built on Oct. 26, 2023, 9:37 a.m.