calculateBSunitWeights: Weighting per BSunit

View source: R/calculateBSunitWeights.R

calculateBSunitWeightsR Documentation

Weighting per BSunit

Description

Returns BSunit weights, i.e. weights used in the calculation of indices for a set of BSunits.

Usage

calculateBSunitWeights(
  ICunits = NULL,
  indicators = NULL,
  fidelity = NULL,
  trophicGroup = NULL,
  keyElement = NULL,
  fids = TRUE,
  tgroups = TRUE,
  keys = "specialWeight",
  w = 0.5
)

Arguments

ICunits

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

indicators

character vector with names of all indicators included in the calculation.

fidelity

numeric vector with the fidelity of each indicator to the major habitat in question. Required if fids = TRUE.

trophicGroup

character vector with either name or ID of trophic group for each indicator. Required if tgroups = TRUE.

keyElement

logical vector indicating whether corresponding indicator is a key indicator or not. Required if keys %in% c("asGroup","specialWeight").

fids

Logical flag: should fidelities be ignored (fids = FALSE) in the calculation of Wi?

tgroups

Logical flag: should grouping of indicators into trophic and key indicator groups be ignored (tgroups = FALSE) in the calculation of Wf?

keys

character, one of c("asGroup","ignore","specialWeight").
keys = "asGroup": Key indicators treated as an ordinary trophic group, no special weighting of key indicators.
keys = "ignore": All indicators treated as non-key indicators and grouped according to trophicGroup.
keys = "specialWeight": Default, special weighting of key indicators where their trophic weight is set to w.

w

numeric 0 <= w <= 1, trophic weight given to key indicators if keys = "specialWeight", defaults to 0.5. Automatically reset to default value if outside [0,1].

Details

The Nature index and many thematic indices are weighted averages of indicator observations. The weights are calculated a priori, i.e. they do not depend on the observations' values. When estimating indices for a set of BSunits, weights are based on the characteristics of indicators (parameters fidelity, trophicGroup, keyElement) and their occurence in BSunits (parameter ICunits).

calculateBSunitWeights calculate BSunit weights for each combination of BSunit and indicator. Under default settings, calculation is according to the Norwegian implementation of the Nature index (cf. the vignette NatureIndexCalculation), where BSunit weights are products of fidelity weights (Wf) and trophic weights (Wt). Weights are based on a distinction between key indicators and non-key indicators, and a grouping of non-key indicators, here referred to as trophic groups.

Wf for an indicator observed in a BSunit is the fidelity of the indicator to the ecosystem in question divided by the summed fidelity of indicators belonging to the same trophic group and observed in the BSunit.

Wt for non-key indicators depends on the number of trophic groups (r) observed in the BSunit and whether key indicators are observed in the BSunit or not. Wt = w/r when key indicators are observed, and Wt = 1/r if no key indicators are observed in the BSunit. w defaults to 0.5. Wt for key indicators equals w if some non-key indicators are observed in the BSunit, and 1 if only key indicators are observed.

There are options for ignoring fidelities and/or grouping of indicators in the calculation of weights, and for alternative treatments of key indicators.

Value

A numeric BSunit x indicator matrix x, where rowSums(x,na.rm = TRUE) = rep(1,nrow), with weights for all indicators observed in each BSunit and NAs elsewhere.

Author(s)

Bård Pedersen

See Also

calculateNIunitWeights and calculateWeights.
The vignette NatureIndexCalculation gives a complete description of the framework for calculating weights for the Nature index.

Examples

# Test data
nBS <- nInd <- 10
BSunits <- paste("unit",1:nBS)
indicators <- paste("indic",1:nInd)
x <- matrix(1,nrow=nBS,ncol=nInd)
for (i in 1:5) {for (j in 1:5) {x[sample(1:nBS,1),sample(1:nInd,1)] <- NA}}
dimnames(x) <- list(BSunits,indicators)
x
ff <- sample(c(rep(100,nInd-1),75))
tt <- sample(paste("group", 1:3),nInd,replace = TRUE)
kk <- rep(FALSE,nInd)
kk[sample(1:nInd,3)] <- TRUE
data.frame(indicators = indicators, fidelity = ff,trophicGroup = tt, keyElement = kk)

# Default calculation:
ww <- calculateBSunitWeights(ICunits = x, indicators = indicators, fidelity = ff,
                       trophicGroup = tt, keyElement = kk)
ww
rowSums(ww,na.rm=TRUE)

# Alternatives for key indicators:
calculateBSunitWeights(ICunits = x, indicators = indicators, fidelity = ff,
                       trophicGroup = tt, keyElement = kk, keys = "asGroup")
calculateBSunitWeights(ICunits = x, indicators = indicators, fidelity = ff,
                       trophicGroup = tt, keys = "ignore")
calculateBSunitWeights(ICunits = x, indicators = indicators, fidelity = ff,
                       trophicGroup = tt, keyElement = kk, w = 0.0)
calculateBSunitWeights(ICunits = x, indicators = indicators, fidelity = ff,
                       trophicGroup = tt, keyElement = kk, w = 1.0)

# Ignore fidelities:
calculateBSunitWeights(ICunits = x, indicators = indicators, fids = FALSE,
                       tgroups = TRUE, trophicGroup = tt, keyElement = kk)

# Equal weighting of indicators.
# I.e. weights equal to the inverse of the number of indicators observed
# in a BSunit:
calculateBSunitWeights(ICunits = x, indicators = indicators, fids = FALSE,
                       tgroups = FALSE)


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