scaleObsMat: Scaling of Indicator Observations

View source: R/scaleObsMat.R

scaleObsMatR Documentation

Scaling of Indicator Observations

Description

scaleObsMat scales a set of indicator observations according to chosen scaling model ("Low" or "Max") and associated reference values.

Usage

scaleObsMat(
  bootmat = NULL,
  refmat = NULL,
  scalingModel = NULL,
  truncAtRef = TRUE
)

Arguments

bootmat

double matrix dim = nObs x nsim of indicator observations.

refmat

double matrix dim = nObs x nsim of reference values.

scalingModel

character length = nObs named vector of scaling model names "Low" or "Max".

truncAtRef

logical flag: whether to truncate scaled indicator observations at the reference value truncAtRef = TRUE (default), or nottruncAtRef = FALSE).

Details

Each indicator observation and reference value is assumed to be entered as nsim draws from their respective distributions. The sets of indicator observations and reference values are both entered as nObs x nsim matrices, with identical row names.

Scaling models are specific for each observation. They should be entered as a named vector of scaling model codes "Low" or "Max", with length = nObs and names identical to the row names of indicator observation and reference values matrices.

Value

double matrix dim=nObs x nsim of scaled indicator observations.

Author(s)

Bård Pedersen

See Also

The vignette NatureIndexCalculation for a description of the framework for calculating the Nature index

Examples

## Not run: 
# Example based on the themeData set for 2019
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)

## End(Not run)


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