View source: R/calculateBSunitWeights.R
calculateBSunitWeights | R Documentation |
Returns BSunit weights, i.e. weights used in the calculation of indices for a set of BSunits.
calculateBSunitWeights(
ICunits = NULL,
indicators = NULL,
fidelity = NULL,
trophicGroup = NULL,
keyElement = NULL,
fids = TRUE,
tgroups = TRUE,
keys = "specialWeight",
w = 0.5
)
ICunits |
numeric BSunit x indicator matrix describing the occurrence of
indicators in BSunits. |
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 |
trophicGroup |
character vector with either name or ID of trophic group for
each indicator. Required if |
keyElement |
logical vector indicating whether corresponding indicator
is a key indicator or not. Required if
|
fids |
Logical flag: should fidelities be ignored ( |
tgroups |
Logical flag: should grouping of indicators into trophic and
key indicator groups be ignored ( |
keys |
character, one of |
w |
numeric |
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.
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 NA
s elsewhere.
Bård Pedersen
calculateNIunitWeights
and calculateWeights
.
The vignette NatureIndexCalculation
gives a complete description
of the framework for calculating weights for the Nature index.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.