knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

For instructions on using this package, please see thepackage Manual.

Rationale

Implementation

Description

The calculation can be described as follows:

For each household individually...

  1. set msni to the largest value of health, protection and shelter
  2. set msni to the impact score, if impact is lower than the previous msni.
  3. set msni to the largets value of msni, wash, fsl, capacity gaps if that is larger than the previous msni
  4. set msni to 2 if and only if
    1. msni is currently 1
    2. and one of health, protection, shelter and education (or one of the additionally supplied indices) is larger or equal 3
  5. set msni to NA if any of the input scores was NA
  6. done!

Code

Here is the actual code.

#  1. set `msni` to the largest value of `health`, `protection` and `shelter`
msni <- pmax(health_lsg,protection_lsg,shelter_lsg)

#  2. set `msni` to the `impact` score, if `impact` is lower than the previous `msni`. 
msni <- pmin(msni, impact)

#  3. set `msni` to the largets value of `msni`, `wash`, `fsl`, `capacity gaps` if that is larger than the previous `msni`
largest_lsg_combination_hps <- pmax(
  pmin(health_lsg,protection_lsg),
  pmin(health_lsg, shelter_lsg),
  pmin(protection_lsg,shelter_lsg)
)

msni <- pmax(msni, largest_lsg_combination_hps)

# If higher than current, replace with highest from wash, FSL or capacity gap
msni <- pmax(msni, wash_lsg,fsl_lsg,capacity_gaps)


#4.A is `msni` is currently `1` _and_ one of health, protection, shelter and education is larger than `3` ?

max_of_remaining <- c(custom_input_indices,list(health_lsg,protection_lsg,shelter_lsg,education_lsg)) %>%
  as.data.frame(stringsAsFactors = FALSE) %>%
  apply(1,max,na.rm = FALSE)
max_of_remaining_larger_equal_3 <- max_of_remaining >= 3
note_applies<-(msni ==1) & max_of_remaining_larger_equal_3

# 4.B set `msni` to `2` where condition above applies
msni[note_applies]<- 2

Dictionary for non-programmers:



mabafaba/msni19 documentation built on Aug. 28, 2019, 9:51 a.m.