calculateWeights: Weighting per NIunit

View source: R/calculateWeights.R

calculateWeightsR Documentation

Weighting per NIunit

Description

Returns weights for the calculation of the Nature index for a set of NIunits.

Usage

calculateWeights(BSunitWeights = NULL, NIunitWeights = NULL)

Arguments

BSunitWeights

numeric BSunit x indicator matrix with BSunit weights for each combination of BSunits and indicators, where rowSums(BSunitWeights,na.rm = TRUE) = rep(1,nrow).

NIunitWeights

numeric BSunit x NIunit matrix with NIunit weights for each combination of BSunits and NIunits, where colSums(NIunitWeights) = rep(1,n).

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. The final weight given to an indicator observation from a BSunit within an NIunit is the product of the observation's BSunit weight and the BSunit's NIunit (area) weight. See the vignette NatureIndexCalculation for details.

Usually, the Nature index and thematic indices are calculated for a whole set of NIunits simultaniously. The function calculates weights for each combination of BSunit and indicator for all NIunits in the set.

Value

A list x of 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.

Author(s)

Bård Pedersen

See Also

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

Examples

# Test data set
nBS <- 4
nInd <- 10
indicators <- paste("Indic",1:nInd)
BSunits <- paste("Unit",1:nBS)
NIunits <- cbind(c(1,1,1,1),c(1,1,0,0),c(1,0,0,0),c(1,0,1,1),c(0,0,0,1))
NIunitNames <- c("All units","Two units","Unit 1","Some units","Unit 4")
dimnames(NIunits) <- list(BSunits,NIunitNames)
awBSunit <- runif(4)*1000
ICunits <- matrix(1,nrow=nBS,ncol=nInd)
for (i in 1:5) {for (j in 1:5) {ICunits[sample(1:nBS,1),sample(1:nInd,1)] <- NA}}
dimnames(ICunits) <- list(BSunits,indicators)
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

x <- calculateWeights(BSunitWeights =
                         calculateBSunitWeights(ICunits = ICunits,
                         indicators = indicators,fidelity = ff,
                         trophicGroup = tt, keyElement = kk),
                      NIunitWeights =
                         calculateNIunitWeights(BSunits = BSunits,
                         NIunits = NIunits, awBSunit = awBSunit))
x
sum(x$'Some units',na.rm = TRUE)


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