Skip to contents

It allows the observations to be ordered by different methods (default percentile rank), and in consideration of domains grouping indicators.

Usage

vulnerability_index(
  data,
  direct = NULL,
  inverse = NULL,
  table = NULL,
  weighted = TRUE,
  domains = "default",
  level = NULL,
  ordered = TRUE,
  method = "percent_rank",
  complete = TRUE,
  na.rm = FALSE
)

Arguments

data

A dataframe containing the variables that will be analyzed.

direct

A vector indicating the name of the variables that contribute directly to the vulnerability index.

inverse

A vector indicating the name of the variables that contribute inversely to the vulnerability index.

table

A dataframe indicating the variables "Codename", "Direction", "Domain" and "Geographic_scale" as a minimum. If this argument is specified, it is no longer necessary to specify the direct and inverse arguments.

weighted

A logical value indicating whether the "Domain" information is used for the index calculation.

domains

A vector indicating the names of the domains grouping the variables of interest. If the argument "table" containing the variable "Domain" is used, only "default" is indicated in this argument.

level

A vector indicating the level of analysis. It currently supports 3 values:"departamental", "provincial", and "distrital".

ordered

A logical value indicating whether the cases analyzed will be ordered from highest to lowest.

method

A vector indicating the analysis method used for the index. Currently only "percent_rank" is supported.

complete

If true, the results table will show all the variables that the dataframe has in addition to the computations performed.

na.rm

A logical value indicating whether cases where missing values are eliminated.

Value

A tibble containing the variables analyzed by the function.

Examples

if (FALSE) {
Sigma_Dom1 <- matrix(rep(c(1, runif(4, 0.65, 0.9)), 4),
                     4, 4, byrow = TRUE)

Sigma_Dom2 <- matrix(rep(c(1, runif(4, 0.65, 0.9)), 4),
                     4, 4, byrow = TRUE)

Dom1 <- as.data.frame(MASS::mvrnorm(100, rep(0, 4), Sigma_Dom1))
Dom2 <- as.data.frame(MASS::mvrnorm(100, rep(0, 4), Sigma_Dom2))
colnames(Dom2) <- paste0("V", 5:8)

df_example <- data.frame(distr = paste0("distr", 1:100))
df_example <- cbind(df_example, Dom1, Dom2)

table_var <- data.frame(
  Codename = paste0("V", 1:8),
  Direction = "Direct",
  Domain = c(rep("Dom1", 4), rep("Dom2", 4)),
  Geographic_scale = "Distrital"
)

vulnerability_index(df_example, table = table_var,
                    level = "distrital", na.rm = TRUE,
                    method = "pca")


vulnerability_index(df_example, table = table_var,
                    level = "distrital", na.rm = TRUE,
                    method = "percent_rank")
}