diff --git a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN-tidyverse.R b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN-tidyverse.R new file mode 100644 index 0000000..1e43d2d --- /dev/null +++ b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN-tidyverse.R @@ -0,0 +1,96 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Consolidated Approach for Reporting Indicators of Food Security (CARI) +# CALCULATE CARI using FCS, rCSI, LCS and ECMEN +#------------------------------------------------------------------------------# + +# Note that there are two ways to calculate CARI - using ECMEN or FES. This syntax +# file is for calculating CARI using ECMEN (version excluding assistance). However, +# please navigate to the script for CARI using FES as relevant. +# Guidance on CARI can be found here: +# https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. + +# Note: this syntax file is based on the assumption that the scripts of the various +# indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, ECMEN) have +# already been run. You can find these scripts here: +# https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +# The following variables should have been defined before running this file: +# FCSCat21 and/or FCSCat28 +# rCSI +# Max_coping_behaviourFS +# ECMEN_exclAsst +# ECMEN_exclAsst_SMEB. + +library(tidyverse) +library(labelled) +library(expss) + +# Load data +data <- read_csv("~/GitHub/RAMResourcesScripts/Static/CARI_FS_Sample_Survey.csv") + +# Assign variable and value labels +var_label(data$FCSCat21) <- "FCS Categories (21/35 thresholds)" +var_label(data$rCSI) <- "Reduced Coping Strategies Index" +var_label(data$Max_coping_behaviourFS) <- "Max Coping Behaviour (FS)" +var_label(data$ECMEN_exclAsst) <- "Expenditure Capacity Measure Excluding Assistance" +var_label(data$ECMEN_exclAsst_SMEB) <- "Expenditure Capacity Measure Excluding Assistance (SMEB)" + +# Process FCS for CARI computation +data <- data %>% + mutate(FCS_4pt = recode(FCSCat21, `1` = 4, `2` = 3, `3` = 1), + FCS_4pt = ifelse(rCSI >= 4 & FCS_4pt == 1, 2, FCS_4pt)) + +val_lab(data$FCS_4pt) <- num_lab(" + 1 Acceptable + 2 Acceptable and rCSI>4 + 3 Borderline + 4 Poor +") + +# Process ECMEN for CARI computation +data <- data %>% + mutate(ECMEN_MEB = case_when( + ECMEN_exclAsst == 1 ~ 1, + ECMEN_exclAsst == 0 & ECMEN_exclAsst_SMEB == 1 ~ 2, + ECMEN_exclAsst == 0 & ECMEN_exclAsst_SMEB == 0 ~ 3 + ), + ECMEN_class_4pt = recode(ECMEN_MEB, `1` = 1, `2` = 3, `3` = 4)) + +val_lab(data$ECMEN_class_4pt) <- num_lab(" + 1 Least vulnerable + 3 Vulnerable + 4 Highly vulnerable +") + +# Computation of CARI +data <- data %>% + mutate(Mean_coping_capacity_ECMEN = rowMeans(select(., Max_coping_behaviourFS, ECMEN_class_4pt), na.rm = TRUE), + CARI_unrounded_ECMEN = rowMeans(select(., FCS_4pt, Mean_coping_capacity_ECMEN), na.rm = TRUE), + CARI_ECMEN = round(CARI_unrounded_ECMEN)) + +var_label(data$CARI_ECMEN) <- "CARI classification (using ECMEN)" +val_lab(data$CARI_ECMEN) <- num_lab(" + 1 Food secure + 2 Marginally food secure + 3 Moderately food insecure + 4 Severely food insecure +") + +# Frequencies of CARI_ECMEN +cari_ecmen_freq <- data %>% + count(CARI_ECMEN) %>% + mutate(percentage = n / sum(n) * 100) +print(cari_ecmen_freq) + +# Create population distribution table +pop_distribution_table <- data %>% + group_by(ECMEN_class_4pt, FCS_4pt, Max_coping_behaviourFS) %>% + summarise(count = n()) %>% + mutate(percentage = count / sum(count) * 100) +print(pop_distribution_table) + +# Drop variables that are not needed +data <- data %>% + select(-ECMEN_MEB, -Mean_coping_capacity_ECMEN, -CARI_unrounded_ECMEN) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.do b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.do index e884a43..d95e229 100644 --- a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.do +++ b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.do @@ -1,28 +1,29 @@ -*** ----------------------------------------------------------------------------------------------------------------* - -*** WFP Standard Scripts -*** Consolidated Approach for Reporting Indicators of Food Security (CARI) -*** CALCULATE CARI using FCS, rCSI, LCS and ECMEN - -*** ----------------------------------------------------------------------------------------------------------------* -/* -Note that there are two ways to calculate CARI - using ECMEN or FES. This syntax file is for calculating CARI using ECMEN (version excluding assistance). However, please navigate to the script for CARI using FES as relevant. -Guidance on CARI can be found here: https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. - -Note: this syntax file is based on the assumption that the scripts of the various indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, ECMEN) have already been run. -You can find these scripts here: https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. -The following variables should have been defined before running this file: - FCSCat21 and/or FCSCat28 - rCSI - Max_coping_behaviourFS - ECMEN_exclAsst - ECMEN_exclAsst_SMEB. -*/ - - -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Consolidated Approach for Reporting Indicators of Food Security (CARI) +* CALCULATE CARI using FCS, rCSI, LCS and ECMEN +*------------------------------------------------------------------------------* + +* Note that there are two ways to calculate CARI - using ECMEN or FES. This syntax +* file is for calculating CARI using ECMEN (version excluding assistance). However, +* please navigate to the script for CARI using FES as relevant. +* Guidance on CARI can be found here: +* https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. + +* Note: this syntax file is based on the assumption that the scripts of the various +* indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, ECMEN) have +* already been run. You can find these scripts here: +* https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +* The following variables should have been defined before running this file: +* FCSCat21 and/or FCSCat28 +* rCSI +* Max_coping_behaviourFS +* ECMEN_exclAsst +* ECMEN_exclAsst_SMEB. + +*------------------------------------------------------------------------------* * Process FCS for CARI computation -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* * Create FCS_4pt for CARI calculation. recode FCSCat21 (1=4) (2=3) (3=1), generate(FCS_4pt) @@ -30,17 +31,17 @@ label variable FCS_4pt "4pt FCG" label define FCS_4pt 1 "Acceptable" 3 "Borderline" 4 "Poor" label values FCS_4pt FCS_4pt -*-------------------------------------------------------------------------------* -* Combine rCSI with FCS_4pt for CARI calculation (current consumption) -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* +* Combine rCSI with FCS_4pt for CARI calculation (current consumption) +*------------------------------------------------------------------------------* recode FCS_4pt (1=2) if rCSI >= 4 label define FCS_4pt_lbl 1 "Acceptable" 2 "Acceptable and rCSI>4" 3 "Borderline" 4 "Poor" label values FCS_4pt FCS_4pt_lbl -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* * Process ECMEN for CARI computation -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* * Recode ECMEN. gen ECMEN_MEB = . @@ -54,9 +55,9 @@ label variable ECMEN_class_4pt "ECMEN 4pt" label define ECMEN_class_4pt_lbl 1 "Least vulnerable" 3 "Vulnerable" 4 "Highly vulnerable" label values ECMEN_class_4pt ECMEN_class_4pt_lbl -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* * Computation of CARI -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* egen Mean_coping_capacity_ECMEN = rowmean(Max_coping_behaviourFS ECMEN_class_4pt) egen CARI_unrounded_ECMEN = rowmean(FCS_4pt Mean_coping_capacity_ECMEN) @@ -67,11 +68,14 @@ label values CARI_ECMEN CARI_ECMEN_lbl tabulate CARI_ECMEN -* Create population distribution table, to explore how the domains interact within the different food security categories -table ( ECMEN_class_4pt) (FCS_4pt Max_coping_behaviourFS ), statistic(percent, across(Max_coping_behaviourFS)) nototal +* Create population distribution table to explore how the domains interact within +* the different food security categories. +table (ECMEN_class_4pt) (FCS_4pt Max_coping_behaviourFS), statistic(percent, across(Max_coping_behaviourFS)) nototal -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* * Drop variables that are not needed -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* drop ECMEN_MEB Mean_coping_capacity_ECMEN CARI_unrounded_ECMEN + +* End of Scripts \ No newline at end of file diff --git a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.py b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.py new file mode 100644 index 0000000..f7d428a --- /dev/null +++ b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.py @@ -0,0 +1,69 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Consolidated Approach for Reporting Indicators of Food Security (CARI) +# CALCULATE CARI using FCS, rCSI, LCS and ECMEN +#------------------------------------------------------------------------------# + +# Note that there are two ways to calculate CARI - using ECMEN or FES. This syntax +# file is for calculating CARI using ECMEN (version excluding assistance). However, +# please navigate to the script for CARI using FES as relevant. +# Guidance on CARI can be found here: +# https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. + +# Note: this syntax file is based on the assumption that the scripts of the various +# indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, ECMEN) have +# already been run. You can find these scripts here: +# https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +# The following variables should have been defined before running this file: +# FCSCat21 and/or FCSCat28 +# rCSI +# Max_coping_behaviourFS +# ECMEN_exclAsst +# ECMEN_exclAsst_SMEB. + +import pandas as pd +import numpy as np + +# Load data +data = pd.read_csv("~/GitHub/RAMResourcesScripts/Static/CARI_FS_Sample_Survey.csv") + +# Process FCS for CARI computation +data['FCS_4pt'] = data['FCSCat21'].replace({1: 4, 2: 3, 3: 1}) +data.loc[data['rCSI'] >= 4, 'FCS_4pt'] = 2 + +# Process ECMEN for CARI computation +data['ECMEN_MEB'] = np.where(data['ECMEN_exclAsst'] == 1, 1, + np.where((data['ECMEN_exclAsst'] == 0) & (data['ECMEN_exclAsst_SMEB'] == 1), 2, + np.where((data['ECMEN_exclAsst'] == 0) & (data['ECMEN_exclAsst_SMEB'] == 0), 3, np.nan))) + +data['ECMEN_class_4pt'] = data['ECMEN_MEB'].replace({1: 1, 2: 3, 3: 4}) + +# Computation of CARI +data['Mean_coping_capacity_ECMEN'] = data[['Max_coping_behaviourFS', 'ECMEN_class_4pt']].mean(axis=1, skipna=True) +data['CARI_unrounded_ECMEN'] = data[['FCS_4pt', 'Mean_coping_capacity_ECMEN']].mean(axis=1, skipna=True) +data['CARI_ECMEN'] = data['CARI_unrounded_ECMEN'].round().astype(int) + +# Label mappings +fcs_4pt_labels = {1: "Acceptable", 2: "Acceptable and rCSI>4", 3: "Borderline", 4: "Poor"} +ecmen_class_4pt_labels = {1: "Least vulnerable", 3: "Vulnerable", 4: "Highly vulnerable"} +cari_ecmen_labels = {1: "Food secure", 2: "Marginally food secure", 3: "Moderately food insecure", 4: "Severely food insecure"} + +data['FCS_4pt'] = data['FCS_4pt'].map(fcs_4pt_labels) +data['ECMEN_class_4pt'] = data['ECMEN_class_4pt'].map(ecmen_class_4pt_labels) +data['CARI_ECMEN'] = data['CARI_ECMEN'].map(cari_ecmen_labels) + +# Frequencies of CARI_ECMEN +cari_ecmen_freq = data['CARI_ECMEN'].value_counts(normalize=True).reset_index() +cari_ecmen_freq.columns = ['CARI_ECMEN', 'percentage'] +cari_ecmen_freq['percentage'] *= 100 +print(cari_ecmen_freq) + +# Create population distribution table +pop_distribution_table = data.pivot_table(index=['ECMEN_class_4pt', 'FCS_4pt'], columns='Max_coping_behaviourFS', aggfunc='size', fill_value=0) +pop_distribution_table = pop_distribution_table.div(pop_distribution_table.sum(axis=1), axis=0) * 100 +print(pop_distribution_table) + +# Drop variables that are not needed +data.drop(columns=['ECMEN_MEB', 'Mean_coping_capacity_ECMEN', 'CARI_unrounded_ECMEN'], inplace=True) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.sps b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.sps index b6a9722..3ee2efb 100644 --- a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.sps +++ b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-ECMEN.sps @@ -1,91 +1,96 @@ -* Encoding: UTF-8. - -*** ----------------------------------------------------------------------------------------------------------------* - -*** WFP Standard Scripts -*** Consolidated Approach for Reporting Indicators of Food Security (CARI) -*** CALCULATE CARI using FCS, rCSI, LCS and ECMEN - -*** ----------------------------------------------------------------------------------------------------------------* - -*Note that there are two ways to calculate CARI - using ECMEN or FES. This syntax file is for calculating CARI using ECMEN (version excluding assistance). However, please navigate to the script for CARI using FES as relevant. -* Guidance on CARI can be found here: https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Consolidated Approach for Reporting Indicators of Food Security (CARI) +* CALCULATE CARI using FCS, rCSI, LCS and ECMEN +*------------------------------------------------------------------------------* + +* Note that there are two ways to calculate CARI - using ECMEN or FES. This syntax +* file is for calculating CARI using ECMEN (version excluding assistance). However, +* please navigate to the script for CARI using FES as relevant. +* Guidance on CARI can be found here: +* https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. + +* Note: this syntax file is based on the assumption that the scripts of the various +* indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, ECMEN) have +* already been run. You can find these scripts here: +* https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +* The following variables should have been defined before running this file: +* FCSCat21 and/or FCSCat28 +* rCSI +* Max_coping_behaviourFS +* ECMEN_exclAsst +* ECMEN_exclAsst_SMEB. + +*------------------------------------------------------------------------------* +* Process FCS for CARI computation +*------------------------------------------------------------------------------* -*Note: this syntax file is based on the assumption that the scripts of the various indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, ECMEN) have already been run. -* You can find these scripts here: https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. -*The following variables should have been defined before running this file: - FCSCat21 and/or FCSCat28 - rCSI - Max_coping_behaviourFS - ECMEN_exclAsst - ECMEN_exclAsst_SMEB. +* Important note: pay attention to the threshold used by your CO when selecting the +* syntax (FCSCat21 or FCSCat28). In this example, the 21-35 threshold is used. -*-------------------------------------------------------------------------------* -* Process FCS for CARI computation -*-------------------------------------------------------------------------------* - -* Important note: pay attention to the threshold used by your CO when selecting the syntax (FCSCat21 or FCSCat28). In this example, the 21-35 treshold is used. - - *** Create FCS_4pt for CARI calculation. -Recode FCSCat21 (1=4) (2=3) (3=1) INTO FCS_4pt. -Variable labels FCS_4pt '4pt FCG'. -Value labels FCS_4pt 1.00 'Acceptable' 3.00 'Borderline' 4.00 'Poor'. +* Create FCS_4pt for CARI calculation. +RECODE FCSCat21 (1=4) (2=3) (3=1) INTO FCS_4pt. +VARIABLE LABELS FCS_4pt '4pt FCG'. +VALUE LABELS FCS_4pt 1 'Acceptable' 3 'Borderline' 4 'Poor'. EXECUTE. -*-------------------------------------------------------------------------------* -* Combine rCSI with FCS_4pt for CARI calculation (current consumption) -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* +* Combine rCSI with FCS_4pt for CARI calculation (current consumption) +*------------------------------------------------------------------------------* -Do if (rCSI >= 4). -Recode FCS_4pt (1=2). -End if. +DO IF (rCSI >= 4). + RECODE FCS_4pt (1=2). +END IF. EXECUTE. -Value labels FCS_4pt 1.00 'Acceptable' 2.00 ' Acceptable and rCSI>4' 3.00 'Borderline' 4.00 'Poor'. +VALUE LABELS FCS_4pt 1 'Acceptable' 2 'Acceptable and rCSI>4' 3 'Borderline' 4 'Poor'. EXECUTE. -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* * Process ECMEN for CARI computation -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* + +* Recode ECMEN. +IF (ECMEN_exclAsst = 1) ECMEN_MEB = 1. +IF (ECMEN_exclAsst = 0 & ECMEN_exclAsst_SMEB = 1) ECMEN_MEB = 2. +IF (ECMEN_exclAsst = 0 & ECMEN_exclAsst_SMEB = 0) ECMEN_MEB = 3. -***Recode ECMEN. -IF (ECMEN_exclAsst=1) ECMEN_MEB=1. -IF (ECMEN_exclAsst=0 & ECMEN_exclAsst_SMEB=1) ECMEN_MEB=2. -IF (ECMEN_exclAsst=0 & ECMEN_exclAsst_SMEB=0) ECMEN_MEB=3. +* Recode the `ECMEN_MEB' variable into a 4pt scale for CARI console. +RECODE ECMEN_MEB (1=1) (2=3) (3=4) INTO ECMEN_class_4pt. +VARIABLE LABELS ECMEN_class_4pt 'ECMEN 4pt'. +EXECUTE. -***Recode the `ECMEN_MEB' variable into a 4pt scale for CARI console. -Recode ECMEN_MEB (1=1) (2=3) (3=4) INTO ECMEN_class_4pt. -Variable labels ECMEN_class_4pt 'ECMEN 4pt'. +VALUE LABELS ECMEN_class_4pt 1 'Least vulnerable' 3 'Vulnerable' 4 'Highly vulnerable'. EXECUTE. - -Value labels ECMEN_class_4pt 1.00 'Least vulnerable' 3.00 'Vulnerable' 4.00 'Highly vulnerable'. -EXECUTE. -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* * Computation of CARI -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* -Compute Mean_coping_capacity_ECMEN = MEAN (Max_coping_behaviourFS, ECMEN_class_4pt). -Compute CARI_unrounded_ECMEN = MEAN (FCS_4pt, Mean_coping_capacity_ECMEN). -Compute CARI_ECMEN = RND (CARI_unrounded_ECMEN). -Variable labels CARI_ECMEN 'CARI classification (using ECMEN)'. +COMPUTE Mean_coping_capacity_ECMEN = MEAN(Max_coping_behaviourFS, ECMEN_class_4pt). +COMPUTE CARI_unrounded_ECMEN = MEAN(FCS_4pt, Mean_coping_capacity_ECMEN). +COMPUTE CARI_ECMEN = RND(CARI_unrounded_ECMEN). +VARIABLE LABELS CARI_ECMEN 'CARI classification (using ECMEN)'. EXECUTE. -Value labels CARI_ECMEN 1 'Food secure' 2 'Marginally food secure' 3 'Moderately food insecure' 4 'Severely food insecure'. +VALUE LABELS CARI_ECMEN 1 'Food secure' 2 'Marginally food secure' 3 'Moderately food insecure' 4 'Severely food insecure'. EXECUTE. -Frequencies CARI_ECMEN. +FREQUENCIES CARI_ECMEN. -***create population distribution table, to to explore how the domains interact within the different food security categories. +* Create population distribution table to explore how the domains interact within +* the different food security categories. CTABLES - /VLABELS VARIABLES= ECMEN_class_4pt FCS_4pt Max_coping_behaviourFS DISPLAY=LABEL + /VLABELS VARIABLES=ECMEN_class_4pt FCS_4pt Max_coping_behaviourFS DISPLAY=LABEL /TABLE ECMEN_class_4pt [C] BY FCS_4pt [C] > Max_coping_behaviourFS [C][ROWPCT.COUNT PCT40.1] - /CATEGORIES VARIABLES= ECMEN_class_4pt ORDER=A KEY=VALUE EMPTY=EXCLUDE + /CATEGORIES VARIABLES=ECMEN_class_4pt ORDER=A KEY=VALUE EMPTY=EXCLUDE /CATEGORIES VARIABLES=FCS_4pt Max_coping_behaviourFS ORDER=A KEY=VALUE EMPTY=INCLUDE. -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* * Drop variables that are not needed -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* DELETE VARIABLES ECMEN_MEB Mean_coping_capacity_ECMEN CARI_unrounded_ECMEN. EXECUTE. + +* End of Scripts \ No newline at end of file diff --git a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES-tidyverse.R b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES-tidyverse.R new file mode 100644 index 0000000..11b859b --- /dev/null +++ b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES-tidyverse.R @@ -0,0 +1,71 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Consolidated Approach for Reporting Indicators of Food Security (CARI) +# CALCULATE CARI using FCS, rCSI, LCS and FES +#------------------------------------------------------------------------------# + +# Note that there are two ways to calculate CARI - using ECMEN or FES. This script +# is for calculating CARI using FES. However, please navigate to the script +# for CARI using ECMEN as relevant. +# Guidance on CARI can be found here: +# https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. + +# Note: this script is based on the assumption that the scripts of the various +# indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, FES) have +# already been run. You can find these scripts here: +# https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +# The following variables should have been defined before running this file: +# FCSCat21 and/or FCSCat28 +# rCSI +# Max_coping_behaviourFS +# FES +# Foodexp_4pt. + +library(dplyr) +library(tidyr) +library(labelled) + +# Create FCS_4pt for CARI calculation +data <- data %>% + mutate(FCS_4pt = case_when( + FCSCat21 == 1 ~ 4, + FCSCat21 == 2 ~ 3, + FCSCat21 == 3 ~ 1 + )) + +var_label(data$FCS_4pt) <- "4pt FCG" +val_labels(data$FCS_4pt) <- c(Acceptable = 1, Borderline = 3, Poor = 4) + +# Combine rCSI with FCS_4pt for CARI calculation (current consumption) +data <- data %>% + mutate(FCS_4pt = if_else(rCSI >= 4 & FCS_4pt == 1, 2, FCS_4pt)) + +val_labels(data$FCS_4pt) <- c(Acceptable = 1, `Acceptable and rCSI>4` = 2, Borderline = 3, Poor = 4) + +# Computation of CARI +data <- data %>% + mutate( + Mean_coping_capacity_FES = rowMeans(select(., Max_coping_behaviourFS, Foodexp_4pt), na.rm = TRUE), + CARI_unrounded_FES = rowMeans(select(., FCS_4pt, Mean_coping_capacity_FES), na.rm = TRUE), + CARI_FES = round(CARI_unrounded_FES) + ) + +var_label(data$CARI_FES) <- "CARI classification (using FES)" +val_labels(data$CARI_FES) <- c(`Food secure` = 1, `Marginally food secure` = 2, `Moderately food insecure` = 3, `Severely food insecure` = 4) + +# Frequency table of CARI_FES +table(data$CARI_FES) + +# Create population distribution table to explore how the domains interact within the different food security categories +table_all <- data %>% + select(Foodexp_4pt, FCS_4pt, Max_coping_behaviourFS) %>% + gather(key = "Variable", value = "Value") %>% + group_by(Variable, Value) %>% + summarise(Count = n()) %>% + spread(key = "Variable", value = "Count") + +# Drop variables that are not needed +data <- data %>% + select(-Mean_coping_capacity_FES, -CARI_unrounded_FES) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.do b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.do index 0e1bcd4..e9545c0 100644 --- a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.do +++ b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.do @@ -1,23 +1,25 @@ -*** ----------------------------------------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Consolidated Approach for Reporting Indicators of Food Security (CARI) +* CALCULATE CARI using FCS, rCSI, LCS and FES +*------------------------------------------------------------------------------* -*** WFP Standard Scripts -*** Consolidated Approach for Reporting Indicators of Food Security (CARI) -*** CALCULATE CARI using FCS, rCSI, LCS and FES +* Note that there are two ways to calculate CARI - using ECMEN or FES. This syntax +* file is for calculating CARI using FES. However, please navigate to the script +* for CARI using ECMEN as relevant. +* Guidance on CARI can be found here: +* https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. -*** ----------------------------------------------------------------------------------------------------------------* -/* -Note that there are two ways to calculate CARI - using ECMEN or FES. This syntax file is for calculating CARI using FES. However, please navigate to the script for CARI using ECMEN as relevant. -Guidance on CARI can be found here: https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. - -Note: this syntax file is based on the assumption that the scripts of the various indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, FES) have already been run. -You can find these scripts here: https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. -The following variables should have been defined before running this file: - FCSCat21 and/or FCSCat28 - rCSI - Max_coping_behaviourFS - FES - Foodexp_4pt. -*/ +* Note: this syntax file is based on the assumption that the scripts of the various +* indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, FES) have +* already been run. You can find these scripts here: +* https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +* The following variables should have been defined before running this file: +* FCSCat21 and/or FCSCat28 +* rCSI +* Max_coping_behaviourFS +* FES +* Foodexp_4pt. *-------------------------------------------------------------------------------* * Process FCS for CARI computation @@ -26,8 +28,8 @@ The following variables should have been defined before running this file: * Create FCS_4pt for CARI calculation. recode FCSCat21 (1=4) (2=3) (3=1), generate(FCS_4pt) label variable FCS_4pt "4pt FCG" -label define FCS_4pt 1 "Acceptable" 3 "Borderline" 4 "Poor" -label values FCS_4pt FCS_4pt +label define FCS_4pt_lbl 1 "Acceptable" 3 "Borderline" 4 "Poor" +label values FCS_4pt FCS_4pt_lbl *-------------------------------------------------------------------------------* * Combine rCSI with FCS_4pt for CARI calculation (current consumption) @@ -50,10 +52,14 @@ label values CARI_FES CARI_FES_lbl tabulate CARI_FES -* Create population distribution table, to explore how the domains interact within the different food security categories -table (Foodexp_4pt) (FCS_4pt Max_coping_behaviourFS ), statistic(percent, across(Max_coping_behaviourFS)) nototal +* Create population distribution table to explore how the domains interact within +* the different food security categories. +table (Foodexp_4pt) (FCS_4pt Max_coping_behaviourFS), statistic(percent, across(Max_coping_behaviourFS)) nototal *-------------------------------------------------------------------------------* * Drop variables that are not needed *-------------------------------------------------------------------------------* + drop Mean_coping_capacity_FES CARI_unrounded_FES + +* End of Scripts \ No newline at end of file diff --git a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.py b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.py new file mode 100644 index 0000000..87af05c --- /dev/null +++ b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.py @@ -0,0 +1,52 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Consolidated Approach for Reporting Indicators of Food Security (CARI) +# CALCULATE CARI using FCS, rCSI, LCS and FES +#------------------------------------------------------------------------------# + +# Note that there are two ways to calculate CARI - using ECMEN or FES. This script +# is for calculating CARI using FES. However, please navigate to the script +# for CARI using ECMEN as relevant. +# Guidance on CARI can be found here: +# https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. + +# Note: this script is based on the assumption that the scripts of the various +# indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, FES) have +# already been run. You can find these scripts here: +# https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +# The following variables should have been defined before running this file: +# FCSCat21 and/or FCSCat28 +# rCSI +# Max_coping_behaviourFS +# FES +# Foodexp_4pt. + +import pandas as pd +import numpy as np + +# Create FCS_4pt for CARI calculation +data['FCS_4pt'] = data['FCSCat21'].replace({1: 4, 2: 3, 3: 1}) +data['FCS_4pt'].replace({1: 'Acceptable', 3: 'Borderline', 4: 'Poor'}, inplace=True) + +# Combine rCSI with FCS_4pt for CARI calculation (current consumption) +data.loc[data['rCSI'] >= 4, 'FCS_4pt'] = data['FCS_4pt'].replace({'Acceptable': 'Acceptable and rCSI>4'}) + +data['FCS_4pt'].replace({'Acceptable': 1, 'Acceptable and rCSI>4': 2, 'Borderline': 3, 'Poor': 4}, inplace=True) + +# Computation of CARI +data['Mean_coping_capacity_FES'] = data[['Max_coping_behaviourFS', 'Foodexp_4pt']].mean(axis=1) +data['CARI_unrounded_FES'] = data[['FCS_4pt', 'Mean_coping_capacity_FES']].mean(axis=1) +data['CARI_FES'] = data['CARI_unrounded_FES'].round().astype(int) + +data['CARI_FES'].replace({1: 'Food secure', 2: 'Marginally food secure', 3: 'Moderately food insecure', 4: 'Severely food insecure'}, inplace=True) + +# Frequency table of CARI_FES +print(data['CARI_FES'].value_counts()) + +# Create population distribution table to explore how the domains interact within the different food security categories +distribution_table = pd.crosstab(index=[data['Foodexp_4pt']], columns=[data['FCS_4pt'], data['Max_coping_behaviourFS']], normalize='index') + +# Drop variables that are not needed +data.drop(columns=['Mean_coping_capacity_FES', 'CARI_unrounded_FES'], inplace=True) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.sps b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.sps index 0feb118..98a59f3 100644 --- a/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.sps +++ b/Indicators/Consolidated-Approach-to-Reporting-Indicators-of-Food-Security/CARI-FES.sps @@ -1,65 +1,68 @@ -* Encoding: UTF-8. - -*** ----------------------------------------------------------------------------------------------------------------* - -*** WFP Standard Scripts -*** Consolidated Approach for Reporting Indicators of Food Security (CARI) -*** CALCULATE CARI using FCS, rCSI, LCS and FES - -*** ----------------------------------------------------------------------------------------------------------------* - -*Note that there are two ways to calculate CARI - using ECMEN or FES. This syntax file is for calculating CARI using FES. However, please navigate to the script for CARI using ECMEN as relevant. -* Guidance on CARI can be found here: https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. - -*Note: this syntax file is based on the assumption that the scripts of the various indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, FES) have already been run. -* You can find these scripts here: https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. -*The following variables should have been defined before running this file: - FCSCat21 and/or FCSCat28 - rCSI - Max_coping_behaviourFS - FES - Foodexp_4pt. +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Consolidated Approach for Reporting Indicators of Food Security (CARI) +* CALCULATE CARI using FCS, rCSI, LCS and FES +*------------------------------------------------------------------------------* + +* Note that there are two ways to calculate CARI - using ECMEN or FES. This syntax +* file is for calculating CARI using FES. However, please navigate to the script +* for CARI using ECMEN as relevant. +* Guidance on CARI can be found here: +* https://www.wfp.org/publications/consolidated-approach-reporting-indicators-food-security-cari-guidelines. + +* Note: this syntax file is based on the assumption that the scripts of the various +* indicators that compose this version of the CARI (FCS, rCSI, LCS-FS, FES) have +* already been run. You can find these scripts here: +* https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +* The following variables should have been defined before running this file: +* FCSCat21 and/or FCSCat28 +* rCSI +* Max_coping_behaviourFS +* FES +* Foodexp_4pt. *-------------------------------------------------------------------------------* * Process FCS for CARI computation *-------------------------------------------------------------------------------* -* Important note: pay attention to the threshold used by your CO when selecting the syntax (FCSCat21 or FCSCat28). In this example, the 21-35 treshold is used. +* Important note: pay attention to the threshold used by your CO when selecting +* the syntax (FCSCat21 or FCSCat28). In this example, the 21-35 threshold is used. - *** Create FCS_4pt for CARI calculation. -Recode FCSCat21 (1=4) (2=3) (3=1) INTO FCS_4pt. -Variable labels FCS_4pt '4pt FCG'. -Value labels FCS_4pt 1.00 'Acceptable' 3.00 'Borderline' 4.00 'Poor'. +* Create FCS_4pt for CARI calculation. +RECODE FCSCat21 (1=4) (2=3) (3=1) INTO FCS_4pt. +VARIABLE LABELS FCS_4pt '4pt FCG'. +VALUE LABELS FCS_4pt 1.00 'Acceptable' 3.00 'Borderline' 4.00 'Poor'. EXECUTE. *-------------------------------------------------------------------------------* * Combine rCSI with FCS_4pt for CARI calculation (current consumption) *-------------------------------------------------------------------------------* -Do if (rCSI >= 4). -Recode FCS_4pt (1=2). -End if. +DO IF (rCSI >= 4). + RECODE FCS_4pt (1=2). +END IF. EXECUTE. -Value labels FCS_4pt 1.00 'Acceptable' 2.00 ' Acceptable and rCSI>4' 3.00 'Borderline' 4.00 'Poor'. +VALUE LABELS FCS_4pt 1.00 'Acceptable' 2.00 'Acceptable and rCSI>4' 3.00 'Borderline' 4.00 'Poor'. EXECUTE. *-------------------------------------------------------------------------------* * Computation of CARI *-------------------------------------------------------------------------------* -Compute Mean_coping_capacity_FES = MEAN(Max_coping_behaviourFS, Foodexp_4pt). -Compute CARI_unrounded_FES = MEAN(FCS_4pt, Mean_coping_capacity_FES). -Compute CARI_FES = RND(CARI_unrounded_FES). +COMPUTE Mean_coping_capacity_FES = MEAN(Max_coping_behaviourFS, Foodexp_4pt). +COMPUTE CARI_unrounded_FES = MEAN(FCS_4pt, Mean_coping_capacity_FES). +COMPUTE CARI_FES = RND(CARI_unrounded_FES). +VARIABLE LABELS CARI_FES 'CARI classification (using FES)'. EXECUTE. -Value labels CARI_FES 1 'Food secure' 2 'Marginally food secure' 3 'Moderately food insecure' 4 'Severely food insecure'. +VALUE LABELS CARI_FES 1 'Food secure' 2 'Marginally food secure' 3 'Moderately food insecure' 4 'Severely food insecure'. EXECUTE. -Frequencies CARI_FES. - -***create population distribution table, to to explore how the domains interact within the different food security categories +FREQUENCIES CARI_FES. +* Create population distribution table to explore how the domains interact within +* the different food security categories. CTABLES /VLABELS VARIABLES=Foodexp_4pt FCS_4pt Max_coping_behaviourFS DISPLAY=LABEL /TABLE Foodexp_4pt [C] BY FCS_4pt [C] > Max_coping_behaviourFS [C][ROWPCT.COUNT PCT40.1] @@ -72,3 +75,5 @@ CTABLES DELETE VARIABLES Mean_coping_capacity_FES CARI_unrounded_FES. EXECUTE. + +* End of Scripts \ No newline at end of file diff --git a/Indicators/ENA-vulnerability-classification/ENA_vulnerability.R b/Indicators/ENA-vulnerability-classification/ENA_vulnerability.R new file mode 100644 index 0000000..7a1fb3b --- /dev/null +++ b/Indicators/ENA-vulnerability-classification/ENA_vulnerability.R @@ -0,0 +1,64 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# ENA Vulnerability Classification Methodology +#------------------------------------------------------------------------------# + +# NOTES: +# This script is based on the vulnerability classification methodology recommended +# for Essential Needs Assessments. This classification is based on the combination +# of three indicators: the Economic Capacity to Meet Essential Needs (ECMEN), the +# Livelihood Coping Index for Essential Needs (LCS-EN), and the Food Consumption +# Score (FCS). However, the vulnerability classification methodology can be adapted +# based on programme needs. See chapter 6 of the Essential Needs Assessment guidance +# note for more details. + +# The script assumes that ECMEN, LCS-EN, and FCS have already been computed based +# on standard scripts available in github: +# https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +# The following variables should have been defined before running this file: +# ECMEN_exclAsst +# ECMEN_exclAsst_SMEB +# Max_coping_behaviourEN +# FCSCat28 +# FCSCat21 + +library(dplyr) + +# Create temporary variables +data <- data %>% + mutate(temp_ECMEN_categ = case_when( + ECMEN_exclAsst == 1 ~ 0, + ECMEN_exclAsst == 0 & ECMEN_exclAsst_SMEB == 1 ~ 1, + ECMEN_exclAsst_SMEB == 0 ~ 2, + TRUE ~ NA_real_ + )) + +val_labels(data$temp_ECMEN_categ) <- c('above MEB' = 0, 'below MEB and above SMEB' = 1, 'below SMEB' = 2) + +# Declare whether the 21 or 28 threshold is used for FCS +data <- data %>% + mutate(temp_FCS_categ = FCSCat21) # replace with FCSCat28 if the CO uses 28 threshold + +# Classify households into vulnerability categories +data <- data %>% + mutate(ENA_vulnerability = case_when( + temp_ECMEN_categ == 2 | Max_coping_behaviourEN == 4 | temp_FCS_categ == 1 ~ 3, + temp_ECMEN_categ == 2 & Max_coping_behaviourEN == 4 ~ 4, + temp_ECMEN_categ == 2 & temp_FCS_categ == 1 ~ 4, + Max_coping_behaviourEN == 4 & temp_FCS_categ == 1 ~ 4, + temp_ECMEN_categ == 1 & Max_coping_behaviourEN < 4 & temp_FCS_categ %in% 2:3 ~ 2, + temp_ECMEN_categ == 0 & Max_coping_behaviourEN == 3 & temp_FCS_categ %in% 2:3 ~ 2, + temp_ECMEN_categ == 0 & Max_coping_behaviourEN < 3 & temp_FCS_categ == 2 ~ 2, + temp_ECMEN_categ == 0 & Max_coping_behaviourEN < 3 & temp_FCS_categ == 3 ~ 1, + TRUE ~ NA_real_ + )) + +val_labels(data$ENA_vulnerability) <- c('Not vulnerable' = 1, 'Moderately vulnerable' = 2, 'Highly vulnerable' = 3, 'Extremely vulnerable' = 4) + +# Calculate the population share in vulnerability tiers +table(data$ENA_vulnerability) + +# Drop unnecessary variables +data <- data %>% select(-temp_ECMEN_categ, -temp_FCS_categ) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/ENA-vulnerability-classification/ENA_vulnerability.do b/Indicators/ENA-vulnerability-classification/ENA_vulnerability.do index b5a23cd..a32a7b9 100644 --- a/Indicators/ENA-vulnerability-classification/ENA_vulnerability.do +++ b/Indicators/ENA-vulnerability-classification/ENA_vulnerability.do @@ -1,63 +1,68 @@ -******************************************************************************** - * STATA Syntax for the ENA vulnerability classification methodology - ******************************************************************************* - -/* -NOTES: - -- This syntax file is based on the vulnerability classification methodology recommended for Essential Needs Assessments. This classification is based on the combination of three indicators: the Economic Capacity to Meet Essential Needs (ECMEN), the Livelihood Coping Index for Essential Needs (LCS-EN), and the Food Consumption Score (FCS). However, the vulnerability classification methodolgy can be adapted based on programme needs. See chapter 6 of the Essential Needs Assessment guidance note for more details. - -- The syntax files assumes that ECMEN, LCS-EN, and FCS have already been computed based on standard syntax available in github (https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators). The following variables should have been defined before running this file: - ECMEN_exclAsst - ECMEN_exclAsst_SMEB - Max_coping_behaviourEN - FCSCat28 - FCSCat21 -*/ - *------------------------------------------------------------------------------* -*1. Create temporary variables +* WFP Standardized Scripts +* ENA Vulnerability Classification Methodology *------------------------------------------------------------------------------* -*** Create a categorical variable for ECMEN that inform if a household is above MEB, betweeen MEB and SMEB, or below SMEB +* This syntax file is based on the vulnerability classification methodology +* recommended for Essential Needs Assessments. This classification is based on +* the combination of three indicators: the Economic Capacity to Meet Essential +* Needs (ECMEN), the Livelihood Coping Index for Essential Needs (LCS-EN), and +* the Food Consumption Score (FCS). However, the vulnerability classification +* methodology can be adapted based on programme needs. See chapter 6 of the +* Essential Needs Assessment guidance note for more details. + +* The syntax files assume that ECMEN, LCS-EN, and FCS have already been computed +* based on standard syntax available on GitHub: +* https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +* The following variables should have been defined before running this file: +* ECMEN_exclAsst +* ECMEN_exclAsst_SMEB +* Max_coping_behaviourEN +* FCSCat28 +* FCSCat21 +*------------------------------------------------------------------------------* +* 1. Create temporary variables +*------------------------------------------------------------------------------* +* Create a categorical variable for ECMEN that informs if a household is above MEB, +* between MEB and SMEB, or below SMEB gen temp_ECMEN_categ = . replace temp_ECMEN_categ = 0 if ECMEN_exclAsst == 1 replace temp_ECMEN_categ = 1 if ECMEN_exclAsst == 0 & ECMEN_exclAsst_SMEB == 1 replace temp_ECMEN_categ = 2 if ECMEN_exclAsst_SMEB == 0 -** Label the values +* Label the values label define ECMEN_categ 2 "below SMEB" 1 "below MEB and above SMEB" 0 "above MEB" label value temp_ECMEN_categ ECMEN_categ -*** Declare whether the 21 or 28 treshold is used for FCS -gen temp_FCS_categ = FCSCat21 // ! replace with FCSCat28 if the CO uses 28 treshold ! - +* Declare whether the 21 or 28 threshold is used for FCS +gen temp_FCS_categ = FCSCat21 // ! replace with FCSCat28 if the CO uses 28 threshold ! *------------------------------------------------------------------------------* -*2. Classify households into vulnerability categories +* 2. Classify households into vulnerability categories *------------------------------------------------------------------------------* - gen ENA_vulnerability = . -replace ENA_vulnerability = 3 if temp_ECMEN_categ == 2 | Max_coping_behaviourEN == 4 | temp_FCS_categ == 1 +replace ENA_vulnerability = 3 if temp_ECMEN_categ == 2 | Max_coping_behaviourEN == 4 | temp_FCS_categ == 1 -replace ENA_vulnerability = 4 if temp_ECMEN_categ == 2 & Max_coping_behaviourEN == 4 -replace ENA_vulnerability = 4 if temp_ECMEN_categ == 2 & temp_FCS_categ == 1 -replace ENA_vulnerability = 4 if Max_coping_behaviourEN == 4 & temp_FCS_categ == 1 +replace ENA_vulnerability = 4 if temp_ECMEN_categ == 2 & Max_coping_behaviourEN == 4 +replace ENA_vulnerability = 4 if temp_ECMEN_categ == 2 & temp_FCS_categ == 1 +replace ENA_vulnerability = 4 if Max_coping_behaviourEN == 4 & temp_FCS_categ == 1 -replace ENA_vulnerability = 2 if temp_ECMEN_categ == 1 & Max_coping_behaviourEN < 4 & inrange(temp_FCS_categ,2,3) -replace ENA_vulnerability = 2 if temp_ECMEN_categ == 0 & Max_coping_behaviourEN == 3 & inrange(temp_FCS_categ,2,3) -replace ENA_vulnerability = 2 if temp_ECMEN_categ == 0 & Max_coping_behaviourEN < 3 & temp_FCS_categ == 2 +replace ENA_vulnerability = 2 if temp_ECMEN_categ == 1 & Max_coping_behaviourEN < 4 & inrange(temp_FCS_categ, 2, 3) +replace ENA_vulnerability = 2 if temp_ECMEN_categ == 0 & Max_coping_behaviourEN == 3 & inrange(temp_FCS_categ, 2, 3) +replace ENA_vulnerability = 2 if temp_ECMEN_categ == 0 & Max_coping_behaviourEN < 3 & temp_FCS_categ == 2 -replace ENA_vulnerability = 1 if temp_ECMEN_categ == 0 & Max_coping_behaviourEN < 3 & temp_FCS_categ ==3 +replace ENA_vulnerability = 1 if temp_ECMEN_categ == 0 & Max_coping_behaviourEN < 3 & temp_FCS_categ == 3 * Label the variable label define vulnerability_tiers 1 "Not vulnerable" 2 "Moderately vulnerable" 3 "Highly vulnerable" 4 "Extremely vulnerable" label values ENA_vulnerability vulnerability_tiers -*** Calculate the population share in vulnerability tiers +* Calculate the population share in vulnerability tiers tab ENA_vulnerability -* drop unnecessary variables -drop temp_ECMEN_categ temp_FCS_categ \ No newline at end of file +* Drop unnecessary variables +drop temp_ECMEN_categ temp_FCS_categ + +* End of Scripts \ No newline at end of file diff --git a/Indicators/ENA-vulnerability-classification/ENA_vulnerability.py b/Indicators/ENA-vulnerability-classification/ENA_vulnerability.py new file mode 100644 index 0000000..5175f07 --- /dev/null +++ b/Indicators/ENA-vulnerability-classification/ENA_vulnerability.py @@ -0,0 +1,60 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# ENA Vulnerability Classification Methodology +#------------------------------------------------------------------------------# + +# NOTES: +# This script is based on the vulnerability classification methodology recommended +# for Essential Needs Assessments. This classification is based on the combination +# of three indicators: the Economic Capacity to Meet Essential Needs (ECMEN), the +# Livelihood Coping Index for Essential Needs (LCS-EN), and the Food Consumption +# Score (FCS). However, the vulnerability classification methodology can be adapted +# based on programme needs. See chapter 6 of the Essential Needs Assessment guidance +# note for more details. + +# The script assumes that ECMEN, LCS-EN, and FCS have already been computed based +# on standard scripts available in github: +# https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +# The following variables should have been defined before running this file: +# ECMEN_exclAsst +# ECMEN_exclAsst_SMEB +# Max_coping_behaviourEN +# FCSCat28 +# FCSCat21 + +import pandas as pd +import numpy as np + +# Create temporary variables +data['temp_ECMEN_categ'] = np.where(data['ECMEN_exclAsst'] == 1, 0, + np.where(data['ECMEN_exclAsst'] == 0 & data['ECMEN_exclAsst_SMEB'] == 1, 1, + np.where(data['ECMEN_exclAsst_SMEB'] == 0, 2, np.nan))) + +data['temp_ECMEN_categ'] = data['temp_ECMEN_categ'].map({0: 'above MEB', 1: 'below MEB and above SMEB', 2: 'below SMEB'}) + +# Declare whether the 21 or 28 threshold is used for FCS +data['temp_FCS_categ'] = data['FCSCat21'] # replace with data['FCSCat28'] if the CO uses 28 threshold + +# Classify households into vulnerability categories +conditions = [ + (data['temp_ECMEN_categ'] == 2) | (data['Max_coping_behaviourEN'] == 4) | (data['temp_FCS_categ'] == 1), + (data['temp_ECMEN_categ'] == 2) & (data['Max_coping_behaviourEN'] == 4), + (data['temp_ECMEN_categ'] == 2) & (data['temp_FCS_categ'] == 1), + (data['Max_coping_behaviourEN'] == 4) & (data['temp_FCS_categ'] == 1), + (data['temp_ECMEN_categ'] == 1) & (data['Max_coping_behaviourEN'] < 4) & (data['temp_FCS_categ'].between(2, 3)), + (data['temp_ECMEN_categ'] == 0) & (data['Max_coping_behaviourEN'] == 3) & (data['temp_FCS_categ'].between(2, 3)), + (data['temp_ECMEN_categ'] == 0) & (data['Max_coping_behaviourEN'] < 3) & (data['temp_FCS_categ'] == 2), + (data['temp_ECMEN_categ'] == 0) & (data['Max_coping_behaviourEN'] < 3) & (data['temp_FCS_categ'] == 3) +] +choices = [3, 4, 4, 4, 2, 2, 2, 1] +data['ENA_vulnerability'] = np.select(conditions, choices, default=np.nan) + +data['ENA_vulnerability'] = data['ENA_vulnerability'].map({1: 'Not vulnerable', 2: 'Moderately vulnerable', 3: 'Highly vulnerable', 4: 'Extremely vulnerable'}) + +# Calculate the population share in vulnerability tiers +print(data['ENA_vulnerability'].value_counts(normalize=True) * 100) + +# Drop unnecessary variables +data.drop(columns=['temp_ECMEN_categ', 'temp_FCS_categ'], inplace=True) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/ENA-vulnerability-classification/ENA_vulnerability.sps b/Indicators/ENA-vulnerability-classification/ENA_vulnerability.sps index 2360f64..5e00b1c 100644 --- a/Indicators/ENA-vulnerability-classification/ENA_vulnerability.sps +++ b/Indicators/ENA-vulnerability-classification/ENA_vulnerability.sps @@ -1,30 +1,32 @@ -* Encoding: UTF-8. - -******************************************************************************** - * SPSS Syntax for the ENA vulnerability classification methodology - ******************************************************************************* - - -*NOTES: - -* This syntax file is based on the vulnerability classification methodology recommended for Essential Needs Assessments. -* This classification is based on the combination of three indicators: the Economic Capacity to Meet Essential Needs (ECMEN), the Livelihood Coping Index for Essential Needs (LCS-EN), and the Food Consumption Score (FCS). -*However, the vulnerability classification methodolgy can be adapted based on programme needs. See chapter 6 of the Essential Needs Assessment guidance note for more details. - -* The syntax files assumes that ECMEN, LCS-EN, and FCS have already been computed based on standard syntax available in - github (https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators). The following variables should have been defined before running this file: - ECMEN_exclAsst - ECMEN_exclAsst_SMEB - Max_coping_behaviourEN - FCSCat28 - FCSCat21 -*/ - -*------------------------------------------------------------------------------. +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* ENA Vulnerability Classification Methodology +*------------------------------------------------------------------------------* + +* This syntax file is based on the vulnerability classification methodology +* recommended for Essential Needs Assessments. This classification is based on +* the combination of three indicators: the Economic Capacity to Meet Essential +* Needs (ECMEN), the Livelihood Coping Index for Essential Needs (LCS-EN), and +* the Food Consumption Score (FCS). However, the vulnerability classification +* methodology can be adapted based on programme needs. See chapter 6 of the +* Essential Needs Assessment guidance note for more details. + +* The syntax files assume that ECMEN, LCS-EN, and FCS have already been computed +* based on standard syntax available on GitHub: +* https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Indicators. +* The following variables should have been defined before running this file: +* ECMEN_exclAsst +* ECMEN_exclAsst_SMEB +* Max_coping_behaviourEN +* FCSCat28 +* FCSCat21 + +*------------------------------------------------------------------------------* * 1. Create temporary variables. -*------------------------------------------------------------------------------. +*------------------------------------------------------------------------------* -* Create a categorical variable for ECMEN that informs if a household is above MEB, between MEB and SMEB, or below SMEB. +* Create a categorical variable for ECMEN that informs if a household is above MEB, +* between MEB and SMEB, or below SMEB. COMPUTE temp_ECMEN_categ = 0. IF (ECMEN_exclAsst = 1) temp_ECMEN_categ = 0. IF (ECMEN_exclAsst = 0 & ECMEN_exclAsst_SMEB = 1) temp_ECMEN_categ = 1. @@ -39,9 +41,9 @@ VALUE LABELS temp_ECMEN_categ * Declare whether the 21 or 28 threshold is used for FCS. COMPUTE temp_FCS_categ = FCSCat21 /* ! replace with FCSCat28 if the CO uses 28 threshold ! */. -*------------------------------------------------------------------------------. +*------------------------------------------------------------------------------* * 2. Classify households into vulnerability categories. -*------------------------------------------------------------------------------. +*------------------------------------------------------------------------------* COMPUTE ENA_vulnerability = 3. IF (temp_ECMEN_categ = 2 | Max_coping_behaviourEN = 4 | temp_FCS_categ = 1) ENA_vulnerability = 3. @@ -69,3 +71,4 @@ FREQUENCIES ENA_vulnerability. * Drop unnecessary variables. DELETE VARIABLES temp_ECMEN_categ temp_FCS_categ. +* End of Scripts \ No newline at end of file diff --git a/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Excluding_Assistance_Assessment.do b/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Excluding_Assistance_Assessment.do index ef3bf62..ecc457a 100644 --- a/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Excluding_Assistance_Assessment.do +++ b/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Excluding_Assistance_Assessment.do @@ -6,7 +6,7 @@ * Detailed guidance on the computation of the ECMEN can be found here: https://docs.wfp.org/api/documents/WFP-0000145644/download/ -*Note 1: In the version used for assessment: a) the household economic capacity aggregate should not include the value of consumed in-kind assistance gifts; b) the value of the cash assistance received from the humanitarian sector should be deducted from the household economic capacity aggregate (but only for the estimated share of the cash assistance that is used for consumption, when available). +* Note 1: In the version used for assessment: a) the household economic capacity aggregate should not include the value of consumed in-kind assistance gifts; b) the value of the cash assistance received from the humanitarian sector should be deducted from the household economic capacity aggregate (but only for the estimated share of the cash assistance that is used for consumption, when available). * Note 2: the computation of the ECMEN requires having already established a Minimum Expenditure Basket (MEB). More information on MEBs can be found here: https://docs.wfp.org/api/documents/WFP-0000074198/download/ diff --git a/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Excluding_Assistance_Assessment_tidyverse.R b/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Excluding_Assistance_Assessment_tidyverse.R index 2b57948..184f0d0 100644 --- a/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Excluding_Assistance_Assessment_tidyverse.R +++ b/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Excluding_Assistance_Assessment_tidyverse.R @@ -37,10 +37,9 @@ getwd() # Display current working directory dir() # Display working directory content # change path to your working folder -setwd("/Users/nicolewu/Desktop") - +#setwd("/Users/nicolewu/Desktop") # add sample data -data <- read_csv("sample_data.csv") #read.spss and other formats can also work +#data <- read_csv("sample_data.csv") #read.spss and other formats can also work # Set switches ----------------------------------------------------------------- diff --git a/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Including_Assistance_Monitoring_tidyverse.R b/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Including_Assistance_Monitoring_tidyverse.R index b86aef8..ff3b760 100644 --- a/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Including_Assistance_Monitoring_tidyverse.R +++ b/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_Including_Assistance_Monitoring_tidyverse.R @@ -28,10 +28,9 @@ getwd() # Display current working directory dir() # Display working directory content # change path to your working folder -setwd("/Users/nicolewu/Desktop") - +#setwd("/Users/nicolewu/Desktop") # add sample data -data <- read_csv("sample_data.csv") #read.spss and other formats can also work +#data <- read_csv("sample_data.csv") #read.spss and other formats can also work # Set switches ----------------------------------------------------------------- diff --git a/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_excluding_assistance_indicator_calculation.py b/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_excluding_assistance_indicator_calculation.py new file mode 100644 index 0000000..c48efa7 --- /dev/null +++ b/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_excluding_assistance_indicator_calculation.py @@ -0,0 +1,310 @@ +#------------------------------------------------------------------------------# +# WFP RAM Standardized Scripts +# Calculating and Summarising ECMEN +# (Excluding Assistance Version - Assessments) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# + +import pandas as pd +import numpy as np + +# Load Sample Data ------------------------------------------------------------# +#df = pd.read_csv("ECMEN_Sample_Survey.csv") +#print(df.columns) # Display var names for the entire data base + +# Initialize columns with their respective labels +columns_food = { + 'HHExpFCer_Purch_MN_7D': 'Expenditures on cereals', + 'HHExpFCer_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - cereals', + 'HHExpFCer_Own_MN_7D': 'Value of consumed own production - cereals', + 'HHExpFTub_Purch_MN_7D': 'Expenditures on tubers', + 'HHExpFTub_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - tubers', + 'HHExpFTub_Own_MN_7D': 'Value of consumed own production - tubers', + 'HHExpFPuls_Purch_MN_7D': 'Expenditures on pulses & nuts', + 'HHExpFPuls_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - pulses and nuts', + 'HHExpFPuls_Own_MN_7D': 'Value of consumed own production - pulses & nuts', + 'HHExpFVeg_Purch_MN_7D': 'Expenditures on vegetables', + 'HHExpFVeg_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - vegetables', + 'HHExpFVeg_Own_MN_7D': 'Value of consumed own production - vegetables', + 'HHExpFFrt_Purch_MN_7D': 'Expenditures on fruits', + 'HHExpFFrt_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - fruits', + 'HHExpFFrt_Own_MN_7D': 'Value of consumed own production - fruits', + 'HHExpFAnimMeat_Purch_MN_7D': 'Expenditures on meat', + 'HHExpFAnimMeat_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - meat', + 'HHExpFAnimMeat_Own_MN_7D': 'Value of consumed own production - meat', + 'HHExpFAnimFish_Purch_MN_7D': 'Expenditures on fish', + 'HHExpFAnimFish_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - fish', + 'HHExpFAnimFish_Own_MN_7D': 'Value of consumed own production - fish', + 'HHExpFFats_Purch_MN_7D': 'Expenditures on fats', + 'HHExpFFats_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - fats', + 'HHExpFFats_Own_MN_7D': 'Value of consumed own production - fats', + 'HHExpFDairy_Purch_MN_7D': 'Expenditures on milk/dairy products', + 'HHExpFDairy_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - milk/dairy products', + 'HHExpFDairy_Own_MN_7D': 'Value of consumed own production - milk/dairy products', + 'HHExpFEgg_Purch_MN_7D': 'Expenditures on eggs', + 'HHExpFEgg_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - eggs', + 'HHExpFEgg_Own_MN_7D': 'Value of consumed own production - eggs', + 'HHExpFSgr_Purch_MN_7D': 'Expenditures on sugar/confectionery/desserts', + 'HHExpFSgr_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - sugar/confectionery/desserts', + 'HHExpFSgr_Own_MN_7D': 'Value of consumed own production - sugar/confectionery/desserts', + 'HHExpFCond_Purch_MN_7D': 'Expenditures on condiments', + 'HHExpFCond_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - condiments', + 'HHExpFCond_Own_MN_7D': 'Value of consumed own production - condiments', + 'HHExpFBev_Purch_MN_7D': 'Expenditures on beverages', + 'HHExpFBev_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - beverages', + 'HHExpFBev_Own_MN_7D': 'Value of consumed own production - beverages', + 'HHExpFOut_Purch_MN_7D': 'Expenditures on snacks/meals prepared outside', + 'HHExpFOut_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - snacks/meals prepared outside', + 'HHExpFOut_Own_MN_7D': 'Value of consumed own production - snacks/meals prepared outside' +} + +columns_non_food_1m = { + 'HHExpNFHyg_Purch_MN_1M': 'Expenditures on hygiene', + 'HHExpNFHyg_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - hygiene', + 'HHExpNFTransp_Purch_MN_1M': 'Expenditures on transport', + 'HHExpNFTransp_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - transport', + 'HHExpNFFuel_Purch_MN_1M': 'Expenditures on fuel', + 'HHExpNFFuel_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - fuel', + 'HHExpNFWat_Purch_MN_1M': 'Expenditures on water', + 'HHExpNFWat_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - water', + 'HHExpNFElec_Purch_MN_1M': 'Expenditures on electricity', + 'HHExpNFElec_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - electricity', + 'HHExpNFEnerg_Purch_MN_1M': 'Expenditures on energy (not electricity)', + 'HHExpNFEnerg_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - energy (not electricity)', + 'HHExpNFDwelSer_Purch_MN_1M': 'Expenditures on services related to dwelling', + 'HHExpNFDwelSer_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - services related to dwelling', + 'HHExpNFPhone_Purch_MN_1M': 'Expenditures on communication', + 'HHExpNFPhone_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - communication', + 'HHExpNFRecr_Purch_MN_1M': 'Expenditures on recreation', + 'HHExpNFRecr_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - recreation', + 'HHExpNFAlcTobac_Purch_MN_1M': 'Expenditures on alcohol/tobacco', + 'HHExpNFAlcTobac_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - alcohol/tobacco' +} + +columns_non_food_6m = { + 'HHExpNFMedServ_Purch_MN_6M': 'Expenditures on health services', + 'HHExpNFMedServ_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - health services', + 'HHExpNFMedGood_Purch_MN_6M': 'Expenditures on medicines and health products', + 'HHExpNFMedGood_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - medicines and health products', + 'HHExpNFCloth_Purch_MN_6M': 'Expenditures on clothing and footwear', + 'HHExpNFCloth_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - clothing and footwear', + 'HHExpNFEduFee_Purch_MN_6M': 'Expenditures on education services', + 'HHExpNFEduFee_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - education services', + 'HHExpNFEduGood_Purch_MN_6M': 'Expenditures on education goods', + 'HHExpNFEduGood_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - education goods', + 'HHExpNFRent_Purch_MN_6M': 'Expenditures on rent', + 'HHExpNFRent_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - rent', + 'HHExpNFHHSoft_Purch_MN_6M': 'Expenditures on household supplies', + 'HHExpNFHHSoft_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - household supplies', + 'HHExpNFHHDur_Purch_MN_6M': 'Expenditures on durable household goods', + 'HHExpNFHHDur_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - durable household goods', + 'HHExpNFHHTrans_Purch_MN_6M': 'Expenditures on household transport', + 'HHExpNFHHTrans_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - household transport', + 'HHExpNFHHComP_Purch_MN_6M': 'Expenditures on household communications and postal services', + 'HHExpNFHHComP_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - household communications and postal services', + 'HHExpNFOthDom_Purch_MN_6M': 'Expenditures on other domestic services', + 'HHExpNFOthDom_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - other domestic services', + 'HHExpNFOthOcc_Purch_MN_6M': 'Expenditures on other occasional expenses', + 'HHExpNFOthOcc_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - other occasional expenses' +} + +# Define columns for food and non-food expenditures and consumption by source +columns_f_purch_7d = [ + 'HHExpFCer_Purch_MN_7D', + 'HHExpFTub_Purch_MN_7D', + 'HHExpFPuls_Purch_MN_7D', + 'HHExpFVeg_Purch_MN_7D', + 'HHExpFFrt_Purch_MN_7D', + 'HHExpFAnimMeat_Purch_MN_7D', + 'HHExpFAnimFish_Purch_MN_7D', + 'HHExpFFats_Purch_MN_7D', + 'HHExpFDairy_Purch_MN_7D', + 'HHExpFEgg_Purch_MN_7D', + 'HHExpFSgr_Purch_MN_7D', + 'HHExpFCond_Purch_MN_7D', + 'HHExpFBev_Purch_MN_7D', + 'HHExpFOut_Purch_MN_7D', +] + +columns_f_giftaid_7d = [ + 'HHExpFCer_GiftAid_MN_7D', + 'HHExpFTub_GiftAid_MN_7D', + 'HHExpFPuls_GiftAid_MN_7D', + 'HHExpFVeg_GiftAid_MN_7D', + 'HHExpFFrt_GiftAid_MN_7D', + 'HHExpFAnimMeat_GiftAid_MN_7D', + 'HHExpFAnimFish_GiftAid_MN_7D', + 'HHExpFFats_GiftAid_MN_7D', + 'HHExpFDairy_GiftAid_MN_7D', + 'HHExpFEgg_GiftAid_MN_7D', + 'HHExpFSgr_GiftAid_MN_7D', + 'HHExpFCond_GiftAid_MN_7D', + 'HHExpFBev_GiftAid_MN_7D', + 'HHExpFOut_GiftAid_MN_7D', +] + +columns_f_own_7d = [ + 'HHExpFCer_Own_MN_7D', + 'HHExpFTub_Own_MN_7D', + 'HHExpFPuls_Own_MN_7D', + 'HHExpFVeg_Own_MN_7D', + 'HHExpFFrt_Own_MN_7D', + 'HHExpFAnimMeat_Own_MN_7D', + 'HHExpFAnimFish_Own_MN_7D', + 'HHExpFFats_Own_MN_7D', + 'HHExpFDairy_Own_MN_7D', + 'HHExpFEgg_Own_MN_7D', + 'HHExpFSgr_Own_MN_7D', + 'HHExpFCond_Own_MN_7D', + 'HHExpFBev_Own_MN_7D', + 'HHExpFOut_Own_MN_7D', +] + +columns_nf_purch_30d = [ + 'HHExpNFHyg_Purch_MN_1M', + 'HHExpNFTransp_Purch_MN_1M', + 'HHExpNFFuel_Purch_MN_1M', + 'HHExpNFWat_Purch_MN_1M', + 'HHExpNFElec_Purch_MN_1M', + 'HHExpNFEnerg_Purch_MN_1M', + 'HHExpNFDwelSer_Purch_MN_1M', + 'HHExpNFPhone_Purch_MN_1M', + 'HHExpNFRecr_Purch_MN_1M', + 'HHExpNFAlcTobac_Purch_MN_1M' +] + +columns_nf_purch_6m = [ + 'HHExpNFMedServ_Purch_MN_6M', + 'HHExpNFMedGood_Purch_MN_6M', + 'HHExpNFCloth_Purch_MN_6M', + 'HHExpNFEduFee_Purch_MN_6M', + 'HHExpNFEduGood_Purch_MN_6M', + 'HHExpNFRent_Purch_MN_6M', + 'HHExpNFHHSoft_Purch_MN_6M', + 'HHExpNFHHMaint_Purch_MN_6M' +] + +columns_nf_giftaid_30d = [ + 'HHExpNFHyg_GiftAid_MN_1M', + 'HHExpNFTransp_GiftAid_MN_1M', + 'HHExpNFFuel_GiftAid_MN_1M', + 'HHExpNFWat_GiftAid_MN_1M', + 'HHExpNFElec_GiftAid_MN_1M', + 'HHExpNFEnerg_GiftAid_MN_1M', + 'HHExpNFDwelSer_GiftAid_MN_1M', + 'HHExpNFPhone_GiftAid_MN_1M', + 'HHExpNFRecr_GiftAid_MN_1M', + 'HHExpNFAlcTobac_GiftAid_MN_1M' +] + +columns_nf_giftaid_6m = [ + 'HHExpNFMedServ_GiftAid_MN_6M', + 'HHExpNFMedGood_GiftAid_MN_6M', + 'HHExpNFCloth_GiftAid_MN_6M', + 'HHExpNFEduFee_GiftAid_MN_6M', + 'HHExpNFEduGood_GiftAid_MN_6M', + 'HHExpNFRent_GiftAid_MN_6M', + 'HHExpNFHHSoft_GiftAid_MN_6M', + 'HHExpNFHHMaint_GiftAid_MN_6M' +] + +# _____________________________ FOOD - Last 7 days ______________________________________ + +# _______ FOOD (cash/credit) _______ +# Calculate monthly food expenditure (cash/credit) +df['HHExp_Food_Purch_MN_1M'] = df[columns_f_purch_7d].sum(axis=1) # Sum purchases of all food groups in the last 7 days +df['HHExp_Food_Purch_MN_1M'] = df['HHExp_Food_Purch_MN_1M'] / 7 * 30 # Express 30 days in monthly terms + +# _______ FOOD (gift/aid) _______ +# Calculate monthly food expenditure (gift/aid) +df['HHExp_Food_GiftAid_MN_1M'] = df[columns_f_giftaid_7d].sum(axis=1) # Sum consumption of gift/aid for all food groups in the last 7 days +df['HHExp_Food_GiftAid_MN_1M'] = df['HHExp_Food_GiftAid_MN_1M'] / 7 * 30 # Express 30 days in monthly terms + +# _______ FOOD (own-production) _______ +# Calculate monthly food expenditure (onw-production) +df['HHExp_Food_Own_MN_1M'] = df[columns_f_own_7d].sum(axis=1) # Sum consumption of own-production for all food groups in the last 7 days +df['HHExp_Food_Own_MN_1M'] = df['HHExp_Food_Own_MN_1M'] / 7 * 30 # Express 30 days in monthly terms + +# _______ FOOD (all sources) _______ +# Calculate total monthly food expenditure (cash/credit & gift/aid & own-production) +df['HHExpF_1M'] = df[['HHExp_Food_Purch_MN_1M', 'HHExp_Food_GiftAid_MN_1M', 'HHExp_Food_Own_MN_1M']].sum(axis=1) + +# _____________________________ NON FOOD - Last 30 days & Last 6 months ______________________________________ + +# _______ NON-FOOD (cash/credit) _______ +# Calculate monthly non-food expenditure (cash/credit) +df['HHExpNFTotal_Purch_MN_30D'] = df[columns_nf_purch_30d].sum(axis=1) # Sum purchases of all food groups in the last 30 days +df['HHExpNFTotal_Purch_MN_6M'] = df[columns_nf_purch_6m].sum(axis=1) # Sum purchases of all food groups in the last 6 months +df['HHExpNFTotal_Purch_MN_6M'] = df['HHExpNFTotal_Purch_MN_6M'] / 6 # Express 6 months in monthly terms +df['HHExpNFTotal_Purch_MN_1M'] = df['HHExpNFTotal_Purch_MN_30D'] + df['HHExpNFTotal_Purch_MN_6M'] # Sum purchases of all non-food groups + +# _______ NON-FOOD (gift/aid) _______ +# Calculate monthly non-food expenditure (gift/aid) +# Note: Remember that for the version of ECMEN used for assessments (excluding assistance), +# the value of consumed in-kind assistance and gifts should be excluded from the household economic capacity aggregate. +# the calculation below is just for analytical purposes and will not be included in the calculation of ECMEN (Excluding assistance version) +df['HHExpNFTotal_GiftAid_MN_30D'] = df[columns_nf_giftaid_30d].sum(axis=1) # Sum consumption of gift/aid of all food groups in the last 30 days +df['HHExpNFTotal_GiftAid_MN_6M'] = df[columns_nf_giftaid_6m].sum(axis=1) # Sum consumption of gift/aid of all food groups in the last 6 months +df['HHExpNFTotal_GiftAid_MN_6M'] = df['HHExpNFTotal_GiftAid_MN_6M'] / 6 # Express 6 months in monthly terms +df['HHExpNFTotal_GiftAid_MN_1M'] = df['HHExpNFTotal_GiftAid_MN_30D'] + df['HHExpNFTotal_GiftAid_MN_6M'] # Sum consumption of gift/aid of all non-food groups + +# _______ NON-FOOD (all sources) _______ +# Calculate total monthly non-food expenditure (cash/credit & gift/aid) +df['HHExpNF_1M'] = df['HHExpNFTotal_Purch_MN_1M'] + df['HHExpNFTotal_GiftAid_MN_1M'] + +# _____________________________ ECONOMIC CAPACITY ______________________________________ +# Aggregate food expenditures and value of consumed food from own production +df['HHExpF_ECMEN'] = df[['HHExp_Food_Purch_MN_1M', 'HHExp_Food_Own_MN_1M']].sum(axis=1) + +# For Non-FOOD only expenditures are considered +df['HHExpNF_ECMEN'] = df['HHExpNFTotal_Purch_MN_1M'] + +# Aggregate food and non-food +df['HHExp_ECMEN'] = df[['HHExpF_ECMEN', 'HHExpNF_ECMEN']].sum(axis=1) + +# After deudcting the value of in-kind assistance from gift/aid, we should deduct cash assistance +# Sum the amount of cash assistance received by WFP and other humanitarian partners +df['HHAsstCBTRec'] = df[['HHAsstWFPCBTRecTot', 'HHAsstUNNGOCBTRecTot']].sum(axis=1) + +# Express in monthly terms if the assistance is reported in the last 3 monts recall period +df['HHAsstCBTRec_1M'] = df['HHAsstCBTRec'] / 3 + +# Estimate the median share of assistance used for consumption +HHAsstCBTCShare_med = df['HHAsstCBTCShare'].median() + +# Multiply the cash assistance received by the median share used for consumption +df['HHAsstCBTRec_Cons_1M'] = df['HHAsstCBTRec_1M'] * (HHAsstCBTCShare_med / 100) + +# Deduct the cash assistance from the household economic capacity +df['HHExp_ECMEN'] = df['HHExp_ECMEN'] - df['HHAsstCBTRec_Cons_1M'].fillna(0) + +# 5. Express household economic capacity in per capita terms +df['PCExp_ECMEN'] = df['HHExp_ECMEN'] / df['HHSize'] + +# _____________________________ CALCULATE ECMEN ______________________________________ +# Using MEB +# Define Dummy MEB +df['MEB'] = 3000 + +# Define variable indicating if PC Household Economic Capacity is equal or greater than MEB +df['ECMEN_exclAsst'] = df['PCExp_ECMEN'] > df['MEB'] + +# Using SMEB (when applicable) +# Define Dummy SMEB +df['SMEB'] = 1200 + +# Define variable indicating if PC Household Economic Capacity is equal or greater than SMEB +df['ECMEN_exclAsst_SMEB'] = df['PCExp_ECMEN'] > df['SMEB'] + +# _____________________________ LABEL VARIABLES (IF NEEDED) ______________________________________ +df['HHAsstWFPCBTRecTot'].rename("Amount of cash assistance received from WFP - last 3 months", inplace=True) +df['HHAsstUNNGOCBTRecTot'].rename("Amount of cash assistance received by other humanitarian partners - last 3 months", inplace=True) +df['HHAsstCBTRec_Cons_1M'].rename("Amount of cash assistance received from WFP and other humanitarian partners - last 3 months", inplace=True) +df['HHAsstCBTCShare'].rename("Share of cash assistance spent on consumption", inplace=True) +df['ECMEN_exclAsst'] = df['ECMEN_exclAsst'].map({True: 'Above MEB', False: 'Below MEB'}) +df['ECMEN_exclAsst_SMEB'] = df['ECMEN_exclAsst_SMEB'].map({True: 'Above SMEB', False: 'Below SMEB'}) +df['HHExp_ECMEN'].rename("Household Economic Capacity - monthly", inplace=True) +df['PCExp_ECMEN'].rename("Household Economic Capacity per capita - monthly", inplace=True) +df['ECMEN_exclAsst'].rename("Economic capacity to meet essential needs - excluding assistance", inplace=True) +df['ECMEN_exclAsst_SMEB'].rename("Economic capacity to meet essential needs (Usin SMEB) - excluding assistance", inplace=True) \ No newline at end of file diff --git a/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_including_assistance_indicator_calculation.py b/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_including_assistance_indicator_calculation.py new file mode 100644 index 0000000..8838b9c --- /dev/null +++ b/Indicators/Economic-Capacity-to-Meet-Essential-Needs/ECMEN_including_assistance_indicator_calculation.py @@ -0,0 +1,289 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating and Summarising ECMEN +# (Including Assistance Version - Monitoring) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# + +import pandas as pd +import numpy as np + +# Load Sample Data ------------------------------------------------------------# +#df = pd.read_csv("ECMEN_Sample_Survey.csv") +#print(df.columns) # Display var names for the entire data base + +# Initialize columns with their respective labels +columns_food = { + 'HHExpFCer_Purch_MN_7D': 'Expenditures on cereals', + 'HHExpFCer_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - cereals', + 'HHExpFCer_Own_MN_7D': 'Value of consumed own production - cereals', + 'HHExpFTub_Purch_MN_7D': 'Expenditures on tubers', + 'HHExpFTub_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - tubers', + 'HHExpFTub_Own_MN_7D': 'Value of consumed own production - tubers', + 'HHExpFPuls_Purch_MN_7D': 'Expenditures on pulses & nuts', + 'HHExpFPuls_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - pulses and nuts', + 'HHExpFPuls_Own_MN_7D': 'Value of consumed own production - pulses & nuts', + 'HHExpFVeg_Purch_MN_7D': 'Expenditures on vegetables', + 'HHExpFVeg_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - vegetables', + 'HHExpFVeg_Own_MN_7D': 'Value of consumed own production - vegetables', + 'HHExpFFrt_Purch_MN_7D': 'Expenditures on fruits', + 'HHExpFFrt_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - fruits', + 'HHExpFFrt_Own_MN_7D': 'Value of consumed own production - fruits', + 'HHExpFAnimMeat_Purch_MN_7D': 'Expenditures on meat', + 'HHExpFAnimMeat_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - meat', + 'HHExpFAnimMeat_Own_MN_7D': 'Value of consumed own production - meat', + 'HHExpFAnimFish_Purch_MN_7D': 'Expenditures on fish', + 'HHExpFAnimFish_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - fish', + 'HHExpFAnimFish_Own_MN_7D': 'Value of consumed own production - fish', + 'HHExpFFats_Purch_MN_7D': 'Expenditures on fats', + 'HHExpFFats_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - fats', + 'HHExpFFats_Own_MN_7D': 'Value of consumed own production - fats', + 'HHExpFDairy_Purch_MN_7D': 'Expenditures on milk/dairy products', + 'HHExpFDairy_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - milk/dairy products', + 'HHExpFDairy_Own_MN_7D': 'Value of consumed own production - milk/dairy products', + 'HHExpFEgg_Purch_MN_7D': 'Expenditures on eggs', + 'HHExpFEgg_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - eggs', + 'HHExpFEgg_Own_MN_7D': 'Value of consumed own production - eggs', + 'HHExpFSgr_Purch_MN_7D': 'Expenditures on sugar/confectionery/desserts', + 'HHExpFSgr_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - sugar/confectionery/desserts', + 'HHExpFSgr_Own_MN_7D': 'Value of consumed own production - sugar/confectionery/desserts', + 'HHExpFCond_Purch_MN_7D': 'Expenditures on condiments', + 'HHExpFCond_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - condiments', + 'HHExpFCond_Own_MN_7D': 'Value of consumed own production - condiments', + 'HHExpFBev_Purch_MN_7D': 'Expenditures on beverages', + 'HHExpFBev_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - beverages', + 'HHExpFBev_Own_MN_7D': 'Value of consumed own production - beverages', + 'HHExpFOut_Purch_MN_7D': 'Expenditures on snacks/meals prepared outside', + 'HHExpFOut_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - snacks/meals prepared outside', + 'HHExpFOut_Own_MN_7D': 'Value of consumed own production - snacks/meals prepared outside' +} + +columns_non_food_1m = { + 'HHExpNFHyg_Purch_MN_1M': 'Expenditures on hygiene', + 'HHExpNFHyg_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - hygiene', + 'HHExpNFTransp_Purch_MN_1M': 'Expenditures on transport', + 'HHExpNFTransp_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - transport', + 'HHExpNFFuel_Purch_MN_1M': 'Expenditures on fuel', + 'HHExpNFFuel_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - fuel', + 'HHExpNFWat_Purch_MN_1M': 'Expenditures on water', + 'HHExpNFWat_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - water', + 'HHExpNFElec_Purch_MN_1M': 'Expenditures on electricity', + 'HHExpNFElec_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - electricity', + 'HHExpNFEnerg_Purch_MN_1M': 'Expenditures on energy (not electricity)', + 'HHExpNFEnerg_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - energy (not electricity)', + 'HHExpNFDwelSer_Purch_MN_1M': 'Expenditures on services related to dwelling', + 'HHExpNFDwelSer_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - services related to dwelling', + 'HHExpNFPhone_Purch_MN_1M': 'Expenditures on communication', + 'HHExpNFPhone_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - communication', + 'HHExpNFRecr_Purch_MN_1M': 'Expenditures on recreation', + 'HHExpNFRecr_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - recreation', + 'HHExpNFAlcTobac_Purch_MN_1M': 'Expenditures on alcohol/tobacco', + 'HHExpNFAlcTobac_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - alcohol/tobacco' +} + +columns_non_food_6m = { + 'HHExpNFMedServ_Purch_MN_6M': 'Expenditures on health services', + 'HHExpNFMedServ_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - health services', + 'HHExpNFMedGood_Purch_MN_6M': 'Expenditures on medicines and health products', + 'HHExpNFMedGood_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - medicines and health products', + 'HHExpNFCloth_Purch_MN_6M': 'Expenditures on clothing and footwear', + 'HHExpNFCloth_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - clothing and footwear', + 'HHExpNFEduFee_Purch_MN_6M': 'Expenditures on education services', + 'HHExpNFEduFee_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - education services', + 'HHExpNFEduGood_Purch_MN_6M': 'Expenditures on education goods', + 'HHExpNFEduGood_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - education goods', + 'HHExpNFRent_Purch_MN_6M': 'Expenditures on rent', + 'HHExpNFRent_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - rent', + 'HHExpNFHHSoft_Purch_MN_6M': 'Expenditures on household supplies', + 'HHExpNFHHSoft_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - household supplies', + 'HHExpNFHHDur_Purch_MN_6M': 'Expenditures on durable household goods', + 'HHExpNFHHDur_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - durable household goods', + 'HHExpNFHHTrans_Purch_MN_6M': 'Expenditures on household transport', + 'HHExpNFHHTrans_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - household transport', + 'HHExpNFHHComP_Purch_MN_6M': 'Expenditures on household communications and postal services', + 'HHExpNFHHComP_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - household communications and postal services', + 'HHExpNFOthDom_Purch_MN_6M': 'Expenditures on other domestic services', + 'HHExpNFOthDom_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - other domestic services', + 'HHExpNFOthOcc_Purch_MN_6M': 'Expenditures on other occasional expenses', + 'HHExpNFOthOcc_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - other occasional expenses' +} + +# Define columns for food and non-food expenditures and consumption by source +columns_f_purch_7d = [ + 'HHExpFCer_Purch_MN_7D', + 'HHExpFTub_Purch_MN_7D', + 'HHExpFPuls_Purch_MN_7D', + 'HHExpFVeg_Purch_MN_7D', + 'HHExpFFrt_Purch_MN_7D', + 'HHExpFAnimMeat_Purch_MN_7D', + 'HHExpFAnimFish_Purch_MN_7D', + 'HHExpFFats_Purch_MN_7D', + 'HHExpFDairy_Purch_MN_7D', + 'HHExpFEgg_Purch_MN_7D', + 'HHExpFSgr_Purch_MN_7D', + 'HHExpFCond_Purch_MN_7D', + 'HHExpFBev_Purch_MN_7D', + 'HHExpFOut_Purch_MN_7D', +] + +columns_f_giftaid_7d = [ + 'HHExpFCer_GiftAid_MN_7D', + 'HHExpFTub_GiftAid_MN_7D', + 'HHExpFPuls_GiftAid_MN_7D', + 'HHExpFVeg_GiftAid_MN_7D', + 'HHExpFFrt_GiftAid_MN_7D', + 'HHExpFAnimMeat_GiftAid_MN_7D', + 'HHExpFAnimFish_GiftAid_MN_7D', + 'HHExpFFats_GiftAid_MN_7D', + 'HHExpFDairy_GiftAid_MN_7D', + 'HHExpFEgg_GiftAid_MN_7D', + 'HHExpFSgr_GiftAid_MN_7D', + 'HHExpFCond_GiftAid_MN_7D', + 'HHExpFBev_GiftAid_MN_7D', + 'HHExpFOut_GiftAid_MN_7D', +] + +columns_f_own_7d = [ + 'HHExpFCer_Own_MN_7D', + 'HHExpFTub_Own_MN_7D', + 'HHExpFPuls_Own_MN_7D', + 'HHExpFVeg_Own_MN_7D', + 'HHExpFFrt_Own_MN_7D', + 'HHExpFAnimMeat_Own_MN_7D', + 'HHExpFAnimFish_Own_MN_7D', + 'HHExpFFats_Own_MN_7D', + 'HHExpFDairy_Own_MN_7D', + 'HHExpFEgg_Own_MN_7D', + 'HHExpFSgr_Own_MN_7D', + 'HHExpFCond_Own_MN_7D', + 'HHExpFBev_Own_MN_7D', + 'HHExpFOut_Own_MN_7D', +] + +columns_nf_purch_30d = [ + 'HHExpNFHyg_Purch_MN_1M', + 'HHExpNFTransp_Purch_MN_1M', + 'HHExpNFFuel_Purch_MN_1M', + 'HHExpNFWat_Purch_MN_1M', + 'HHExpNFElec_Purch_MN_1M', + 'HHExpNFEnerg_Purch_MN_1M', + 'HHExpNFDwelSer_Purch_MN_1M', + 'HHExpNFPhone_Purch_MN_1M', + 'HHExpNFRecr_Purch_MN_1M', + 'HHExpNFAlcTobac_Purch_MN_1M' +] + +columns_nf_purch_6m = [ + 'HHExpNFMedServ_Purch_MN_6M', + 'HHExpNFMedGood_Purch_MN_6M', + 'HHExpNFCloth_Purch_MN_6M', + 'HHExpNFEduFee_Purch_MN_6M', + 'HHExpNFEduGood_Purch_MN_6M', + 'HHExpNFRent_Purch_MN_6M', + 'HHExpNFHHSoft_Purch_MN_6M', + 'HHExpNFHHMaint_Purch_MN_6M' +] + +columns_nf_giftaid_30d = [ + 'HHExpNFHyg_GiftAid_MN_1M', + 'HHExpNFTransp_GiftAid_MN_1M', + 'HHExpNFFuel_GiftAid_MN_1M', + 'HHExpNFWat_GiftAid_MN_1M', + 'HHExpNFElec_GiftAid_MN_1M', + 'HHExpNFEnerg_GiftAid_MN_1M', + 'HHExpNFDwelSer_GiftAid_MN_1M', + 'HHExpNFPhone_GiftAid_MN_1M', + 'HHExpNFRecr_GiftAid_MN_1M', + 'HHExpNFAlcTobac_GiftAid_MN_1M' +] + +columns_nf_giftaid_6m = [ + 'HHExpNFMedServ_GiftAid_MN_6M', + 'HHExpNFMedGood_GiftAid_MN_6M', + 'HHExpNFCloth_GiftAid_MN_6M', + 'HHExpNFEduFee_GiftAid_MN_6M', + 'HHExpNFEduGood_GiftAid_MN_6M', + 'HHExpNFRent_GiftAid_MN_6M', + 'HHExpNFHHSoft_GiftAid_MN_6M', + 'HHExpNFHHMaint_GiftAid_MN_6M' +] + +# _____________________________ FOOD - Last 7 days ______________________________________ + +# _______ FOOD (cash/credit) _______ +# Calculate monthly food expenditure (cash/credit) +df['HHExp_Food_Purch_MN_1M'] = df[columns_f_purch_7d].sum(axis=1) # Sum purchases of all food groups in the last 7 days +df['HHExp_Food_Purch_MN_1M'] = df['HHExp_Food_Purch_MN_1M'] / 7 * 30 # Express 30 days in monthly terms + +# _______ FOOD (gift/aid) _______ +# Calculate monthly food expenditure (gift/aid) +df['HHExp_Food_GiftAid_MN_1M'] = df[columns_f_giftaid_7d].sum(axis=1) # Sum consumption of gift/aid for all food groups in the last 7 days +df['HHExp_Food_GiftAid_MN_1M'] = df['HHExp_Food_GiftAid_MN_1M'] / 7 * 30 # Express 30 days in monthly terms + +# _______ FOOD (own-production) _______ +# Calculate monthly food expenditure (onw-production) +df['HHExp_Food_Own_MN_1M'] = df[columns_f_own_7d].sum(axis=1) # Sum consumption of own-production for all food groups in the last 7 days +df['HHExp_Food_Own_MN_1M'] = df['HHExp_Food_Own_MN_1M'] / 7 * 30 # Express 30 days in monthly terms + +# _______ FOOD (all sources) _______ +# Calculate total monthly food expenditure (cash/credit & gift/aid & own-production) +df['HHExpF_1M'] = df[['HHExp_Food_Purch_MN_1M', 'HHExp_Food_GiftAid_MN_1M', 'HHExp_Food_Own_MN_1M']].sum(axis=1) + +# _____________________________ NON FOOD - Last 30 days & Last 6 months ______________________________________ + +# _______ NON-FOOD (cash/credit) _______ +# Calculate monthly non-food expenditure (cash/credit) +df['HHExpNFTotal_Purch_MN_30D'] = df[columns_nf_purch_30d].sum(axis=1) # Sum purchases of all food groups in the last 30 days +df['HHExpNFTotal_Purch_MN_6M'] = df[columns_nf_purch_6m].sum(axis=1) # Sum purchases of all food groups in the last 6 months +df['HHExpNFTotal_Purch_MN_6M'] = df['HHExpNFTotal_Purch_MN_6M'] / 6 # Express 6 months in monthly terms +df['HHExpNFTotal_Purch_MN_1M'] = df['HHExpNFTotal_Purch_MN_30D'] + df['HHExpNFTotal_Purch_MN_6M'] # Sum purchases of all non-food groups + +# _______ NON-FOOD (gift/aid) _______ +# Calculate monthly non-food expenditure (gift/aid) +# Note: Remember that for the version of ECMEN used for monitoring (including assistance), +# the value of consumed in-kind assistance and gifts should be included in the household economic capacity aggregate. +df['HHExpNFTotal_GiftAid_MN_30D'] = df[columns_nf_giftaid_30d].sum(axis=1) # Sum consumption of gift/aid of all food groups in the last 30 days +df['HHExpNFTotal_GiftAid_MN_6M'] = df[columns_nf_giftaid_6m].sum(axis=1) # Sum consumption of gift/aid of all food groups in the last 6 months +df['HHExpNFTotal_GiftAid_MN_6M'] = df['HHExpNFTotal_GiftAid_MN_6M'] / 6 # Express 6 months in monthly terms +df['HHExpNFTotal_GiftAid_MN_1M'] = df['HHExpNFTotal_GiftAid_MN_30D'] + df['HHExpNFTotal_GiftAid_MN_6M'] # Sum consumption of gift/aid of all non-food groups + +# _______ NON-FOOD (all sources) _______ +# Calculate total monthly non-food expenditure (cash/credit & gift/aid) +df['HHExpNF_1M'] = df['HHExpNFTotal_Purch_MN_1M'] + df['HHExpNFTotal_GiftAid_MN_1M'] + +# _____________________________ ECONOMIC CAPACITY ______________________________________ +# Aggregate food expenditures, value of consumed food from gift/aid, and value of consumed food from own production +df['HHExpF_ECMEN'] = df[['HHExp_Food_Purch_MN_1M', 'HHExpNFTotal_GiftAid_MN_1M', 'HHExp_Food_Own_MN_1M']].sum(axis=1) + +# Aggregate non-food expenditures and value of consumed non-food from gift/aid +df['HHExpNF_ECMEN'] = df['HHExpNFTotal_Purch_MN_1M'] + df['HHExpNFTotal_GiftAid_MN_1M'] + +# Aggregate food and non-food +df['HHExp_ECMEN'] = df[['HHExpF_ECMEN', 'HHExpNF_ECMEN']].sum(axis=1) + +# 5. Express household economic capacity in per capita terms +df['PCExp_ECMEN'] = df['HHExp_ECMEN'] / df['HHSize'] + +# _____________________________ CALCULATE ECMEN ______________________________________ +# Using MEB +# Define Dummy MEB +df['MEB'] = 3000 + +# Define variable indicating if PC Household Economic Capacity is equal or greater than MEB +df['ECMEN_inclAsst'] = df['PCExp_ECMEN'] > df['MEB'] + +# Using SMEB (when applicable) +# Define Dummy SMEB +df['SMEB'] = 1200 + +# Define variable indicating if PC Household Economic Capacity is equal or greater than SMEB +df['ECMEN_inclAsst_SMEB'] = df['PCExp_ECMEN'] > df['SMEB'] + +# _____________________________ LABEL VARIABLES (IF NEEDED) ______________________________________ +df['ECMEN_inclAsst'] = df['ECMEN_inclAsst'].map({True: 'Above MEB', False: 'Below MEB'}) +df['ECMEN_inclAsst_SMEB'] = df['ECMEN_inclAsst_SMEB'].map({True: 'Above SMEB', False: 'Below SMEB'}) +df['HHExp_ECMEN'].rename("Household Economic Capacity - monthly", inplace=True) +df['PCExp_ECMEN'].rename("Household Economic Capacity per capita - monthly", inplace=True) +df['ECMEN_inclAsst'].rename("Economic capacity to meet essential needs - including assistance", inplace=True) +df['ECMEN_inclAsst_SMEB'].rename("Economic capacity to meet essential needs (Usin SMEB) - including assistance", inplace=True) \ No newline at end of file diff --git a/Indicators/Food-consumption-score-nutrition/FCSN-indicaror-calculation.py b/Indicators/Food-consumption-score-nutrition/FCSN-indicaror-calculation.py new file mode 100644 index 0000000..8bb6255 --- /dev/null +++ b/Indicators/Food-consumption-score-nutrition/FCSN-indicaror-calculation.py @@ -0,0 +1,64 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Food Consumption Score - Nutrition (FCSN) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# + +import pandas as pd +import numpy as np + +# Load Sample Data ------------------------------------------------------------# + +# df = pd.read_csv("FCSN_Sample_Survey.csv", na_values="n/a") + +# Label FCSN relevant variables -----------------------------------------------# + +fcsn_columns = [ + 'FCSNPrMeatF', 'FCSNPrMeatO', 'FCSNPrFish', 'FCSNPrEggs', + 'FCSNVegOrg', 'FCSNVegGre', 'FCSNFruiOrg' +] + +# Recode "n/a" values to 0 and change to numeric +df[fcsn_columns] = df[fcsn_columns].replace("n/a", 0).apply(pd.to_numeric) + +# Compute aggregates of key micronutrient consumption -------------------------# + +# Vitamin A-Rich Foods +df['FGVitA'] = (df['FCSDairy'] + df['FCSNPrMeatO'] + df['FCSNPrEggs'] + + df['FCSNVegOrg'] + df['FCSNVegGre'] + df['FCSNFruiOrg']) + +# Protein-Rich Foods +df['FGProtein'] = (df['FCSPulse'] + df['FCSDairy'] + df['FCSNPrMeatF'] + + df['FCSNPrMeatO'] + df['FCSNPrFish'] + df['FCSNPrEggs']) + +# Iron-Rich Foods +df['FGHIron'] = df['FCSNPrMeatF'] + df['FCSNPrMeatO'] + df['FCSNPrFish'] + +# Recode into nutritious groups ---------------------------------------------# + +df['FGVitACat'] = pd.cut(df['FGVitA'], bins=[-np.inf, 0, 6, np.inf], + labels=['Never consumed', 'Consumed sometimes', 'Consumed at least 7 times']) + +df['FGProteinCat'] = pd.cut(df['FGProtein'], bins=[-np.inf, 0, 6, np.inf], + labels=['Never consumed', 'Consumed sometimes', 'Consumed at least 7 times']) + +df['FGHIronCat'] = pd.cut(df['FGHIron'], bins=[-np.inf, 0, 6, np.inf], + labels=['Never consumed', 'Consumed sometimes', 'Consumed at least 7 times']) + +# Define variables labels and properties +# In pandas, we generally don't label data like in R, but you can create a dictionary for descriptions if needed + +labels = { + 'FGVitACat': "Consumption group of vitamin A-rich foods", + 'FGProteinCat': "Consumption group of protein-rich foods", + 'FGHIronCat': "Consumption group of heme iron-rich foods" +} + +# Print summary to check the results +print(df[['FGVitA', 'FGVitACat', 'FGProtein', 'FGProteinCat', 'FGHIron', 'FGHIronCat']].head()) +print(df['FGVitA'].describe()) +print(df['FGProtein'].describe()) +print(df['FGHIron'].describe()) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Food-consumption-score-nutrition/FCSN_indicator_tidyverse.R b/Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation-tidyverse.R similarity index 96% rename from Indicators/Food-consumption-score-nutrition/FCSN_indicator_tidyverse.R rename to Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation-tidyverse.R index 6c1b504..9fa616e 100644 --- a/Indicators/Food-consumption-score-nutrition/FCSN_indicator_tidyverse.R +++ b/Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation-tidyverse.R @@ -1,8 +1,6 @@ #------------------------------------------------------------------------------# - -# WFP RAM Standardized Scripts +# WFP Standardized Scripts # Calculating Food Consumption Score - Nutrition (FCSN) - #------------------------------------------------------------------------------# rm(list = ls()) @@ -15,7 +13,7 @@ library(expss) # Load Sample Data ------------------------------------------------------------# -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/FCSN_Sample_Survey.csv") +#data <- read_csv("~/GitHub/RAMResourcesScripts/Static/FCSN_Sample_Survey.csv") # Label FCSN relevant variables -----------------------------------------------# diff --git a/Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation.do b/Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation.do index 9a66613..3a1afb8 100644 --- a/Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation.do +++ b/Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation.do @@ -1,14 +1,12 @@ *------------------------------------------------------------------------------* - -* WFP RAM Standardized Scripts +* WFP APP Standardized Scripts * Calculating Food Consumption Score - Nutrition (FCSN) - * -----------------------------------------------------------------------------* * * Load data * --------- - import delim using "../GitHub/RAMResourcesScripts/Static/FCSN_Sample_Survey.csv", /// - clear case(preserve) +* import delim using "../GitHub/RAMResourcesScripts/Static/FCSN_Sample_Survey.csv", /// +* clear case(preserve) ** check and recode missing values as 0 sum FCS* @@ -48,4 +46,4 @@ label var FGProteinCat "Consumption group of protein-rich foods" label var FGHIronCat "Consumption group of heme iron-rich foods" -* End of scripts +* End of scripts \ No newline at end of file diff --git a/Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation.sps b/Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation.sps index dcb5a32..8df6831 100644 --- a/Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation.sps +++ b/Indicators/Food-consumption-score-nutrition/FCSN-indicator-calculation.sps @@ -1,8 +1,6 @@ *** -------------------------------------------------------------------------- - -*** WFP RAM Standardized Scripts -*** Calculating Food Consumption Score Nutrition (FCSN) - +*** WFP Standardized Scripts +*** Calculating Food Consumption Score - Nutrition (FCSN) *** -------------------------------------------------------------------------- * Encoding: UTF-8. diff --git a/Indicators/Food-consumption-score/FCS-indicator-calculation.R b/Indicators/Food-consumption-score/FCS-indicator-calculation.R index 3f0de9a..8beb234 100644 --- a/Indicators/Food-consumption-score/FCS-indicator-calculation.R +++ b/Indicators/Food-consumption-score/FCS-indicator-calculation.R @@ -1,8 +1,6 @@ #------------------------------------------------------------------------------# - -# WFP RAM Standardized Scripts -# Calculating FCS - +# WFP Standardized Scripts +# Calculating Food Consumption Score (FCS) #------------------------------------------------------------------------------# ## Load Packages --------------------------------------------------------------# @@ -26,16 +24,15 @@ library("diveRsity") getwd()# Display current working directory dir()# Display working directory content -setwd("C:\\Users\\name.lastname\\Documents\\Rfolder") +#setwd("C:\\Users\\name.lastname\\Documents\\Rfolder") # This is just an example. Copy and paste your own working directory. Remember to use "\\" instead of "/" # The data base to be used should be part of the content # Load Sample Data ------------------------------------------------------------# -data <- read.csv("../../Static/FCS_Sample_Survey.csv",na.strings = "n/a") - -names(data)# Display var names for the entire data base -attach(data)# Attach the data base for easy access to var names. +#data <- read.csv("../../Static/FCS_Sample_Survey.csv",na.strings = "n/a") +#names(data)# Display var names for the entire data base +#attach(data)# Attach the data base for easy access to var names. # Prepare FCS related variables -----------------------------------------------# diff --git a/Indicators/Food-consumption-score/FCS-indicator-calculation.do b/Indicators/Food-consumption-score/FCS-indicator-calculation.do index 6fc0758..36c926b 100644 --- a/Indicators/Food-consumption-score/FCS-indicator-calculation.do +++ b/Indicators/Food-consumption-score/FCS-indicator-calculation.do @@ -1,14 +1,12 @@ *------------------------------------------------------------------------------* - -* WFP RAM Standardized Scripts +* WFP Standardized Scripts * Calculating Food Consumption Score (FCS) - *----------------------------------------------------------------------------- ** Load data * --------- - import delim using "../../Static/FCS_Sample_Survey.csv", clear /// - case(preserve) bindquotes(strict) varn(1) +* import delim using "../../Static/FCS_Sample_Survey.csv", clear /// +* case(preserve) bindquotes(strict) varn(1) ** Label FCS relevant variables label var FCSStap "Consumption over the past 7 days: cereals, grains and tubers" @@ -47,4 +45,4 @@ label val FCSCat21 FCSCat28 FCSCat * --------- -** End of Scripts +** End of Scripts \ No newline at end of file diff --git a/Indicators/Food-consumption-score/FCS-indicator-calculation.sps b/Indicators/Food-consumption-score/FCS-indicator-calculation.sps index 17ce50a..340aba0 100644 --- a/Indicators/Food-consumption-score/FCS-indicator-calculation.sps +++ b/Indicators/Food-consumption-score/FCS-indicator-calculation.sps @@ -1,8 +1,6 @@ *** -------------------------------------------------------------------------- - -*** WFP RAM Standardized Scripts +*** WFP Standardized Scripts *** Calculating Food Consumption Score (FCS) - *** -------------------------------------------------------------------------- * Encoding: UTF-8. diff --git a/Indicators/Food-consumption-score/FCS_indicator_calculation.py b/Indicators/Food-consumption-score/FCS_indicator_calculation.py new file mode 100644 index 0000000..9f8f2d1 --- /dev/null +++ b/Indicators/Food-consumption-score/FCS_indicator_calculation.py @@ -0,0 +1,77 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Food Consumption Score (FCS) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# + +import pandas as pd +import numpy as np +import matplotlib.pyplot as plt +import seaborn as sns + +# Load Sample Data ------------------------------------------------------------# + +#df = pd.read_csv("FCS_Sample_Survey.csv", na_values="n/a") +#print(df.columns) # Display var names for the entire data base + +# Prepare FCS related variables -----------------------------------------------# + +# 1. Re-coding missing values to zero +fcs_columns = ['FCSStap', 'FCSVeg', 'FCSFruit', 'FCSPr', 'FCSPulse', 'FCSDairy', 'FCSSugar', 'FCSFat', 'FCSCond'] +df[fcs_columns] = df[fcs_columns].fillna(0) + +# Test results +print(df['FCSStap']) # How data looks like? + +# 2. Variables creation and statistics testing +# Var FCSStapCer FCSStapTub +# although deprecated, in case two staples are collected separately, then: +if 'FCSStap' not in df.columns: + df['FCSStap'] = df[['FCSStapCer', 'FCSStapTub']].max(axis=1) + +# Display summary statistics and plots for each FCS related variable +def summarize_and_plot(column): + print(f"Summary statistics for {column}:") + print(df[column].describe()) + sns.histplot(df[column], kde=True) + plt.title(f"Density plot for {column}") + plt.show() + +for col in fcs_columns: + summarize_and_plot(col) + +# 2.1 Recode above 7 to 7 (only if necessary) +df[fcs_columns] = df[fcs_columns].applymap(lambda x: 7 if x > 7 else x) + +# Calculate FCS ---------------------------------------------------------------# +df['FCS'] = (df['FCSStap'] * 2 + + df['FCSPulse'] * 3 + + df['FCSDairy'] * 4 + + df['FCSPr'] * 4 + + df['FCSVeg'] + + df['FCSFruit'] + + df['FCSFat'] * 0.5 + + df['FCSSugar'] * 0.5) + +# Test FCS results +print(df['FCS'].head(10)) +print(df['FCS'].describe()) +sns.histplot(df['FCS'], kde=True) +plt.title("Density plot for FCS") +plt.show() + +# Create FCG groups based on 21/35 or 28/42 thresholds ------------------------# +# Use this when analyzing a country with low consumption of sugar and oil - thresholds 21-35 +df['FCSCat21'] = pd.cut(df['FCS'], bins=[0, 21.5, 35.5, float('inf')], + labels=['Poor', 'Borderline', 'Acceptable'], + right=False) + +# Use this when analyzing a country with high consumption of sugar and oil - thresholds 28-42 +df['FCSCat28'] = pd.cut(df['FCS'], bins=[0, 28.5, 42.5, float('inf')], + labels=['Poor', 'Borderline', 'Acceptable'], + right=False) + +print(df[['FCS', 'FCSCat21', 'FCSCat28']].head(10)) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Food-consumption-score/FCS_indicator_tidyverse.R b/Indicators/Food-consumption-score/FCS_indicator_tidyverse.R index 0af110a..06956eb 100644 --- a/Indicators/Food-consumption-score/FCS_indicator_tidyverse.R +++ b/Indicators/Food-consumption-score/FCS_indicator_tidyverse.R @@ -1,8 +1,6 @@ #------------------------------------------------------------------------------# - -# WFP RAM Standardized Scripts -# Calculating FCS - +# WFP Standardized Scripts +# Calculating Food Consumption Score (FCS) #------------------------------------------------------------------------------# ## Load Packages --------------------------------------------------------------# @@ -15,7 +13,7 @@ library(haven) # Load Sample Data ------------------------------------------------------------# -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/FCS_Sample_Survey.csv") +#data <- read_csv("~/GitHub/RAMResourcesScripts/Static/FCS_Sample_Survey.csv") # Label relevant FCS variables ------------------------------------------------# @@ -66,4 +64,4 @@ val_lab(data$FCSCat28) = num_lab(" ") var_label(data$FCSCat28) <- "FCS Categories: 28/42 thresholds" -# End of Scripts +# End of Scripts \ No newline at end of file diff --git a/Indicators/Food-consumption-score/README.md b/Indicators/Food-consumption-score/README.md index a16eba4..befd4a6 100644 --- a/Indicators/Food-consumption-score/README.md +++ b/Indicators/Food-consumption-score/README.md @@ -1,12 +1,12 @@ # RAM Resources - Scripts -This folder contains all standardized scripts for indicators, analysis and visualization. +This folder contains all standardized scripts for indicators, analysis and visualization. ## Food Consumption Score (FCS) + - [Indicator Description on VAM Resource Center](https://resources.vam.wfp.org/data-analysis/quantitative/food-security/food-consumption-score-nutritional-quality-analysis) ## Main folder [Link to Sample Dataset](https://github.com/WFP-VAM/RAMResourcesScripts/blob/main/Static/FCS_Sample_Survey.csv) [Indicator Description on VAM Resource Center](https://resources.vam.wfp.org/data-analysis/quantitative/food-security/food-consumption-score) - diff --git a/Indicators/Food-consumption-sources/Food-consumption-sources.R b/Indicators/Food-consumption-sources/Food-consumption-sources.R new file mode 100644 index 0000000..e3da3eb --- /dev/null +++ b/Indicators/Food-consumption-sources/Food-consumption-sources.R @@ -0,0 +1,117 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Food Consumption Sources (FCS Source) +#------------------------------------------------------------------------------# + +## Load Packages --------------------------------------------------------------# + +library(tidyverse) +library(dplyr) +library(labelled) +library(expss) +library(haven) + +# Load Sample Data ------------------------------------------------------------# + +# data <- read_csv("~/GitHub/RAMResourcesScripts/Static/FCS_Source_Sample_Survey.csv") + +# Label relevant FCS variables ------------------------------------------------# + +var_label(data$FCSStap) <- "Consumption over the past 7 days: cereals, grains and tubers" +var_label(data$FCSPulse) <- "Consumption over the past 7 days: pulses" +var_label(data$FCSDairy) <- "Consumption over the past 7 days: dairy products" +var_label(data$FCSPr) <- "Consumption over the past 7 days: protein-rich foods" +var_label(data$FCSVeg) <- "Consumption over the past 7 days: vegetables" +var_label(data$FCSFruit) <- "Consumption over the past 7 days: fruit" +var_label(data$FCSFat) <- "Consumption over the past 7 days: oil" +var_label(data$FCSSugar) <- "Consumption over the past 7 days: sugar" +var_label(data$FCSCond) <- "Consumption over the past 7 days: condiments" + +var_label(data$FCSStap_SRf) <- "Main source: cereals, grains and tubers" +var_label(data$FCSPulse_SRf) <- "Main source: pulses" +var_label(data$FCSDairy_SRf) <- "Main source: dairy products" +var_label(data$FCSPr_SRf) <- "Main source: protein-rich foods" +var_label(data$FCSVeg_SRf) <- "Main source: vegetables" +var_label(data$FCSFruit_SRf) <- "Main source: fruit" +var_label(data$FCSFat_SRf) <- "Main source: oil" +var_label(data$FCSSugar_SRf) <- "Main source: sugar" +var_label(data$FCSCond_SRf) <- "Main source: condiments" + +# Define source types --------------------------------------------------------# + +sources <- c("Ownprod", "HuntFish", "Gather", "Borrow", "Cash", "Credit", "Beg", "Exchange", "Gift", "Assistance") +food_vars <- c("Stap", "Pulse", "Dairy", "Pr", "Veg", "Fruit", "Fat", "Sugar", "Cond") + +# Create source variables -----------------------------------------------------# + +for (food in food_vars) { + for (source in sources) { + data <- data %>% mutate(!!paste0(source, "_", food) := ifelse(get(paste0("FCS", food, "_SRf")) == match(source, sources) * 100, + get(paste0("FCS", food)), 0)) + } +} + +# Aggregate by source --------------------------------------------------------# + +data <- data %>% mutate( + Ownprod = rowSums(select(data, starts_with("Ownprod_")), na.rm = TRUE), + HuntFish = rowSums(select(data, starts_with("HuntFish_")), na.rm = TRUE), + Gather = rowSums(select(data, starts_with("Gather_")), na.rm = TRUE), + Borrow = rowSums(select(data, starts_with("Borrow_")), na.rm = TRUE), + Cash = rowSums(select(data, starts_with("Cash_")), na.rm = TRUE), + Credit = rowSums(select(data, starts_with("Credit_")), na.rm = TRUE), + Beg = rowSums(select(data, starts_with("Beg_")), na.rm = TRUE), + Exchange = rowSums(select(data, starts_with("Exchange_")), na.rm = TRUE), + Gift = rowSums(select(data, starts_with("Gift_")), na.rm = TRUE), + Assistance = rowSums(select(data, starts_with("Assistance_")), na.rm = TRUE) +) + +# Compute total sources of food -----------------------------------------------# + +data <- data %>% mutate( + Total_source = rowSums(select(data, Ownprod, HuntFish, Gather, Borrow, Cash, Credit, Beg, Exchange, Gift, Assistance), + na.rm = TRUE) +) + +# Calculate percentage of each food source ------------------------------------# + +data <- data %>% mutate( + Percent_Ownprod = (Ownprod / Total_source) * 100, + Percent_HuntFish = (HuntFish / Total_source) * 100, + Percent_Gather = (Gather / Total_source) * 100, + Percent_Borrow = (Borrow / Total_source) * 100, + Percent_Cash = (Cash / Total_source) * 100, + Percent_Credit = (Credit / Total_source) * 100, + Percent_Beg = (Beg / Total_source) * 100, + Percent_Exchange = (Exchange / Total_source) * 100, + Percent_Gift = (Gift / Total_source) * 100, + Percent_Assistance = (Assistance / Total_source) * 100 +) + +# Label new percentage variables ------------------------------------------------# + +var_label(data$Percent_Ownprod) <- "Percent of main source: Own production" +var_label(data$Percent_HuntFish) <- "Percent of main source: Hunted or fished" +var_label(data$Percent_Gather) <- "Percent of main source: Gathered" +var_label(data$Percent_Borrow) <- "Percent of main source: Borrowed from family or friends" +var_label(data$Percent_Cash) <- "Percent of main source: Purchased with cash" +var_label(data$Percent_Credit) <- "Percent of main source: Purchased with credit" +var_label(data$Percent_Beg) <- "Percent of main source: Begging" +var_label(data$Percent_Exchange) <- "Percent of main source: Barter or exchange" +var_label(data$Percent_Gift) <- "Percent of main source: Gifts from family or friends" +var_label(data$Percent_Assistance) <- "Percent of main source: Assistance" + +# Drop intermediate variables --------------------------------------------------# + +data <- data %>% select(-starts_with("Ownprod_"), + -starts_with("HuntFish_"), + -starts_with("Gather_"), + -starts_with("Borrow_"), + -starts_with("Cash_"), + -starts_with("Credit_"), + -starts_with("Beg_"), + -starts_with("Exchange_"), + -starts_with("Gift_"), + -starts_with("Assistance_")) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Food-consumption-sources/Food-consumption-sources.do b/Indicators/Food-consumption-sources/Food-consumption-sources.do new file mode 100644 index 0000000..578a413 --- /dev/null +++ b/Indicators/Food-consumption-sources/Food-consumption-sources.do @@ -0,0 +1,109 @@ +/******************************************************************************* +* WFP Standardized Scripts * +* Calculating Food Consumption Groups and Food Sources * +*******************************************************************************/ +* PART 1: Label Relevant Variables and Values +******************************************************************************** + + label var FCSStap "Consumption over the past 7 days: cereals, grains and tubers" + label var FCSPulse "Consumption over the past 7 days: pulses" + label var FCSDairy "Consumption over the past 7 days: dairy products" + label var FCSPr "Consumption over the past 7 days: protein-rich foods" + label var FCSVeg "Consumption over the past 7 days: vegetables" + label var FCSFruit "Consumption over the past 7 days: fruit" + label var FCSFat "Consumption over the past 7 days: oil" + label var FCSSugar "Consumption over the past 7 days: sugar" + label var FCSCond "Consumption over the past 7 days: condiments" + + label var FCSStap_SRf "Main source: cereals, grains and tubers" + label var FCSPulse_SRf "Main source: pulses" + label var FCSDairy_SRf "Main source: dairy products" + label var FCSPr_SRf "Main source: protein-rich foods" + label var FCSVeg_SRf "Main source: vegetables" + label var FCSFruit_SRf "Main source: fruit" + label var FCSFat_SRf "Main source: oil" + label var FCSSugar_SRf "Main source: sugar" + label var FCSCond_SRf "Main source: condiments" + + label def FCS_SRf_l 100 "Own production" /// + 200 "Fishing or hunting" /// + 300 "Gathering" /// + 400 "Loaned or borrowed" /// + 500 "Purchased" /// + 600 "Credit" /// + 700 "Begging" /// + 800 "Exchange for labour or items" /// + 900 "Gifts from family or friends" /// + 1000 "Food aid" + + label val FCSStap_SRf FCSPulse_SRf FCSDairy_SRf FCSPr_SRf FCSVeg_SRf /// + FCSFruit_SRf FCSFat_SRf FCSSugar_SRf FCSCond_SRf FCS_SRf_l + +*******************************************************************************/ +* PART 2: Create Food Consumption Variable by Source +******************************************************************************** + +** Step 0 - Rename existing variables +local SRf Ownprod HuntFish Gather Borrow Cash Credit Beg Exchange Gift Assistance + +foreach var of local SRf { + cap rename `var'* OLD_`var'* +} + +** Step 1 - Calculate unique variable for each source +local SRf_var Stap Pulse Dairy Pr Veg Fruit Fat Sugar Cond + +foreach var of local SRf_var { + gen Ownprod_`var' = FCS`var' if FCS`var'_SRf == 100 + gen HuntFish_`var' = FCS`var' if FCS`var'_SRf == 200 + gen Gather_`var' = FCS`var' if FCS`var'_SRf == 300 + gen Borrow_`var' = FCS`var' if FCS`var'_SRf == 400 + gen Cash_`var' = FCS`var' if FCS`var'_SRf == 500 + gen Credit_`var' = FCS`var' if FCS`var'_SRf == 600 + gen Beg_`var' = FCS`var' if FCS`var'_SRf == 700 + gen Exchange_`var' = FCS`var' if FCS`var'_SRf == 800 + gen Gift_`var' = FCS`var' if FCS`var'_SRf == 900 + gen Assistance_`var'= FCS`var' if FCS`var'_SRf == 1000 +} + +** Step 2 - Aggregate by source + egen Ownprod = rowtotal(Ownprod_*) + egen HuntFish = rowtotal(HuntFish_*) + egen Gather = rowtotal(Gather_*) + egen Borrow = rowtotal(Borrow_*) + egen Cash = rowtotal(Cash_*) + egen Credit = rowtotal(Credit_*) + egen Beg = rowtotal(Beg_*) + egen Exchange = rowtotal(Exchange_*) + egen Gift = rowtotal(Gift_*) + egen Assistance = rowtotal(Assistance_*) + +** Step 3 - Compute the total sources of food + egen Total_source = rowtotal(Ownprod HuntFish Gather Borrow Cash Credit Beg /// + Exchange Gift Assistance) + +** Step 4 - Calculate % of each food source + +foreach var of local SRf { + gen Percent_`var' = (`var'/Total_source) * 100 +} + +** Step 5 - Label new variables + label var Percent_Ownprod "Percent of main source: Own production" + label var Percent_HuntFish "Percent of main source: Hunted or fished" + label var Percent_Gather "Percent of main source: Gathered" + label var Percent_Borrow "Percent of main source: Borrowed from family or friends" + label var Percent_Cash "Percent of main source: Purchased with cash" + label var Percent_Credit "Percent of main source: Purchased with credit" + label var Percent_Beg "Percent of main source: Begging" + label var Percent_Exchange "Percent of main source: Barter or exchange" + label var Percent_Gift "Percent of main source: Gifts from family or friends" + label var Percent_Assistance "Percent of main source: Assistance" + +** Step 6 - Drop intermediate variables + + drop Ownprod_* HuntFish_* Gather_* Borrow_* Cash_* Credit_* Beg_* Exchange_* /// + Gift_* Assistance_* + +* --------- +** End of Scripts \ No newline at end of file diff --git a/Indicators/Food-consumption-sources/Food-consumption-sources.py b/Indicators/Food-consumption-sources/Food-consumption-sources.py new file mode 100644 index 0000000..95cdf1c --- /dev/null +++ b/Indicators/Food-consumption-sources/Food-consumption-sources.py @@ -0,0 +1,74 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Food Consumption Sources (FCS Source) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# + +import pandas as pd +import numpy as np +import matplotlib.pyplot as plt +import seaborn as sns + +# Load Sample Data ------------------------------------------------------------# + +# df = pd.read_csv("FCS_Source_Sample_Survey.csv", na_values="n/a") +# print(df.columns) # Display var names for the entire data base + +# Prepare FCS Source related variables ----------------------------------------# + +# 1. Re-coding missing values to zero for FCS Source variables +fcs_source_columns = ['FCSStap_SRf', 'FCSPulse_SRf', 'FCSDairy_SRf', 'FCSPr_SRf', + 'FCSVeg_SRf', 'FCSFruit_SRf', 'FCSFat_SRf', 'FCSSugar_SRf', + 'FCSCond_SRf'] +df[fcs_source_columns] = df[fcs_source_columns].fillna(0) + +# 2. Create source-related variables +sources = { + 'Ownprod': 100, + 'HuntFish': 200, + 'Gather': 300, + 'Borrow': 400, + 'Cash': 500, + 'Credit': 600, + 'Beg': 700, + 'Exchange': 800, + 'Gift': 900, + 'Assistance': 1000 +} + +for food in ['Stap', 'Pulse', 'Dairy', 'Pr', 'Veg', 'Fruit', 'Fat', 'Sugar', 'Cond']: + for source, code in sources.items(): + df[f'{source}_{food}'] = np.where(df[f'FCS{food}_SRf'] == code, df[f'FCS{food}'], 0) + +# Aggregate by source +source_vars = {source: [f'{source}_{food}' for food in ['Stap', 'Pulse', 'Dairy', 'Pr', 'Veg', 'Fruit', 'Fat', 'Sugar', 'Cond']] for source in sources.keys()} +for source, vars in source_vars.items(): + df[source] = df[vars].sum(axis=1) + +# Compute total sources of food +df['Total_source'] = df[list(source_vars.keys())].sum(axis=1) + +# Calculate percentage of each food source +for source in sources.keys(): + df[f'Percent_{source}'] = (df[source] / df['Total_source']) * 100 + +# Plot percentage distributions +def plot_percentage(column): + sns.histplot(df[column], kde=True) + plt.title(f"Density plot for {column}") + plt.show() + +for column in [f'Percent_{source}' for source in sources.keys()]: + plot_percentage(column) + +# Display summary statistics +print(df[[f'Percent_{source}' for source in sources.keys()]].describe()) + +# Drop intermediate variables +drop_vars = [var for sublist in source_vars.values() for var in sublist] +df = df.drop(columns=drop_vars) + +print(df.head(10)) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Food-expenditure-share/FES-indicator-calculation-tidyverse.R b/Indicators/Food-expenditure-share/FES-indicator-calculation-tidyverse.R new file mode 100644 index 0000000..c4f186d --- /dev/null +++ b/Indicators/Food-expenditure-share/FES-indicator-calculation-tidyverse.R @@ -0,0 +1,254 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Food Expenditure Share (FES) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# +library(dplyr) +library(readr) +library(labelled) + +# Load Sample Data ------------------------------------------------------------# +#data <- read_csv("FES_Sample_Survey.csv") + +# Label Variables -------------------------------------------------------------# +var_label(data$HHExpFCer_Purch_MN_7D) <- "Expenditures on cereals" +var_label(data$HHExpFCer_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - cereals" +var_label(data$HHExpFCer_Own_MN_7D) <- "Value of consumed own production - cereals" +var_label(data$HHExpFTub_Purch_MN_7D) <- "Expenditures on tubers" +var_label(data$HHExpFTub_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - tubers" +var_label(data$HHExpFTub_Own_MN_7D) <- "Value of consumed own production - tubers" +var_label(data$HHExpFPuls_Purch_MN_7D) <- "Expenditures on pulses & nuts" +var_label(data$HHExpFPuls_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - pulses and nuts" +var_label(data$HHExpFPuls_Own_MN_7D) <- "Value of consumed own production - pulses & nuts" +var_label(data$HHExpFVeg_Purch_MN_7D) <- "Expenditures on vegetables" +var_label(data$HHExpFVeg_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - vegetables" +var_label(data$HHExpFVeg_Own_MN_7D) <- "Value of consumed own production - vegetables" +var_label(data$HHExpFFrt_Purch_MN_7D) <- "Expenditures on fruits" +var_label(data$HHExpFFrt_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - fruits" +var_label(data$HHExpFFrt_Own_MN_7D) <- "Value of consumed own production - fruits" +var_label(data$HHExpFAnimMeat_Purch_MN_7D) <- "Expenditures on meat" +var_label(data$HHExpFAnimMeat_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - meat" +var_label(data$HHExpFAnimMeat_Own_MN_7D) <- "Value of consumed own production - meat" +var_label(data$HHExpFAnimFish_Purch_MN_7D) <- "Expenditures on fish" +var_label(data$HHExpFAnimFish_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - fish" +var_label(data$HHExpFAnimFish_Own_MN_7D) <- "Value of consumed own production - fish" +var_label(data$HHExpFFats_Purch_MN_7D) <- "Expenditures on fats" +var_label(data$HHExpFFats_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - fats" +var_label(data$HHExpFFats_Own_MN_7D) <- "Value of consumed own production - fats" +var_label(data$HHExpFDairy_Purch_MN_7D) <- "Expenditures on milk/dairy products" +var_label(data$HHExpFDairy_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - milk/dairy products" +var_label(data$HHExpFDairy_Own_MN_7D) <- "Value of consumed own production - milk/dairy products" +var_label(data$HHExpFEgg_Purch_MN_7D) <- "Expenditures on eggs" +var_label(data$HHExpFEgg_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - eggs" +var_label(data$HHExpFEgg_Own_MN_7D) <- "Value of consumed own production - eggs" +var_label(data$HHExpFSgr_Purch_MN_7D) <- "Expenditures on sugar/confectionery/desserts" +var_label(data$HHExpFSgr_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - sugar/confectionery/desserts" +var_label(data$HHExpFSgr_Own_MN_7D) <- "Value of consumed own production - sugar/confectionery/desserts" +var_label(data$HHExpFCond_Purch_MN_7D) <- "Expenditures on condiments" +var_label(data$HHExpFCond_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - condiments" +var_label(data$HHExpFCond_Own_MN_7D) <- "Value of consumed own production - condiments" +var_label(data$HHExpFBev_Purch_MN_7D) <- "Expenditures on beverages" +var_label(data$HHExpFBev_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - beverages" +var_label(data$HHExpFBev_Own_MN_7D) <- "Value of consumed own production - beverages" +var_label(data$HHExpFOut_Purch_MN_7D) <- "Expenditures on snacks/meals prepared outside" +var_label(data$HHExpFOut_GiftAid_MN_7D) <- "Value of consumed in-kind assistance and gifts - snacks/meals prepared outside" +var_label(data$HHExpFOut_Own_MN_7D) <- "Value of consumed own production - snacks/meals prepared outside" + +# Calculate total value of food expenditures/consumption by source -------------# + +# Calculate total value of food expenditures/consumption by source -------------# + +# Monthly food expenditures in cash/credit +data$HHExp_Food_Purch_MN_1M <- rowSums(data[c("HHExpFCer_Purch_MN_7D", + "HHExpFTub_Purch_MN_7D", + "HHExpFPuls_Purch_MN_7D", + "HHExpFVeg_Purch_MN_7D", + "HHExpFFrt_Purch_MN_7D", + "HHExpFAnimMeat_Purch_MN_7D", + "HHExpFAnimFish_Purch_MN_7D", + "HHExpFFats_Purch_MN_7D", + "HHExpFDairy_Purch_MN_7D", + "HHExpFEgg_Purch_MN_7D", + "HHExpFSgr_Purch_MN_7D", + "HHExpFCond_Purch_MN_7D", + "HHExpFBev_Purch_MN_7D", + "HHExpFOut_Purch_MN_7D")], + na.rm = TRUE) * (30/7) +var_label(data$HHExp_Food_Purch_MN_1M) <- "Total monthly food expenditure (cash and credit)" + +# Monthly value of consumed food from gifts/aid +data$HHExp_Food_GiftAid_MN_1M <- rowSums(data[c("HHExpFCer_GiftAid_MN_7D", + "HHExpFTub_GiftAid_MN_7D", + "HHExpFPuls_GiftAid_MN_7D", + "HHExpFVeg_GiftAid_MN_7D", + "HHExpFFrt_GiftAid_MN_7D", + "HHExpFAnimMeat_GiftAid_MN_7D", + "HHExpFAnimFish_GiftAid_MN_7D", + "HHExpFFats_GiftAid_MN_7D", + "HHExpFDairy_GiftAid_MN_7D", + "HHExpFEgg_GiftAid_MN_7D", + "HHExpFSgr_GiftAid_MN_7D", + "HHExpFCond_GiftAid_MN_7D", + "HHExpFBev_GiftAid_MN_7D", + "HHExpFOut_GiftAid_MN_7D")], + na.rm = TRUE) * (30/7) +var_label(data$HHExp_Food_GiftAid_MN_1M) <- "Total monthly food consumption from gifts/aid" + +# Monthly value of consumed food from own-production +data$HHExp_Food_Own_MN_1M <- rowSums(data[c("HHExpFCer_Own_MN_7D", + "HHExpFTub_Own_MN_7D", + "HHExpFPuls_Own_MN_7D", + "HHExpFVeg_Own_MN_7D", + "HHExpFFrt_Own_MN_7D", + "HHExpFAnimMeat_Own_MN_7D", + "HHExpFAnimFish_Own_MN_7D", + "HHExpFFats_Own_MN_7D", + "HHExpFDairy_Own_MN_7D", + "HHExpFEgg_Own_MN_7D", + "HHExpFSgr_Own_MN_7D", + "HHExpFCond_Own_MN_7D", + "HHExpFBev_Own_MN_7D", + "HHExpFOut_Own_MN_7D")], + na.rm = TRUE) * (30/7) +var_label(data$HHExp_Food_Own_MN_1M) <- "Total monthly food consumption from own-production" + +# Label variables for non-food expenditures -----------------------------------# +# Non-food expenditures (1 month recall period) +var_label(data$HHExpNFHyg_Purch_MN_1M) <- "Expenditures on hygiene" +var_label(data$HHExpNFHyg_GiftAid_MN_1M) <- "Value of consumed in-kind assistance-gifts - hygiene" +var_label(data$HHExpNFTransp_Purch_MN_1M) <- "Expenditures on transport" +var_label(data$HHExpNFTransp_GiftAid_MN_1M) <- "Value of consumed in-kind assistance-gifts - transport" +var_label(data$HHExpNFFuel_Purch_MN_1M) <- "Expenditures on fuel" +var_label(data$HHExpNFFuel_GiftAid_MN_1M) <- "Value of consumed in-kind assistance-gifts - fuel" +var_label(data$HHExpNFWat_Purch_MN_1M) <- "Expenditures on water" +var_label(data$HHExpNFWat_GiftAid_MN_1M) <- "Value of consumed in-kind assistance-gifts - water" +var_label(data$HHExpNFElec_Purch_MN_1M) <- "Expenditures on electricity" +var_label(data$HHExpNFElec_GiftAid_MN_1M) <- "Value of consumed in-kind assistance-gifts - electricity" +var_label(data$HHExpNFEnerg_Purch_MN_1M) <- "Expenditures on energy (not electricity)" +var_label(data$HHExpNFEnerg_GiftAid_MN_1M) <- "Value of consumed in-kind assistance-gifts - energy (not electricity)" +var_label(data$HHExpNFDwelSer_Purch_MN_1M) <- "Expenditures on services related to dwelling" +var_label(data$HHExpNFDwelSer_GiftAid_MN_1M) <- "Value of consumed in-kind assistance-gifts - services related to dwelling" +var_label(data$HHExpNFPhone_Purch_MN_1M) <- "Expenditures on communication" +var_label(data$HHExpNFPhone_GiftAid_MN_1M) <- "Value of consumed in-kind assistance-gifts - communication" +var_label(data$HHExpNFRecr_Purch_MN_1M) <- "Expenditures on recreation" +var_label(data$HHExpNFRecr_GiftAid_MN_1M) <- "Value of consumed in-kind assistance-gifts - recreation" +var_label(data$HHExpNFAlcTobac_Purch_MN_1M) <- "Expenditures on alcohol/tobacco" +var_label(data$HHExpNFAlcTobac_GiftAid_MN_1M) <- "Value of consumed in-kind assistance-gifts - alcohol/tobacco" + +# Non-food expenditures (6 months recall period) +var_label(data$HHExpNFMedServ_Purch_MN_6M) <- "Expenditures on health services" +var_label(data$HHExpNFMedServ_GiftAid_MN_6M) <- "Value of consumed in-kind assistance-gifts - health services" +var_label(data$HHExpNFMedGood_Purch_MN_6M) <- "Expenditures on medicines and health products" +var_label(data$HHExpNFMedGood_GiftAid_MN_6M) <- "Value of consumed in-kind assistance-gifts - medicines and health products" +var_label(data$HHExpNFCloth_Purch_MN_6M) <- "Expenditures on clothing and footwear" +var_label(data$HHExpNFCloth_GiftAid_MN_6M) <- "Value of consumed in-kind assistance-gifts - clothing and footwear" +var_label(data$HHExpNFEduFee_Purch_MN_6M) <- "Expenditures on education services" +var_label(data$HHExpNFEduFee_GiftAid_MN_6M) <- "Value of consumed in-kind assistance-gifts - education services" +var_label(data$HHExpNFEduGood_Purch_MN_6M) <- "Expenditures on education goods" +var_label(data$HHExpNFEduGood_GiftAid_MN_6M) <- "Value of consumed in-kind assistance-gifts - education goods" +var_label(data$HHExpNFRent_Purch_MN_6M) <- "Expenditures on rent" +var_label(data$HHExpNFRent_GiftAid_MN_6M) <- "Value of consumed in-kind assistance-gifts - rent" +var_label(data$HHExpNFHHSoft_Purch_MN_6M) <- "Expenditures on non-durable furniture/utensils" +var_label(data$HHExpNFHHSoft_GiftAid_MN_6M) <- "Value of consumed in-kind assistance-gifts - non-durable furniture/utensils" +var_label(data$HHExpNFHHMaint_Purch_MN_6M) <- "Expenditures on household routine maintenance" +var_label(data$HHExpNFHHMaint_GiftAid_MN_6M) <- "Value of consumed in-kind assistance-gifts - household routine maintenance" + +# 1 month recall period +data$HHExpNFTotal_Purch_MN_30D <- rowSums(data[c("HHExpNFHyg_Purch_MN_1M", + "HHExpNFTransp_Purch_MN_1M", + "HHExpNFFuel_Purch_MN_1M", + "HHExpNFWat_Purch_MN_1M", + "HHExpNFElec_Purch_MN_1M", + "HHExpNFEnerg_Purch_MN_1M", + "HHExpNFDwelSer_Purch_MN_1M", + "HHExpNFPhone_Purch_MN_1M", + "HHExpNFRecr_Purch_MN_1M", + "HHExpNFAlcTobac_Purch_MN_1M")], + na.rm = TRUE) + +# Label variable for total monthly non-food expenditure (cash and credit) +var_label(data$HHExpNFTotal_Purch_MN_1M) <- "Total monthly non-food expenditure (cash and credit)" +# Drop intermediate columns +data <- data %>% select(-HHExpNFTotal_Purch_MN_6M, -HHExpNFTotal_Purch_MN_30D) + +data$HHExpNFTotal_Purch_MN_6M <- rowSums(data[c("HHExpNFMedServ_Purch_MN_6M", + "HHExpNFMedGood_Purch_MN_6M", + "HHExpNFCloth_Purch_MN_6M", + "HHExpNFEduFee_Purch_MN_6M", + "HHExpNFEduGood_Purch_MN_6M", + "HHExpNFRent_Purch_MN_6M", + "HHExpNFHHSoft_Purch_MN_6M", + "HHExpNFHHMaint_Purch_MN_6M")], + na.rm = TRUE) / 6 + +data$HHExpNFTotal_Purch_MN_1M <- data$HHExpNFTotal_Purch_MN_30D + data$HHExpNFTotal_Purch_MN_6M + +# Monthly value of consumed non-food from gifts/aid +data$HHExpNFTotal_GiftAid_MN_30D <- rowSums(data[c("HHExpNFHyg_GiftAid_MN_1M", + "HHExpNFTransp_GiftAid_MN_1M", + "HHExpNFFuel_GiftAid_MN_1M", + "HHExpNFWat_GiftAid_MN_1M", + "HHExpNFElec_GiftAid_MN_1M", + "HHExpNFEnerg_GiftAid_MN_1M", + "HHExpNFDwelSer_GiftAid_MN_1M", + "HHExpNFPhone_GiftAid_MN_1M", + "HHExpNFRecr_GiftAid_MN_1M", + "HHExpNFAlcTobac_GiftAid_MN_1M")], + na.rm = TRUE) + +# Label variable for total monthly non-food consumption from gifts/aid +var_label(data$HHExpNFTotal_GiftAid_MN_1M) <- "Total monthly non-food consumption from gifts/aid" +# Drop intermediate columns +data <- data %>% select(-HHExpNFTotal_GiftAid_MN_6M, -HHExpNFTotal_GiftAid_MN_30D) + +data$HHExpNFTotal_GiftAid_MN_6M <- rowSums(data[c("HHExpNFMedServ_GiftAid_MN_6M", + "HHExpNFMedGood_GiftAid_MN_6M", + "HHExpNFCloth_GiftAid_MN_6M", + "HHExpNFEduFee_GiftAid_MN_6M", + "HHExpNFEduGood_GiftAid_MN_6M", + "HHExpNFRent_GiftAid_MN_6M", + "HHExpNFHHSoft_GiftAid_MN_6M", + "HHExpNFHHMaint_GiftAid_MN_6M")], + na.rm = TRUE) / 6 + +data$HHExpNFTotal_GiftAid_MN_1M <- data$HHExpNFTotal_GiftAid_MN_30D + data$HHExpNFTotal_GiftAid_MN_6M + +# Aggregate food expenditures, value of consumed food from gifts/assistance, and value of consumed food from own production +data$HHExpF_1M <- rowSums(data[c("HHExp_Food_Purch_MN_1M", + "HHExp_Food_GiftAid_MN_1M", + "HHExp_Food_Own_MN_1M")], + na.rm = TRUE) + +# Aggregate NF expenditures and value of consumed non-food from gifts/assistance +data$HHExpNF_1M <- rowSums(data[c("HHExpNFTotal_Purch_MN_1M", + "HHExpNFTotal_GiftAid_MN_1M")], + na.rm = TRUE) + +# Compute FES +# Aggregate total food and non-food expenditures +data$HHExpTot_1M <- rowSums(data[c("HHExpF_1M", "HHExpNF_1M")], + na.rm = TRUE) + +# Compute FES for each household +data$FES <- data$HHExpF_1M / data$HHExpTot_1M +var_label(data$FES) <- "Household food expenditure share" + +# Drop intermediate column +data <- data %>% select(-HHExpTot_1M) + +# Transform FES to 4 categories +data$Foodexp_4pt <- cut(data$FES, + breaks = c(-Inf, 0.4999999, 0.65, 0.75, Inf), + labels = c("<50%", "50-65%", "65-75%", ">=75%")) + +var_label(data$Foodexp_4pt) <- "Food expenditure share categories" + +# Define value labels for Foodexp_4pt +data$Foodexp_4pt <- factor(data$Foodexp_4pt, + levels = c("<50%", "50-65%", "65-75%", ">=75%")) + +# Compute FES indicator +table(data$Foodexp_4pt) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Food-expenditure-share/FES-indicator-calculation.py b/Indicators/Food-expenditure-share/FES-indicator-calculation.py new file mode 100644 index 0000000..8743199 --- /dev/null +++ b/Indicators/Food-expenditure-share/FES-indicator-calculation.py @@ -0,0 +1,288 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Food Expenditure Share (FES) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# + +import pandas as pd +import numpy as np + +# Load Sample Data ------------------------------------------------------------# + +df = pd.read_csv("FES_Sample_Survey.csv") + +print(df.columns) # Display var names for the entire data base + +# Initialize columns with their respective labels +columns_food = { + 'HHExpFCer_Purch_MN_7D': 'Expenditures on cereals', + 'HHExpFCer_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - cereals', + 'HHExpFCer_Own_MN_7D': 'Value of consumed own production - cereals', + 'HHExpFTub_Purch_MN_7D': 'Expenditures on tubers', + 'HHExpFTub_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - tubers', + 'HHExpFTub_Own_MN_7D': 'Value of consumed own production - tubers', + 'HHExpFPuls_Purch_MN_7D': 'Expenditures on pulses & nuts', + 'HHExpFPuls_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - pulses and nuts', + 'HHExpFPuls_Own_MN_7D': 'Value of consumed own production - pulses & nuts', + 'HHExpFVeg_Purch_MN_7D': 'Expenditures on vegetables', + 'HHExpFVeg_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - vegetables', + 'HHExpFVeg_Own_MN_7D': 'Value of consumed own production - vegetables', + 'HHExpFFrt_Purch_MN_7D': 'Expenditures on fruits', + 'HHExpFFrt_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - fruits', + 'HHExpFFrt_Own_MN_7D': 'Value of consumed own production - fruits', + 'HHExpFAnimMeat_Purch_MN_7D': 'Expenditures on meat', + 'HHExpFAnimMeat_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - meat', + 'HHExpFAnimMeat_Own_MN_7D': 'Value of consumed own production - meat', + 'HHExpFAnimFish_Purch_MN_7D': 'Expenditures on fish', + 'HHExpFAnimFish_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - fish', + 'HHExpFAnimFish_Own_MN_7D': 'Value of consumed own production - fish', + 'HHExpFFats_Purch_MN_7D': 'Expenditures on fats', + 'HHExpFFats_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - fats', + 'HHExpFFats_Own_MN_7D': 'Value of consumed own production - fats', + 'HHExpFDairy_Purch_MN_7D': 'Expenditures on milk/dairy products', + 'HHExpFDairy_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - milk/dairy products', + 'HHExpFDairy_Own_MN_7D': 'Value of consumed own production - milk/dairy products', + 'HHExpFEgg_Purch_MN_7D': 'Expenditures on eggs', + 'HHExpFEgg_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - eggs', + 'HHExpFEgg_Own_MN_7D': 'Value of consumed own production - eggs', + 'HHExpFSgr_Purch_MN_7D': 'Expenditures on sugar/confectionery/desserts', + 'HHExpFSgr_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - sugar/confectionery/desserts', + 'HHExpFSgr_Own_MN_7D': 'Value of consumed own production - sugar/confectionery/desserts', + 'HHExpFCond_Purch_MN_7D': 'Expenditures on condiments', + 'HHExpFCond_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - condiments', + 'HHExpFCond_Own_MN_7D': 'Value of consumed own production - condiments', + 'HHExpFBev_Purch_MN_7D': 'Expenditures on beverages', + 'HHExpFBev_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - beverages', + 'HHExpFBev_Own_MN_7D': 'Value of consumed own production - beverages', + 'HHExpFOut_Purch_MN_7D': 'Expenditures on snacks/meals prepared outside', + 'HHExpFOut_GiftAid_MN_7D': 'Value of consumed in-kind assistance and gifts - snacks/meals prepared outside', + 'HHExpFOut_Own_MN_7D': 'Value of consumed own production - snacks/meals prepared outside' +} + +columns_non_food_1m = { + 'HHExpNFHyg_Purch_MN_1M': 'Expenditures on hygiene', + 'HHExpNFHyg_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - hygiene', + 'HHExpNFTransp_Purch_MN_1M': 'Expenditures on transport', + 'HHExpNFTransp_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - transport', + 'HHExpNFFuel_Purch_MN_1M': 'Expenditures on fuel', + 'HHExpNFFuel_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - fuel', + 'HHExpNFWat_Purch_MN_1M': 'Expenditures on water', + 'HHExpNFWat_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - water', + 'HHExpNFElec_Purch_MN_1M': 'Expenditures on electricity', + 'HHExpNFElec_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - electricity', + 'HHExpNFEnerg_Purch_MN_1M': 'Expenditures on energy (not electricity)', + 'HHExpNFEnerg_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - energy (not electricity)', + 'HHExpNFDwelSer_Purch_MN_1M': 'Expenditures on services related to dwelling', + 'HHExpNFDwelSer_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - services related to dwelling', + 'HHExpNFPhone_Purch_MN_1M': 'Expenditures on communication', + 'HHExpNFPhone_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - communication', + 'HHExpNFRecr_Purch_MN_1M': 'Expenditures on recreation', + 'HHExpNFRecr_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - recreation', + 'HHExpNFAlcTobac_Purch_MN_1M': 'Expenditures on alcohol/tobacco', + 'HHExpNFAlcTobac_GiftAid_MN_1M': 'Value of consumed in-kind assistance-gifts - alcohol/tobacco' +} + +columns_non_food_6m = { + 'HHExpNFMedServ_Purch_MN_6M': 'Expenditures on health services', + 'HHExpNFMedServ_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - health services', + 'HHExpNFMedGood_Purch_MN_6M': 'Expenditures on medicines and health products', + 'HHExpNFMedGood_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - medicines and health products', + 'HHExpNFCloth_Purch_MN_6M': 'Expenditures on clothing and footwear', + 'HHExpNFCloth_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - clothing and footwear', + 'HHExpNFEduFee_Purch_MN_6M': 'Expenditures on education services', + 'HHExpNFEduFee_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - education services', + 'HHExpNFEduGood_Purch_MN_6M': 'Expenditures on education goods', + 'HHExpNFEduGood_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - education goods', + 'HHExpNFRent_Purch_MN_6M': 'Expenditures on rent', + 'HHExpNFRent_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - rent', + 'HHExpNFHHSoft_Purch_MN_6M': 'Expenditures on household supplies', + 'HHExpNFHHSoft_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - household supplies', + 'HHExpNFHHDur_Purch_MN_6M': 'Expenditures on durable household goods', + 'HHExpNFHHDur_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - durable household goods', + 'HHExpNFHHTrans_Purch_MN_6M': 'Expenditures on household transport', + 'HHExpNFHHTrans_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - household transport', + 'HHExpNFHHComP_Purch_MN_6M': 'Expenditures on household communications and postal services', + 'HHExpNFHHComP_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - household communications and postal services', + 'HHExpNFOthDom_Purch_MN_6M': 'Expenditures on other domestic services', + 'HHExpNFOthDom_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - other domestic services', + 'HHExpNFOthOcc_Purch_MN_6M': 'Expenditures on other occasional expenses', + 'HHExpNFOthOcc_GiftAid_MN_6M': 'Value of consumed in-kind assistance-gifts - other occasional expenses' +} + +# Define columns for food and non-food expenditures and consumption by source +columns_f_purch_7d = [ + 'HHExpFCer_Purch_MN_7D', + 'HHExpFTub_Purch_MN_7D', + 'HHExpFPuls_Purch_MN_7D', + 'HHExpFVeg_Purch_MN_7D', + 'HHExpFFrt_Purch_MN_7D', + 'HHExpFAnimMeat_Purch_MN_7D', + 'HHExpFAnimFish_Purch_MN_7D', + 'HHExpFFats_Purch_MN_7D', + 'HHExpFDairy_Purch_MN_7D', + 'HHExpFEgg_Purch_MN_7D', + 'HHExpFSgr_Purch_MN_7D', + 'HHExpFCond_Purch_MN_7D', + 'HHExpFBev_Purch_MN_7D', + 'HHExpFOut_Purch_MN_7D', +] + +columns_f_giftaid_7d = [ + 'HHExpFCer_GiftAid_MN_7D', + 'HHExpFTub_GiftAid_MN_7D', + 'HHExpFPuls_GiftAid_MN_7D', + 'HHExpFVeg_GiftAid_MN_7D', + 'HHExpFFrt_GiftAid_MN_7D', + 'HHExpFAnimMeat_GiftAid_MN_7D', + 'HHExpFAnimFish_GiftAid_MN_7D', + 'HHExpFFats_GiftAid_MN_7D', + 'HHExpFDairy_GiftAid_MN_7D', + 'HHExpFEgg_GiftAid_MN_7D', + 'HHExpFSgr_GiftAid_MN_7D', + 'HHExpFCond_GiftAid_MN_7D', + 'HHExpFBev_GiftAid_MN_7D', + 'HHExpFOut_GiftAid_MN_7D', +] + +columns_f_own_7d = [ + 'HHExpFCer_Own_MN_7D', + 'HHExpFTub_Own_MN_7D', + 'HHExpFPuls_Own_MN_7D', + 'HHExpFVeg_Own_MN_7D', + 'HHExpFFrt_Own_MN_7D', + 'HHExpFAnimMeat_Own_MN_7D', + 'HHExpFAnimFish_Own_MN_7D', + 'HHExpFFats_Own_MN_7D', + 'HHExpFDairy_Own_MN_7D', + 'HHExpFEgg_Own_MN_7D', + 'HHExpFSgr_Own_MN_7D', + 'HHExpFCond_Own_MN_7D', + 'HHExpFBev_Own_MN_7D', + 'HHExpFOut_Own_MN_7D', +] + +columns_nf_purch_30d = [ + 'HHExpNFHyg_Purch_MN_1M', + 'HHExpNFTransp_Purch_MN_1M', + 'HHExpNFFuel_Purch_MN_1M', + 'HHExpNFWat_Purch_MN_1M', + 'HHExpNFElec_Purch_MN_1M', + 'HHExpNFEnerg_Purch_MN_1M', + 'HHExpNFDwelSer_Purch_MN_1M', + 'HHExpNFPhone_Purch_MN_1M', + 'HHExpNFRecr_Purch_MN_1M', + 'HHExpNFAlcTobac_Purch_MN_1M' +] + +columns_nf_purch_6m = [ + 'HHExpNFMedServ_Purch_MN_6M', + 'HHExpNFMedGood_Purch_MN_6M', + 'HHExpNFCloth_Purch_MN_6M', + 'HHExpNFEduFee_Purch_MN_6M', + 'HHExpNFEduGood_Purch_MN_6M', + 'HHExpNFRent_Purch_MN_6M', + 'HHExpNFHHSoft_Purch_MN_6M', + 'HHExpNFHHMaint_Purch_MN_6M' +] + +columns_nf_giftaid_30d = [ + 'HHExpNFHyg_GiftAid_MN_1M', + 'HHExpNFTransp_GiftAid_MN_1M', + 'HHExpNFFuel_GiftAid_MN_1M', + 'HHExpNFWat_GiftAid_MN_1M', + 'HHExpNFElec_GiftAid_MN_1M', + 'HHExpNFEnerg_GiftAid_MN_1M', + 'HHExpNFDwelSer_GiftAid_MN_1M', + 'HHExpNFPhone_GiftAid_MN_1M', + 'HHExpNFRecr_GiftAid_MN_1M', + 'HHExpNFAlcTobac_GiftAid_MN_1M' +] + +columns_nf_giftaid_6m = [ + 'HHExpNFMedServ_GiftAid_MN_6M', + 'HHExpNFMedGood_GiftAid_MN_6M', + 'HHExpNFCloth_GiftAid_MN_6M', + 'HHExpNFEduFee_GiftAid_MN_6M', + 'HHExpNFEduGood_GiftAid_MN_6M', + 'HHExpNFRent_GiftAid_MN_6M', + 'HHExpNFHHSoft_GiftAid_MN_6M', + 'HHExpNFHHMaint_GiftAid_MN_6M' +] + +# _____________________________ FOOD - Last 7 days ______________________________________ + +# _______ FOOD (cash/credit) _______ +# Calculate monthly food expenditure (cash/credit) +df['HHExp_Food_Purch_MN_1M'] = df[columns_f_purch_7d].sum(axis=1) # Sum purchases of all food groups in the last 7 days +df['HHExp_Food_Purch_MN_1M'] = df['HHExp_Food_Purch_MN_1M'] / 7 * 30 # Express 30 days in monthly terms + +# _______ FOOD (gift/aid) _______ +# Calculate monthly food expenditure (gift/aid) +df['HHExp_Food_GiftAid_MN_1M'] = df[columns_f_giftaid_7d].sum(axis=1) # Sum consumption of gift/aid for all food groups in the last 7 days +df['HHExp_Food_GiftAid_MN_1M'] = df['HHExp_Food_GiftAid_MN_1M'] / 7 * 30 # Express 30 days in monthly terms + +# _______ FOOD (own-production) _______ +# Calculate monthly food expenditure (onw-production) +df['HHExp_Food_Own_MN_1M'] = df[columns_f_own_7d].sum(axis=1) # Sum consumption of own-production for all food groups in the last 7 days +df['HHExp_Food_Own_MN_1M'] = df['HHExp_Food_Own_MN_1M'] / 7 * 30 # Express 30 days in monthly terms + +# _______ FOOD (all sources) _______ +# Calculate total monthly food expenditure (cash/credit & gidt/aid & own-production) +df['HHExpF_1M'] = df[['HHExp_Food_Purch_MN_1M', 'HHExp_Food_GiftAid_MN_1M', 'HHExp_Food_Own_MN_1M']].sum(axis=1) + +# _____________________________ NON FOOD - Last 30 days & Last 6 months ______________________________________ + +# _______ NON-FOOD (cash/credit) _______ +# Calculate monthly non-food expenditure (cash/credit) +df['HHExpNFTotal_Purch_MN_30D'] = df[columns_nf_purch_30d].sum(axis=1) # Sum purchases of all food groups in the last 30 days +df['HHExpNFTotal_Purch_MN_6M'] = df[columns_nf_purch_6m].sum(axis=1) # Sum purchases of all food groups in the last 6 months +df['HHExpNFTotal_Purch_MN_6M'] = df['HHExpNFTotal_Purch_MN_6M'] / 6 # Express 6 months in monthly terms +df['HHExpNFTotal_Purch_MN_1M'] = df['HHExpNFTotal_Purch_MN_30D'] + df['HHExpNFTotal_Purch_MN_6M'] # Sum purchases of all non-food groups + +# _______ NON-FOOD (gift/aid) _______ +# Calculate monthly non-food expenditure (gift/aid) +df['HHExpNFTotal_GiftAid_MN_30D'] = df[columns_nf_giftaid_30d].sum(axis=1) # Sum consumption of gift/aid of all food groups in the last 30 days +df['HHExpNFTotal_GiftAid_MN_6M'] = df[columns_nf_giftaid_6m].sum(axis=1) # Sum consumption of gift/aid of all food groups in the last 6 months +df['HHExpNFTotal_GiftAid_MN_6M'] = df['HHExpNFTotal_GiftAid_MN_6M'] / 6 # Express 6 months in monthly terms +df['HHExpNFTotal_GiftAid_MN_1M'] = df['HHExpNFTotal_GiftAid_MN_30D'] + df['HHExpNFTotal_GiftAid_MN_6M'] # Sum consumption of gift/aid of all non-food groups + +# _______ NON-FOOD (all sources) _______ +# Calculate total monthly non-food expenditure (cash/credit & gidt/aid) +df['HHExpNF_1M'] = df['HHExpNFTotal_Purch_MN_1M'] + df['HHExpNFTotal_GiftAid_MN_1M'] + +# ______________________________________________ FES __________________________________________________________ +# Calculate FES (Household food expenditure share) +df['FES'] = df['HHExpF_1M'] / (df['HHExpF_1M'] + df['HHExpNF_1M']) # monthly food expenditure divided by total monthly expenditure (food & non-food) + +# ______________________________________________ FES CLASSIFICATION____________________________________________ +# Recode FES into 4-point scale +df['Foodexp_4pt'] = pd.cut( + df['FES'], + bins=[0, 0.5, 0.65, 0.75, float('inf')], + labels=[1, 2, 3, 4], + right=False +) + +# Define value labels +foodexp_labels = { + 1: 'Low FES (<50%)', + 2: 'Medium FES (50-65%)', + 3: 'High FES (65-75%)', + 4: 'Very High FES (> 75%)'} +df['Foodexp_4pt'] = df['Foodexp_4pt'].map(foodexp_labels) + +# _____________________________ RENANE COLUMNS (IF NEEDED) ______________________________________ +df['HHExp_Food_Purch_MN_1M'].rename('Total monthly food expenditure (cash and credit)', inplace=True) +df['HHExp_Food_GiftAid_MN_1M'].rename('Total monthly food consumption from gifts/aid', inplace=True) +df['HHExp_Food_Own_MN_1M'].rename('Total monthly food consumption from own production', inplace=True) +df['HHExpNFTotal_Purch_MN_1M'].rename('Total monthly non-food expenditure (cash and credit)', inplace=True) +df['HHExpNFTotal_GiftAid_MN_1M'].rename('Total monthly non-food consumption from gifts/aid', inplace=True) +df['HHExpF_1M'].rename('Total monthly expenditures', inplace=True) +df['FES'].rename('Food expenditure share', inplace=True) +df['Foodexp_4pt'].rename('Food expenditure share classfication', inplace=True) + +# Display frequencies of Foodexp_4pt +print(df['Foodexp_4pt'].value_counts()) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Food-expenditure-share/FES.do b/Indicators/Food-expenditure-share/FES.do index 088fcc0..978d08b 100644 --- a/Indicators/Food-expenditure-share/FES.do +++ b/Indicators/Food-expenditure-share/FES.do @@ -86,13 +86,11 @@ egen HHExp_Food_Own_MN_1M=rowtotal(HHExpFCer_Own_MN_7D HHExpFTub_Own_MN_7D HHExp replace HHExp_Food_Own_MN_1M=HHExp_Food_Own_MN_1M*(30/7) // conversion in monthly terms - do it only if recall period for food was 7 days lab var HHExp_Food_Own_MN_1M "Total monthly food consumption from own-production" - *-------------------------------------------------------------------------------* *2. Create variables for non-food expenditure, by source *-------------------------------------------------------------------------------* *** 2.a Label variables: - *1 month recall period - variables labels: lab var HHExpNFHyg_Purch_MN_1M "Expenditures on hygiene" lab var HHExpNFHyg_GiftAid_MN_1M "Value of consumed in-kind assistance-gifts - hygiene" @@ -136,7 +134,6 @@ lab var HHExpNFHHMaint_GiftAid_MN_6M "Value of consumed in-kind assistance-gifts * If the questionnaire included further non-food categories/items, label the respective variables *** 2.b Calculate total value of non-food expenditures/consumption by source - ** Total non-food expenditure (cash/credit) * 30 days recall @@ -208,3 +205,4 @@ label value Foodexp_4pt Foodexp_4pt_lab * Compute FES indicator tab Foodexp_4pt +** End of Scripts \ No newline at end of file diff --git a/Indicators/Food-expenditure-share/FES.sps b/Indicators/Food-expenditure-share/FES.sps index c1d88a9..9eda7a6 100644 --- a/Indicators/Food-expenditure-share/FES.sps +++ b/Indicators/Food-expenditure-share/FES.sps @@ -229,5 +229,4 @@ EXECUTE. FREQUENCIES Foodexp_4pt. - - +*** End of Scripts \ No newline at end of file diff --git a/Indicators/Household-Dietary-Diversity-Score/HDDS-calculation.do b/Indicators/Household-Dietary-Diversity-Score/HDDS-calculation.do new file mode 100644 index 0000000..d74395b --- /dev/null +++ b/Indicators/Household-Dietary-Diversity-Score/HDDS-calculation.do @@ -0,0 +1,35 @@ +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Calculating Household Dietary Diversity Score (HDDS) +*------------------------------------------------------------------------------* + +* Variable labels +label variable HDDSStapCer "Cereals consumption in the previous 24 hours" +label variable HDDSStapRoot "Roots and tubers consumption in the previous 24 hours" +label variable HDDSVeg "Vegetable consumption in the previous 24 hours" +label variable HDDSFruit "Fruit consumption in the previous 24 hours" +label variable HDDSPrMeat "Meat/poultry consumption in the previous 24 hours" +label variable HDDSPrEggs "Eggs consumption in the previous 24 hours" +label variable HDDSPrFish "Fish consumption in the previous 24 hours" +label variable HDDSPulse "Pulses/legumes consumption in the previous 24 hours" +label variable HDDSDairy "Milk and dairy product consumption in the previous 24 hours" +label variable HDDSFat "Oil/fats consumption in the previous 24 hours" +label variable HDDSSugar "Sugar/honey consumption in the previous 24 hours" +label variable HDDSCond "Miscellaneous/condiments consumption in the previous 24 hours" + +* Compute HDDS +gen HDDS = HDDSStapCer + HDDSStapRoot + HDDSVeg + HDDSFruit + HDDSPrMeat + HDDSPrEggs + HDDSPrFish + HDDSPulse + HDDSDairy + HDDSFat + HDDSSugar + HDDSCond +* egen HDDS = rowtotal(HDDS*) depending on the missing value checking and cleaning + +label variable HDDS "Household Dietary Diversity Score" + +* Recode HDDS into categories +recode HDDS (0/2 = 1) (3/4 = 2) (5/12 = 3), generate(HDDSCat_IPC) + +label variable HDDSCat_IPC "HDDS categories using IPC severity scale" +label define HDDSCat_IPC 1 "0-2 food groups (phase 4 to 5)" /// + 2 "3-4 food groups (phase 3)" /// + 3 "5-12 food groups (phase 1 to 2)" +label values HDDSCat_IPC HDDSCat_IPC + +* End of Scripts \ No newline at end of file diff --git a/Indicators/Household-Dietary-Diversity-Score/HDDS-calculation.py b/Indicators/Household-Dietary-Diversity-Score/HDDS-calculation.py new file mode 100644 index 0000000..9fea25f --- /dev/null +++ b/Indicators/Household-Dietary-Diversity-Score/HDDS-calculation.py @@ -0,0 +1,27 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Household Dietary Diversity Score (HDDS) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# +import pandas as pd + +# Load Sample Data ------------------------------------------------------------# +#df = pd.read_csv("~/GitHub/RAMResourcesScripts/Static/HDDS_Sample_Survey.csv") + +# Compute HDDS ---------------------------------------------------------------# +df['HDDS'] = (df['HDDSStapCer'] + df['HDDSStapRoot'] + df['HDDSVeg'] + + df['HDDSFruit'] + df['HDDSPrMeat'] + df['HDDSPrEggs'] + + df['HDDSPrFish'] + df['HDDSPulse'] + df['HDDSDairy'] + + df['HDDSFat'] + df['HDDSSugar'] + df['HDDSCond']) + +# Recode HDDS into categories -----------------------------------------------# +df['HDDSCat_IPC'] = pd.cut(df['HDDS'], bins=[-float('inf'), 2, 4, float('inf')], + labels=['0-2 food groups (phase 4 to 5)', + '3-4 food groups (phase 3)', + '5-12 food groups (phase 1 to 2)']) + +# View the result -----------------------------------------------------------# +print(df[['HDDS', 'HDDSCat_IPC']].head(10)) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Household-Dietary-Diversity-Score/HDDS-calculation.sps b/Indicators/Household-Dietary-Diversity-Score/HDDS-calculation.sps new file mode 100644 index 0000000..bb5aa6b --- /dev/null +++ b/Indicators/Household-Dietary-Diversity-Score/HDDS-calculation.sps @@ -0,0 +1,40 @@ +*** -------------------------------------------------------------------------- +***    WFP Standardized Scripts +*** Calculating Household Dietary Diversity Score (HDDS) +*** -------------------------------------------------------------------------- + +* Encoding: UTF-8. + +***Create Household Dietary Diversity Score – 24hr recall from HDDS module *** +**remember that you need 12 food groups to compute the HDDS, recall period is past 24 hours before the survey + +Variable labels + HDDSStapCer Cereals consumption in the previous 24 hours + HDDSStapRoot Roots and tubers consumption in the previous 24 hours + HDDSVeg Vegetable consumption in the previous 24 hours + HDDSFruit Fruit consumption in the previous 24 hours + HDDSPrMeat Meat/poultry consumption in the previous 24 hours + HDDSPrEggs Eggs consumption in the previous 24 hours + HDDSPrFish Fish consumption in the previous 24 hours + HDDSPulse Pulses/legumes consumption in the previous 24 hours + HDDSDairy Milk and dairy product consumption in the previous 24 hours + HDDSFat Oil/fats consumption in the previous 24 hours + HDDSSugar Sugar/honey consumption in the previous 24 hours + HDDSCond Miscellaneous/condiments consumption in the previous 24 hours. + +**Note that it is advised to use + instead of SUM() as cases with missing values should not be included in the calculation. + +Compute HDDS = HDDSStapCer + HDDSStapRoot + HDDSVeg + HDDSFruit + HDDSPrMeat + HDDSPrEggs + HDDSPrFish + HDDSPulse + HDDSDairy + HDDSFat + HDDSSugar + HDDSCond. +Variable labels HDDS 'Household Dietary Diversity Score'. +EXECUTE. + +* Recode HDDS into categories. +RECODE HDDS (LO THRU 2 = 1) (3 THRU 4 = 2) (5 THRU HI = 3) INTO HDDSCat_IPC. +VALUE LABELS HDDSCat_IPC + 1 '0-2 food groups (phase 4 to 5)' + 2 '3-4 food groups (phase 3)' + 3 '5-12 food groups (phase 1 to 2)'. +VARIABLE LABELS HDDSCat_IPC 'HDDS categories using IPC severity scale'. +EXECUTE. + +*** End of Scripts \ No newline at end of file diff --git a/Indicators/Household-Dietary-Diversity-Score/HDDS-calulation-tidyverse.R b/Indicators/Household-Dietary-Diversity-Score/HDDS-calulation-tidyverse.R new file mode 100644 index 0000000..3d93c01 --- /dev/null +++ b/Indicators/Household-Dietary-Diversity-Score/HDDS-calulation-tidyverse.R @@ -0,0 +1,52 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Household Dietary Diversity Score (HDDS) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# +library(tidyverse) +library(dplyr) +library(labelled) +library(expss) +library(haven) + +# Load Sample Data ------------------------------------------------------------# + +# data <- read_csv("path_to_your_file.csv") + +# Assign variable labels -------------------------------------------------------# +var_label(data$HDDSStapCer) <- "Cereals consumption in the previous 24 hours" +var_label(data$HDDSStapRoot) <- "Roots and tubers consumption in the previous 24 hours" +var_label(data$HDDSVeg) <- "Vegetable consumption in the previous 24 hours" +var_label(data$HDDSFruit) <- "Fruit consumption in the previous 24 hours" +var_label(data$HDDSPrMeat) <- "Meat/poultry consumption in the previous 24 hours" +var_label(data$HDDSPrEggs) <- "Eggs consumption in the previous 24 hours" +var_label(data$HDDSPrFish) <- "Fish consumption in the previous 24 hours" +var_label(data$HDDSPulse) <- "Pulses/legumes consumption in the previous 24 hours" +var_label(data$HDDSDairy) <- "Milk and dairy product consumption in the previous 24 hours" +var_label(data$HDDSFat) <- "Oil/fats consumption in the previous 24 hours" +var_label(data$HDDSSugar) <- "Sugar/honey consumption in the previous 24 hours" +var_label(data$HDDSCond) <- "Miscellaneous/condiments consumption in the previous 24 hours" + +# Compute HDDS ---------------------------------------------------------------# +data <- data %>% + mutate(HDDS = HDDSStapCer + HDDSStapRoot + HDDSVeg + HDDSFruit + + HDDSPrMeat + HDDSPrEggs + HDDSPrFish + HDDSPulse + + HDDSDairy + HDDSFat + HDDSSugar + HDDSCond) %>% + mutate(HDDSCat_IPC = case_when( + HDDS <= 2 ~ 1, + HDDS >= 3 & HDDS <= 4 ~ 2, + HDDS >= 5 ~ 3 + )) + +# Assign value labels +val_lab(data$HDDSCat_IPC) <- num_lab(" + 1 '0-2 food groups (phase 4 to 5)' + 2 '3-4 food groups (phase 3)' + 3 '5-12 food groups (phase 1 to 2)' +") + +# View the result +print(data %>% select(HDDS, HDDSCat_IPC)) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Household-Dietary-Diversity-Score/Household-Dietary-Diversity-Score.sps b/Indicators/Household-Dietary-Diversity-Score/Household-Dietary-Diversity-Score.sps deleted file mode 100644 index 092cca9..0000000 --- a/Indicators/Household-Dietary-Diversity-Score/Household-Dietary-Diversity-Score.sps +++ /dev/null @@ -1,36 +0,0 @@ -*** -------------------------------------------------------------------------- - -***    WFP RAM Standardized Scripts -*** Calculating Household Dietary Diversity Score (HDDS) - -*** -------------------------------------------------------------------------- - -* Encoding: UTF-8. - -***Create Household Dietary Diversity Score – 24hr recall from HDDS module *** -**remember that you need 12 food groups to compute the HDDS, recall period is past 24 hours before the survey - -Variable labels -HDDSStapCer Cereals consumption in the previous 24 hours -HDDSStapRoot Roots and tubers consumption in the previous 24 hours -HDDSVeg Vegetable consumption in the previous 24 hours -HDDSFruit Fruit consumption in the previous 24 hours -HDDSPrMeat Meat/poultry consumption in the previous 24 hours -HDDSPrEggs Eggs consumption in the previous 24 hours -HDDSPrFish Fish consumption in the previous 24 hours -HDDSPulse Pulses/legumes consumption in the previous 24 hours -HDDSDairy Milk and dairy product consumption in the previous 24 hours -HDDSFat Oil/fats consumption in the previous 24 hours -HDDSSugar Sugar/honey consumption in the previous 24 hours -HDDSCond Miscellaneous/condiments consumption in the previous 24 hours. - -**Note that it is advised to use + instead of SUM() as cases with missing values should not be included in the calcuation. - -Compute HDDS = HDDSStapCer + HDDSStapRoot + HDDSVeg + HDDSFruit + HDDSPrMeat + HDDSPrEggs + HDDSPrFish + HDDSPulse + HDDSDairy + HDDSFat + HDDSSugar + HDDSCond. -Variable labels HDDS 'Household Dietary Diversity Score'. -EXECUTE. - -Recode HDDS (lowest thru 2=1) (3 thru 4=2) (5 thru highest = 3) into HDDSCat_IPC. -Value labels HDDSCat_IPC 1 '0-2 food groups (phase 4 to 5)' 2 '3-4 food groups (phase 3)' 3 '5-12 food groups (phase 1 to 2)'. -Variable labels HDDSCat_IPC 'HDDS categories using IPC severity scale'. -EXECUTE. diff --git a/Indicators/Household-Hunger-Scale/HHS-calculation-tidyverse.R b/Indicators/Household-Hunger-Scale/HHS-calculation-tidyverse.R new file mode 100644 index 0000000..4deef6e --- /dev/null +++ b/Indicators/Household-Hunger-Scale/HHS-calculation-tidyverse.R @@ -0,0 +1,127 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating the Household Hunger Scale (HHS) +#------------------------------------------------------------------------------# + +# Load necessary packages -----------------------------------------------------# +library(tidyverse) # For data manipulation +library(labelled) # For handling value labels + +# Load data --------------------------------------------------------------------# +# Replace with your data file path +#df <- read_csv("path_to_your_file.csv") + +# Define variable labels -------------------------------------------------------# +var_label(data$HHSNoFood) <- "In the past [4 weeks/30 days], was there ever no food to eat of any kind in your house because of lack of resources to get food?" +var_label(data$HHSNoFood_FR) <- "How often did this happen in the past [4 weeks/30 days]?" +var_label(data$HHSBedHung) <- "In the past [4 weeks/30 days], did you or any household member go to sleep at night hungry because there was not enough food?" +var_label(data$HHSBedHung_FR) <- "How often did this happen in the past [4 weeks/30 days]?" +var_label(data$HHSNotEat) <- "In the past [4 weeks/30 days], did you or any household member go a whole day and night without eating anything because there was not enough food?" +var_label(data$HHSNotEat_FR) <- "How often did this happen in the past [4 weeks/30 days]?" + +# Define value labels ----------------------------------------------------------# +val_lab(data$HHSNoFood) <- num_lab(" + 0 No + 1 Yes +") + +val_lab(data$HHSNoFood_FR) <- num_lab(" + 1 Rarely (1–2 times) + 2 Sometimes (3–10 times) + 3 Often (more than 10 times) +") + +val_lab(data$HHSBedHung) <- num_lab(" + 0 No + 1 Yes +") + +val_lab(data$HHSBedHung_FR) <- num_lab(" + 1 Rarely (1–2 times) + 2 Sometimes (3–10 times) + 3 Often (more than 10 times) +") + +val_lab(data$HHSNotEat) <- num_lab(" + 0 No + 1 Yes +") + +val_lab(data$HHSNotEat_FR) <- num_lab(" + 1 Rarely (1–2 times) + 2 Sometimes (3–10 times) + 3 Often (more than 10 times) +") + +# Cleaning of HHS variables: consistency between filter and frequency questions ----# +# HHSNoFood and HHSNoFood_FR +data <- data %>% + mutate(HHSNoFood = ifelse(HHSNoFood_FR > 0, 1, HHSNoFood)) + +# HHSBedHung and HHSBedHung_FR +data <- data %>% + mutate(HHSBedHung = ifelse(HHSBedHung_FR > 0, 1, HHSBedHung)) + +# HHSNotEat and HHSNotEat_FR +data <- data %>% + mutate(HHSNotEat = ifelse(HHSNotEat_FR > 0, 1, HHSNotEat)) + +# Create new variables for frequency-of-occurrence questions --------------------# +data <- data %>% + mutate( + HHSQ1 = case_when(HHSNoFood_FR %in% c(1, 2) ~ 1, + HHSNoFood_FR == 3 ~ 2, + TRUE ~ 0), + HHSQ2 = case_when(HHSBedHung_FR %in% c(1, 2) ~ 1, + HHSBedHung_FR == 3 ~ 2, + TRUE ~ 0), + HHSQ3 = case_when(HHSNotEat_FR %in% c(1, 2) ~ 1, + HHSNotEat_FR == 3 ~ 2, + TRUE ~ 0) + ) + +# Compute the Household Hunger Score (HHS) -------------------------------------# +data <- data %>% + mutate(HHS = HHSQ1 + HHSQ2 + HHSQ3) + +# Define variable labels for HHS and HHS categories -----------------------------# +var_label(data$HHS) <- "Household Hunger Score" + +# Categorize HHS scores --------------------------------------------------------# +data <- data %>% + mutate( + HHSCat = case_when( + HHS <= 1 ~ 1, + HHS >= 2 & HHS <= 3 ~ 2, + HHS >= 4 ~ 3 + ), + HHSCatr = case_when( + HHS == 0 ~ 0, + HHS == 1 ~ 1, + HHS >= 2 & HHS <= 3 ~ 2, + HHS == 4 ~ 3, + HHS >= 5 ~ 4 + ) + ) + +# Define value labels for HHS categories ---------------------------------------# +data <- data %>% + mutate( + HHSCat = val_lab(data$HHSCat, num_lab(" + 1 No or little hunger in the household + 2 Moderate hunger in the household + 3 Severe hunger in the household + ")), + HHSCatr = val_lab(data$HHSCatr, num_lab(" + 0 No hunger in the household + 1 Little hunger in the household (stress) + 2 Moderate hunger in the household (crisis) + 3 Severe hunger in the household (emergency) + 4 Very severe hunger in the household (catastrophe) + ")) + ) + +# View results -----------------------------------------------------------------# +print(data %>% select(HHS, HHSCat, HHSCatr)) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Household-Hunger-Scale/HHS-calculation.do b/Indicators/Household-Hunger-Scale/HHS-calculation.do new file mode 100644 index 0000000..23b66a3 --- /dev/null +++ b/Indicators/Household-Hunger-Scale/HHS-calculation.do @@ -0,0 +1,65 @@ +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Calculating the Household Hunger Scale (HHS) +*------------------------------------------------------------------------------* + +* Define variable labels -------------------------------------------------------* +label variable HHSNoFood "In the past [4 weeks/30 days], was there ever no food to eat of any kind in your house because of lack of resources to get food?" +label variable HHSNoFood_FR "How often did this happen in the past [4 weeks/30 days]?" +label variable HHSBedHung "In the past [4 weeks/30 days], did you or any household member go to sleep at night hungry because there was not enough food?" +label variable HHSBedHung_FR "How often did this happen in the past [4 weeks/30 days]?" +label variable HHSNotEat "In the past [4 weeks/30 days], did you or any household member go a whole day and night without eating anything because there was not enough food?" +label variable HHSNotEat_FR "How often did this happen in the past [4 weeks/30 days]?" + +* Define value labels ----------------------------------------------------------* +label define hhs_nofood 0 "No" 1 "Yes" +label values HHSNoFood hhs_nofood + +label define hhs_freq 1 "Rarely (1–2 times)" /// + 2 "Sometimes (3–10 times)" /// + 3 "Often (more than 10 times)" +label values HHSNoFood_FR HHSBedHung_FR HHSNotEat_FR hhs_freq + +* Clean HHS variables ----------------------------------------------------------* +gen HHSNoFood = (HHSNoFood_FR > 0) +gen HHSBedHung = (HHSBedHung_FR > 0) +gen HHSNotEat = (HHSNotEat_FR > 0) + +* Recode frequency-of-occurrence questions ------------------------------------* +recode HHSNoFood_FR (1=1) (2=1) (3=2) (else=0), gen(HHSQ1) +recode HHSBedHung_FR (1=1) (2=1) (3=2) (else=0), gen(HHSQ2) +recode HHSNotEat_FR (1=1) (2=1) (3=2) (else=0), gen(HHSQ3) + +* Define variable labels for new variables -------------------------------------* +label variable HHSQ1 "Was there ever no food to eat in HH?" +label variable HHSQ2 "Did any HH member go sleep hungry?" +label variable HHSQ3 "Did any HH member go whole day without food?" + +* Compute Household Hunger Score ------------------------------------------------* +gen HHS = HHSQ1 + HHSQ2 + HHSQ3 +label variable HHS "Household Hunger Score" + +* Display HHS summary statistics -------------------------------------------------* +summarize HHS, detail + +* Create categorical HHS indicators ---------------------------------------------* +recode HHS (0/1 = 1) (2/3 = 2) (4/.) = 3, gen(HHSCat) +label define hhs_cat 1 "No or little hunger in the household" /// + 2 "Moderate hunger in the household" /// + 3 "Severe hunger in the household" +label values HHSCat hhs_cat + +* IPC Categories ----------------------------------------------------------------* +recode HHS (0 = 0) (1 = 1) (2/3 = 2) (4 = 3) (5/.) = 4, gen(HHSCatr) +label define hhs_cat_ipc 0 "No hunger in the household" /// + 1 "Little hunger in the household (stress)" /// + 2 "Moderate hunger in the household (crisis)" /// + 3 "Severe hunger in the household (emergency)" /// + 4 "Very severe hunger in the household (catastrophe)" +label values HHSCatr hhs_cat_ipc + +* Display categorical HHS indicators --------------------------------------------* +tab HHSCat +tab HHSCatr + +* End of Scripts \ No newline at end of file diff --git a/Indicators/Household-Hunger-Scale/HHS-calculation.py b/Indicators/Household-Hunger-Scale/HHS-calculation.py new file mode 100644 index 0000000..ebf2785 --- /dev/null +++ b/Indicators/Household-Hunger-Scale/HHS-calculation.py @@ -0,0 +1,32 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating the Household Hunger Scale (HHS) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# +import pandas as pd + +# Load Sample Data ------------------------------------------------------------# +# df = pd.read_csv("path_to_your_file.csv") + +# Clean HHS variables --------------------------------------------------------# +df['HHSNoFood'] = df['HHSNoFood_FR'].apply(lambda x: 1 if x > 0 else 0) +df['HHSBedHung'] = df['HHSBedHung_FR'].apply(lambda x: 1 if x > 0 else 0) +df['HHSNotEat'] = df['HHSNotEat_FR'].apply(lambda x: 1 if x > 0 else 0) + +# Recode frequency-of-occurrence questions -----------------------------------# +df['HHSQ1'] = df['HHSNoFood_FR'].map({1: 1, 2: 1, 3: 2}).fillna(0).astype(int) +df['HHSQ2'] = df['HHSBedHung_FR'].map({1: 1, 2: 1, 3: 2}).fillna(0).astype(int) +df['HHSQ3'] = df['HHSNotEat_FR'].map({1: 1, 2: 1, 3: 2}).fillna(0).astype(int) + +# Compute Household Hunger Score ------------------------------------------------# +df['HHS'] = df['HHSQ1'] + df['HHSQ2'] + df['HHSQ3'] + +# Create categorical HHS indicators -------------------------------------------# +df['HHSCat'] = pd.cut(df['HHS'], bins=[-float('inf'), 1, 3, float('inf')], labels=[1, 2, 3]) +df['HHSCatr'] = pd.cut(df['HHS'], bins=[-float('inf'), 0, 1, 3, 4, float('inf')], labels=[0, 1, 2, 3, 4]) + +# Display the results --------------------------------------------------------# +print(df[['HHS', 'HHSCat', 'HHSCatr']].head(10)) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Household-Hunger-Scale/HHS-calculation.sps b/Indicators/Household-Hunger-Scale/HHS-calculation.sps new file mode 100644 index 0000000..09b3204 --- /dev/null +++ b/Indicators/Household-Hunger-Scale/HHS-calculation.sps @@ -0,0 +1,102 @@ +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Calculating the Household Hunger Scale (HHS) +*------------------------------------------------------------------------------* + +* Define variables and labels -------------------------------------------------* + +VARIABLE LABELS + HHSNoFood 'In the past [4 weeks/30 days], was there ever no food to eat of any kind in your house because of lack of resources to get food?' + HHSNoFood_FR 'How often did this happen in the past [4 weeks/30 days]?' + HHSBedHung 'In the past [4 weeks/30 days], did you or any household member go to sleep at night hungry because there was not enough food?' + HHSBedHung_FR 'How often did this happen in the past [4 weeks/30 days]?' + HHSNotEat 'In the past [4 weeks/30 days], did you or any household member go a whole day and night without eating anything because there was not enough food?' + HHSNotEat_FR 'How often did this happen in the past [4 weeks/30 days]?' + +* Define value labels --------------------------------------------------------* + +VALUE LABELS HHSNoFood HHSBedHung HHSNotEat + 0 'No' + 1 'Yes'. + +VALUE LABELS HHSNoFood_FR HHSBedHung_FR HHSNotEat_FR + 1 'Rarely (1–2 times)' + 2 'Sometimes (3–10 times)' + 3 'Often (more than 10 times)'. + +* Clean HHS variables --------------------------------------------------------* + +* HHSNoFood and HHSNoFood_FR +DO IF (HHSNoFood_FR > 0). + COMPUTE HHSNoFood = 1. +ELSE. + COMPUTE HHSNoFood = 0. +END IF. +EXECUTE. + +* HHSBedHung and HHSBedHung_FR +DO IF (HHSBedHung_FR > 0). + COMPUTE HHSBedHung = 1. +ELSE. + COMPUTE HHSBedHung = 0. +END IF. +EXECUTE. + +* HHSNotEat and HHSNotEat_FR +DO IF (HHSNotEat_FR > 0). + COMPUTE HHSNotEat = 1. +ELSE. + COMPUTE HHSNotEat = 0. +END IF. +EXECUTE. + +* Recode frequency-of-occurrence questions -----------------------------------* + +RECODE HHSNoFood_FR HHSBedHung_FR HHSNotEat_FR (1=1) (2=1) (3=2) (ELSE=0) INTO HHSQ1 HHSQ2 HHSQ3. + +* Define variable labels for new variables -----------------------------------* + +VARIABLE LABELS + HHSQ1 'Was there ever no food to eat in HH?' + HHSQ2 'Did any HH member go sleep hungry?' + HHSQ3 'Did any HH member go whole day without food?'. +EXECUTE. + +* Compute Household Hunger Score ------------------------------------------------* + +COMPUTE HHS = HHSQ1 + HHSQ2 + HHSQ3. +VARIABLE LABELS HHS 'Household Hunger Score'. +EXECUTE. + +* Display HHS summary statistics ----------------------------------------------* + +FREQUENCIES VARIABLES = HHS + /STATISTICS = MEAN MEDIAN MINIMUM MAXIMUM + /ORDER = ANALYSIS. + +* Create categorical HHS indicators -------------------------------------------* + +* HHS Categories +RECODE HHS (0 THRU 1 = 1) (2 THRU 3 = 2) (4 THRU HI = 3) INTO HHSCat. +VARIABLE LABELS HHSCat 'Household Hunger Score Categories'. +VALUE LABELS HHSCat + 1 'No or little hunger in the household' + 2 'Moderate hunger in the household' + 3 'Severe hunger in the household'. +EXECUTE. + +* IPC Categories +RECODE HHS (0 = 0) (1 = 1) (2 THRU 3 = 2) (4 = 3) (5 THRU HI = 4) INTO HHSCatr. +VARIABLE LABELS HHSCatr 'Household Hunger Score Categories'. +VALUE LABELS HHSCatr + 0 'No hunger in the household' + 1 'Little hunger in the household (stress)' + 2 'Moderate hunger in the household (crisis)' + 3 'Severe hunger in the household (emergency)' + 4 'Very severe hunger in the household (catastrophe)'. +EXECUTE. + +* Display categorical HHS indicators ------------------------------------------* +FREQUENCIES VARIABLES = HHSCat HHSCatr. + +** End of Scripts \ No newline at end of file diff --git a/Indicators/Household-hunger-scale/Household-Hunger-Scale.sps b/Indicators/Household-hunger-scale/Household-Hunger-Scale.sps deleted file mode 100644 index f092b64..0000000 --- a/Indicators/Household-hunger-scale/Household-Hunger-Scale.sps +++ /dev/null @@ -1,116 +0,0 @@ -Syntax for Calculating the Household Hunger Scale - -***Create Household Hunger Scale*** - -**define variables - -Variable labels -HHSNoFood ‘In the past [4 weeks/30 days], was there ever no food to eat of any kind in your house because of lack of resources to get food?’ -HHSNoFood_FR ‘How often did this happen in the past [4 weeks/30 days]?’ -HHSBedHung ‘In the past [4 weeks/30 days], did you or any household member go to sleep at night hungry because there was not enough food?’ -HHSBedHung_FR ‘How often did this happen in the past [4 weeks/30 days]?’ -HHSNotEat ‘In the past 4 weeks (30 days), did you or any household member go a whole day and night without eating anything because there was not enough food?’ -HHSNotEat_FR ‘How often did this happen in the past [4 weeks/30 days]?’. - - -***define labels - -Value labels HHSNoFood HHSBedHung HHSNotEat -0 ‘No’ -1 ‘Yes’. - -Value labels HHSNoFood_FR HHSBedHung_FR HHSNotEat_FR -1 ‘Rarely (1–2 times)’ -2 ‘Sometimes (3–10 times)’ -3 ‘Often (more than 10 times)’. - -**Cleaning of HHS variables: make sure that is consistency between the filter and the frequency questions** - -* HHSNoFood and HHSNoFood_FR* - -Do if (HHSNoFood_FR >0). -Compute HHSNoFood =1. -ELSE. -End if. -EXECUTE. - -* HHSBedHung and HHSBedHung_FR* - -Do if (HHSBedHung_FR >0). -Compute HHSBedHung =1. -ELSE. -End if. -EXECUTE. - -* HHSNotEat and HHSNotEat_FR* - -Do if (HHSNotEat_FR>0). -Compute HHSNotEat =1. -ELSE. -End if. -EXECUTE. - -**Create a new variable for each frequency-of-occurrence question: the objective is to recode each frequency-of-occurrence question from three frequency categories (“rarely,” “sometimes,” “often”) into two frequency categories (“rarely or sometimes” and “often”)** - -RECODE HHSNoFood_FR HHSBedHung_FR HHSNotEat_FR (1=1) (2=1) (3=2) (ELSE=0) INTO HHSQ1 HHSQ2 HHSQ3. - -***define variables - - - -Variable labels -HHSQ1 'Was there ever no food to eat in HH?' -HHSQ2 'Did any HH member go sleep hungry?' -HHSQ3 'Did any HH member go whole day without food?'. -EXECUTE. - - -**The values of HHSQ1, HHSQ2, and HHSQ3 are summed for each household to calculate the HHS score** - -COMPUTE HHS=HHSQ1 + HHSQ2 + HHSQ3. - -Variable labels HHS 'Household Hunger Score'. -EXECUTE. - -**Each household should have an HHS score between 0 and 6. These values are then used to generate the HHS indicators** - -FREQUENCIES VARIABLES=HHS - /STATISTICS=MEAN MEDIAN MINIMUM MAXIMUM - /ORDER=ANALYSIS. - -**To tabulate the categorical HHS indicator, two different cutoff values (> 1 and > 3) are applied to the HHS scores that were generated in Step 3 above** - -RECODE HHS (0 thru 1=1) (2 thru 3=2) (4 thru Highest=3) INTO HHSCat. -variable labels HHSCat 'Household Hunger Score Categories'. -EXECUTE. - - - -***define labels - -Value labels HHSCat - -1 `No or little hunger in the household` -2 `Moderate hunger in the household` -3 `Severe hunger in the household`. - - -**Note: to tabulate the categorical HHS indicator for the IPC, using the four IPC cutoff values (0, 1, 2-3, 4 and 5+) are applied to the HHS scores that were generated in Step 3 above** - -RECODE HHSr (0=0) (1=1) (2 thru 3=2) (4=3) (5 thru Highest=4) INTO HHSCatr. -variable labels HHSCatr 'Household Hunger Score Categories'. -EXECUTE. - - -***define labels - -Value labels HHSCat_IPC -0 No hunger in the household -1 little hunger in the household stress -2 Moderate hunger in the household crisis -3 Severe hunger in the household emergency -4 Very severe hunger in the household catastrophe. - -FREQUENCIES HHSCat_IPC. - -*****END***** diff --git a/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.R b/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.R index 6359b4f..0063bc7 100644 --- a/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.R +++ b/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.R @@ -1,133 +1,124 @@ -library(tidyverse) -library(labelled) -library(expss) +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Livelihood Coping Strategy for Food Security (LCS-EN) +#------------------------------------------------------------------------------# +# This script calculates the Livelihood Coping Strategy for Food Security (LCS-EN) +# indicator based on household responses to various coping strategies. The indicator +# considers stress, crisis, and emergency strategies and summarizes coping behavior. -#add sample data -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/LCS_Sample_Survey/LHCS_EN_Sample_Survey.csv") +# Important note: this script is only an example. When calculating the indicator, +# you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that +# were selected for your specific case. +# Please find more guidance on the indicator at the LCS-EN VAM Resource Center page: +# https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/livelihood-coping-strategies-essential-needs -#assign variable and value labels -#variable labels -var_label(data$LcsEN_stress_DomAsset) <- "Sold household assets/goods (radio, furniture, television, jewellery etc.) to meet essential needs" -var_label(data$LcsEN_stress_Saving) <- "Spent savings to meet essential needs" -var_label(data$LcsEN_stress_CrdtFood) <- "Purchased food or other essential items on credit" -var_label(data$LcsEN_stress_BorrowCash) <- "Borrowed money to meet essential needs" -var_label(data$LcsEN_crisis_ProdAssets) <- "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.) to meet essential needs" -var_label(data$LcsEN_crisis_Health) <- "Reduced expenses on health (including drugs) to meet other essential needs" -var_label(data$LcsEN_crisis_OutSchool) <- "Withdrew children from school to meet essential needs" -var_label(data$LcsEN_em_ResAsset) <- "Mortgaged/Sold house that the household was permanently living in or sold land to meet essential needs" -var_label(data$LcsEN_em_Begged) <- "Begged and/or scavenged (asked strangers for money/food) to meet essential needs" -var_label(data$LcsEN_em_IllegalAct) <- "Engaged in socially degrading, high risk, or exploitive jobs, or life-threatening income activities (e.g., smuggling, theft, join armed groups, prostitution) to meet essential needs" -#value labels -data <- data %>% - mutate(across(c(LcsEN_stress_DomAsset,LcsEN_stress_Saving,LcsEN_stress_CrdtFood,LcsEN_stress_BorrowCash,LcsEN_crisis_ProdAssets,LcsEN_crisis_Health,LcsEN_crisis_OutSchool,LcsEN_em_ResAsset,LcsEN_em_Begged,LcsEN_em_IllegalAct), ~labelled(., labels = c( - "No, because I did not need to" = 10, - "No, because I already sold those assets or have engaged in this activity within the last 12 months and cannot continue to do it" = 20, - "Yes" = 30, - "Not applicable (don’t have access to this strategy)" = 9999 - )))) - -#create a variable to specify if the household used any of the strategies by severity -#stress -data <- data %>% mutate(stress_coping_EN = case_when( - LcsEN_stress_DomAsset == 20 | LcsEN_stress_DomAsset == 30 ~ 1, - LcsEN_stress_Saving == 20 | LcsEN_stress_Saving == 30 ~ 1, - LcsEN_stress_CrdtFood == 20 | LcsEN_stress_CrdtFood == 30 ~1, - LcsEN_stress_BorrowCash == 20 | LcsEN_stress_BorrowCash == 30 ~ 1, - TRUE ~ 0)) -var_label(data$stress_coping_EN) <- "Did the HH engage in stress coping strategies" -#Crisis -data <- data %>% mutate(crisis_coping_EN = case_when( - LcsEN_crisis_ProdAssets == 20 | LcsEN_crisis_ProdAssets == 30 ~ 1, - LcsEN_crisis_Health == 20 | LcsEN_crisis_Health == 30 ~ 1, - LcsEN_crisis_OutSchool == 20 | LcsEN_crisis_OutSchool == 30 ~ 1, - TRUE ~ 0)) -var_label(data$crisis_coping_EN) <- "Did the HH engage in crisis coping strategies" -#Emergency -data <- data %>% mutate(emergency_coping_EN = case_when( - LcsEN_em_ResAsset == 20 | LcsEN_em_ResAsset == 30 ~ 1, - LcsEN_em_Begged == 20 | LcsEN_em_Begged == 30 ~ 1, - LcsEN_em_IllegalAct == 20 | LcsEN_em_IllegalAct == 30 ~ 1, - TRUE ~ 0)) -var_label(data$emergency_coping_EN) <- "Did the HH engage in emergency coping strategies" - -#calculate Max_coping_behaviour -data <- data %>% mutate(Max_coping_behaviourEN = case_when( - emergency_coping_EN == 1 ~ 4, - crisis_coping_EN == 1 ~ 3, - stress_coping_EN == 1 ~ 2, - TRUE ~ 1)) -var_label(data$Max_coping_behaviourEN) <- "Summary of asset depletion" -val_lab(data$Max_coping_behaviourEN) = num_lab(" - 1 HH not adopting coping strategies - 2 Stress coping strategies - 3 Crisis coping strategies - 4 Emergencies coping strategies -") - - -#creates a table of the weighted percentage of Max_coping_behaviourFS by -#creating a temporary variable to display value labels -#and providing the option to use weights if needed - - -Max_coping_behaviourEN_table_wide <- data %>% - drop_na(Max_coping_behaviourEN) %>% - count(Max_coping_behaviourEN_lab = as.character(Max_coping_behaviourEN)) %>% # if weights are needed use instead the row below - #count(Max_coping_behaviourEN_lab = as.character(Max_coping_behaviourEN), wt = nameofweightvariable) - mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = Max_coping_behaviourEN_lab, - values_from = Percentage, - values_fill = 0) - -#calculate LCS-FS indicator using the LCS-EN module to be able to calculate CARI - -#depending on the format you download the data sets and the import options you select the format of the variable could be different - in general, recommend downloading with the multiple response split into seperate columns with 1/0 - -#define value labels - -var_label(data$`LhCSIEnAccess/1`) <- "To buy food" -var_label(data$`LhCSIEnAccess/2`) <- "To pay for rent or access adequate shelter" -var_label(data$`LhCSIEnAccess/3`) <- "To pay for school fees and other education costs" -var_label(data$`LhCSIEnAccess/4`) <- "To cover health expenses" -var_label(data$`LhCSIEnAccess/5`) <- "To buy essential non-food items (clothes, small furniture...)" -var_label(data$`LhCSIEnAccess/6`) <- "To access water or sanitation facilities" -var_label(data$`LhCSIEnAccess/7`) <- "To access essential dwelling services (electricity, energy, waste disposal…)" -var_label(data$`LhCSIEnAccess/8`) <- "To pay for existing debts" -var_label(data$`LhCSIEnAccess/999`) <- "Other" - -#multiple response tables - get % of each reason for coping - -data %>% - select(`LhCSIEnAccess/1`:`LhCSIEnAccess/999`) %>% - map(., ~tabyl(.)) - -#Calculating LCS-FS using the LCS-EN module - -#Important note: If "To buy food" is not among the reasons selected for applying livelihood coping strategies then these case/households should be considered under 'HH not adopting coping strategies' when computing CARI. - -#If the design of this question provides responses in a single cell then the analyst should split the responses in excel prior to running this syntax - -#annoyingly its hard to recode because its labelled - removing labels then will add back afterwards - this code should be improved later -data$Max_coping_behaviourEN <- unlab(data$Max_coping_behaviourEN) - -data <- data %>% mutate(Max_coping_behaviour = case_when( - `LhCSIEnAccess/1` == 0 ~ 1, - TRUE ~ Max_coping_behaviourEN)) - -#value labels -data <- data %>% - mutate(across(c(Max_coping_behaviourEN, Max_coping_behaviour), ~labelled(., labels = c( - "HH not adopting coping strategies" = 1, - "Stress coping strategies" = 2, - "Crisis coping strategies" = 3, - "Emergencies coping strategies" =4 - )))) - -data %>% - select(Max_coping_behaviourEN, Max_coping_behaviour) %>% - map(., ~tabyl(.)) +library(tidyverse) +library(labelled) +library(expss) +# Load data +#data <- read_csv("~/GitHub/RAMResourcesScripts/Static/LCS_EN_Sample_Survey.csv") + +# Assign variable and value labels +var_label(data$LcsEN_stress_DomAsset) <- "Sold household assets/goods (radio, furniture, refrigerator, television, jewellery, etc.)" +var_label(data$LcsEN_stress_Utilities) <- "Reduced or ceased payments on essential utilities and bills" +var_label(data$LcsEN_stress_Saving) <- "Spent savings" +var_label(data$LcsEN_stress_BorrowCash) <- "Borrowed cash" +var_label(data$LcsEN_crisis_ProdAssets) <- "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.)" +var_label(data$LcsEN_crisis_Health) <- "Reduced expenses on health (including drugs)" +var_label(data$LcsEN_crisis_OutSchool) <- "Withdrew children from school" +var_label(data$LcsEN_em_ResAsset) <- "Mortgaged/Sold house or land" +var_label(data$LcsEN_em_Begged) <- "Begged and/or scavenged (asked strangers for money/food/other goods)" +var_label(data$LcsEN_em_IllegalAct) <- "Had to engage in illegal income activities (theft, prostitution)" +data <- data %>% + mutate(across(c(LcsEN_stress_DomAsset, LcsEN_stress_Utilities, LcsEN_stress_Saving, LcsEN_stress_BorrowCash, + LcsEN_crisis_ProdAssets, LcsEN_crisis_Health, LcsEN_crisis_OutSchool, + LcsEN_em_ResAsset, LcsEN_em_Begged, LcsEN_em_IllegalAct), + ~labelled(., labels = c( + "No, because we did not need to" = 10, + "No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to do it" = 20, + "Yes" = 30, + "Not applicable (don’t have access to this strategy)" = 9999 + )))) + +# Treatment of missing values +frequencies <- data %>% summarise(across(starts_with("LcsEN"), ~ sum(is.na(.)))) +print(frequencies) + +# Custom handling for missing values can be added here if required + +# Stress strategies +data <- data %>% + mutate(stress_coping_EN = case_when( + LcsEN_stress_DomAsset %in% c(20, 30) | LcsEN_stress_Utilities %in% c(20, 30) | + LcsEN_stress_Saving %in% c(20, 30) | LcsEN_stress_BorrowCash %in% c(20, 30) ~ 1, + TRUE ~ 0)) + +var_label(data$stress_coping_EN) <- "Did the HH engage in stress coping strategies?" + +# Crisis strategies +data <- data %>% + mutate(crisis_coping_EN = case_when( + LcsEN_crisis_ProdAssets %in% c(20, 30) | LcsEN_crisis_Health %in% c(20, 30) | + LcsEN_crisis_OutSchool %in% c(20, 30) ~ 1, + TRUE ~ 0)) + +var_label(data$crisis_coping_EN) <- "Did the HH engage in crisis coping strategies?" + +# Emergency strategies +data <- data %>% + mutate(emergency_coping_EN = case_when( + LcsEN_em_ResAsset %in% c(20, 30) | LcsEN_em_Begged %in% c(20, 30) | + LcsEN_em_IllegalAct %in% c(20, 30) ~ 1, + TRUE ~ 0)) + +var_label(data$emergency_coping_EN) <- "Did the HH engage in emergency coping strategies?" + +# Coping behavior +data <- data %>% + mutate(temp_nonmiss_number = rowSums(!is.na(select(., starts_with("LcsEN")))), + max_coping_behaviourEN = case_when( + temp_nonmiss_number > 0 ~ 1, + stress_coping_EN == 1 ~ 2, + crisis_coping_EN == 1 ~ 3, + emergency_coping_EN == 1 ~ 4, + TRUE ~ NA_real_)) + +var_label(data$max_coping_behaviourEN) <- "Summary of asset depletion" +val_lab(data$max_coping_behaviourEN) <- c("HH not adopting coping strategies" = 1, + "Stress coping strategies" = 2, + "Crisis coping strategies" = 3, + "Emergency coping strategies" = 4) + +# Remove temporary variables +data <- data %>% select(-temp_nonmiss_number) + +# Analyze reasons for adopting strategies +data <- data %>% + rename(LhCSIEnAccess1 = LhCSIEnAccess.1, LhCSIEnAccess2 = LhCSIEnAccess.2, LhCSIEnAccess3 = LhCSIEnAccess.3, + LhCSIEnAccess4 = LhCSIEnAccess.4, LhCSIEnAccess5 = LhCSIEnAccess.5, LhCSIEnAccess6 = LhCSIEnAccess.6, + LhCSIEnAccess7 = LhCSIEnAccess.7, LhCSIEnAccess8 = LhCSIEnAccess.8, LhCSIEnAccess999 = LhCSIEnAccess.999) + +var_label(data$LhCSIEnAccess1) <- "Adopted strategies to buy food" +var_label(data$LhCSIEnAccess2) <- "Adopted strategies to pay for rent" +var_label(data$LhCSIEnAccess3) <- "Adopted strategies to pay school, education costs" +var_label(data$LhCSIEnAccess4) <- "Adopted strategies to cover health expenses" +var_label(data$LhCSIEnAccess5) <- "Adopted strategies to buy essential non-food items (clothes, small furniture)" +var_label(data$LhCSIEnAccess6) <- "Adopted strategies to access water or sanitation facilities" +var_label(data$LhCSIEnAccess7) <- "Adopted strategies to access essential dwelling services (electricity, energy, waste disposal...)" +var_label(data$LhCSIEnAccess8) <- "Adopted strategies to pay for existing debts" +var_label(data$LhCSIEnAccess999) <- "Adopted strategies for other reasons" + +desc_stats <- data %>% summarise(across(starts_with("LhCSIEnAccess"), mean, na.rm = TRUE)) + +# Calculating LCS-FS using the LCS-EN module +data <- data %>% + mutate(max_coping_behaviourFS = if_else(!is.na(max_coping_behaviourEN), max_coping_behaviourEN, NA_real_), + max_coping_behaviourFS = if_else(LhCSIEnAccess1 == 0 & !is.na(max_coping_behaviourFS), 1, max_coping_behaviourFS)) + +var_label(data$max_coping_behaviourFS) <- "Summary of asset depletion (converted from EN to FS)" + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.do b/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.do index 98c612c..5363cf6 100644 --- a/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.do +++ b/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.do @@ -1,213 +1,233 @@ -******************************************************************************** - * STATA Syntax for the Livelihood Coping Strategy for Essential Needs (LCS-EN) indicator - ******************************************************************************* - -* Important note: this syntax file is only an example. When calculating the indicator, you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that were selected for your specific case. +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Calculating Livelihood Coping Strategy for Essential Needs (LCS-EN) +*------------------------------------------------------------------------------* -* Please find more guidance on the indicator at the LCS-EN VAM Resource Center page: https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/livelihood-coping-strategies-essential-needs +* This script calculates the Livelihood Coping Strategy for Essential Needs (LCS-EN) +* indicator based on household responses to various coping strategies. The indicator +* considers stress, crisis, and emergency strategies and summarizes coping behavior. -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +* Important note: this syntax file is only an example. When calculating the indicator, +* you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that +* were selected for your specific case. +* Please find more guidance on the indicator at the LCS-EN VAM Resource Center page: +* https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/livelihood-coping-strategies-essential-needs + +*------------------------------------------------------------------------------* * VALUE LABELS -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* + +label define LcsEN_label /// + 10 "No, because we did not need to" /// + 20 "No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to" /// + 30 "Yes" /// + 9999 "Not applicable (don't have children/these assets)" -lab def LcsEN_label /// - 10 "No, because we did not need to" /// - 20 "No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to" /// - 30 "Yes" /// - 9999 "Not applicable (don't have children/these assets)" - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +label values LcsEN_stress_DomAsset LcsEN_stress_Utilities LcsEN_stress_Saving /// + LcsEN_stress_BorrowCash LcsEN_crisis_ProdAssets LcsEN_crisis_Health /// + LcsEN_crisis_OutSchool LcsEN_em_ResAsset LcsEN_em_Begged /// + LcsEN_em_IllegalAct LcsEN_label +*------------------------------------------------------------------------------* * TREATMENT OF MISSING VALUES -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* The LCS-EN standard module does not allow for skipping questions, so there should not be missing values. Check that indeed this is the case. +*------------------------------------------------------------------------------* + +* The LCS-EN standard module does not allow for skipping questions, so there should +* not be missing values. Check that indeed this is the case. + foreach var of varlist LcsEN_stress_DomAsset LcsEN_stress_Utilities LcsEN_stress_Saving LcsEN_stress_BorrowCash LcsEN_crisis_ProdAssets LcsEN_crisis_Health LcsEN_crisis_OutSchool LcsEN_em_ResAsset LcsEN_em_Begged LcsEN_em_IllegalAct { -tab `var' , missing + tab `var', missing } -* If there are no missings, you can just go ahead. If there are missing values, then you will need to understand why and, based on that, treat these missing values. +* If there are no missings, you can just go ahead. If there are missing values, then +* you will need to understand why and, based on that, treat these missing values. - * POTENTIAL REASON 1: Although not recommended, customized modules might include skip patterns to avoid asking about strategies that are not relevant for the household. For example, a skip pattern might be introduced so that a question on withdrawing children from school is not asked to households with no children. In these cases, it is important to recode missing values to 9999 "Not applicable (don't have children/these assets)". - - * POTENTIAL REASON 2: Although in the standard module questions should be mandatory, customized modules might allow to skip questions (for example because the respondent refuse to answer). In these cases, missing values should be left as such. +* POTENTIAL REASON 1: Although not recommended, customized modules might include skip +* patterns to avoid asking about strategies that are not relevant for the household. +* For example, a skip pattern might be introduced so that a question on withdrawing +* children from school is not asked to households with no children. In these cases, +* it is important to recode missing values to 9999 "Not applicable (don't have children/these assets)". -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +* POTENTIAL REASON 2: Although in the standard module questions should be mandatory, +* customized modules might allow to skip questions (for example because the respondent +* refuses to answer). In these cases, missing values should be left as such. +*------------------------------------------------------------------------------* * STRESS STRATEGIES +*------------------------------------------------------------------------------* -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of four stress strategies. You will need to replace with the four strategies selected for your specific case - -*Variable labels: - -lab var LcsEN_stress_DomAsset "Sold household assets/goods (radio, furniture, refrigerator, relevision, jewellery, etc.)" - -lab var LcsEN_stress_Utilities "Reduced or ceased payments on essential utilities and bills " - -lab var LcsEN_stress_Saving "Spent saving" - -lab var LcsEN_stress_BorrowCash "Borrowed cash" - - -foreach var of varlist LcsEN_stress_DomAsset LcsEN_stress_Utilities LcsEN_stress_Saving LcsEN_stress_BorrowCash { - -lab val `var' LcsEN_label -} - - -*% of household who adopted one or more stress coping strategies +* Reminder: this is just an example of four stress strategies. You will need to +* replace with the four strategies selected for your specific case -gen stress_coping_EN=(LcsEN_stress_DomAsset==20 | LcsEN_stress_DomAsset==30) | (LcsEN_stress_Utilities==20 | LcsEN_stress_Utilities==30) | (LcsEN_stress_Saving==20 | LcsEN_stress_Saving==30) | (LcsEN_stress_BorrowCash==20 | LcsEN_stress_BorrowCash==30) +* Variable labels +label variable LcsEN_stress_DomAsset "Sold household assets/goods (radio, furniture, refrigerator, television, jewellery, etc.)" +label variable LcsEN_stress_Utilities "Reduced or ceased payments on essential utilities and bills" +label variable LcsEN_stress_Saving "Spent savings" +label variable LcsEN_stress_BorrowCash "Borrowed cash" - -lab var stress_coping_EN "Did the HH engage in stress coping strategies?" +* % of households who adopted one or more stress coping strategies +gen stress_coping_EN = (LcsEN_stress_DomAsset == 20 | LcsEN_stress_DomAsset == 30) | /// + (LcsEN_stress_Utilities == 20 | LcsEN_stress_Utilities == 30) | /// + (LcsEN_stress_Saving == 20 | LcsEN_stress_Saving == 30) | /// + (LcsEN_stress_BorrowCash == 20 | LcsEN_stress_BorrowCash == 30) - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +label variable stress_coping_EN "Did the HH engage in stress coping strategies?" +*------------------------------------------------------------------------------* * CRISIS STRATEGIES +*------------------------------------------------------------------------------* -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of three crisis strategies. You will need to replace with the three strategies selected for your specific case - -*Variables lables: - -lab var LcsEN_crisis_ProdAssets "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.)" - -lab var LcsEN_crisis_Health "Reduced expenses on health (including medicines)" - -lab var LcsEN_crisis_OutSchool "Withdrew children from school" - - -foreach var of varlist LcsEN_crisis_ProdAssets LcsEN_crisis_Health LcsEN_crisis_OutSchool { - -lab val `var' LcsEN_label - -} - - -*% of household who adopted one or more crisis coping strategies - -gen crisis_coping_EN=(LcsEN_crisis_ProdAssets==20 | LcsEN_crisis_ProdAssets==30) | (LcsEN_crisis_Health==20 | LcsEN_crisis_Health==30) | (LcsEN_crisis_OutSchool==20 | LcsEN_crisis_OutSchool==30) - +* Reminder: this is just an example of three crisis strategies. You will need to +* replace with the three strategies selected for your specific case -lab var crisis_coping_EN "Did HH engage in crisis coping strategies?" +* Variable labels +label variable LcsEN_crisis_ProdAssets "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.)" +label variable LcsEN_crisis_Health "Reduced expenses on health (including drugs)" +label variable LcsEN_crisis_OutSchool "Withdrew children from school" +* % of households who adopted one or more crisis coping strategies +gen crisis_coping_EN = (LcsEN_crisis_ProdAssets == 20 | LcsEN_crisis_ProdAssets == 30) | /// + (LcsEN_crisis_Health == 20 | LcsEN_crisis_Health == 30) | /// + (LcsEN_crisis_OutSchool == 20 | LcsEN_crisis_OutSchool == 30) -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +label variable crisis_coping_EN "Did the HH engage in crisis coping strategies?" -* EMERGENCY STRATEGIES: +*------------------------------------------------------------------------------* +* EMERGENCY STRATEGIES +*------------------------------------------------------------------------------* -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of three emergency strategies. You will need to replace with the three strategies selected for your specific case +* Reminder: this is just an example of three emergency strategies. You will need to +* replace with the three strategies selected for your specific case -*Variables lables: +* Variable labels +label variable LcsEN_em_ResAsset "Mortgaged/Sold house or land" +label variable LcsEN_em_Begged "Begged and/or scavenged (asked strangers for money/food/other goods)" +label variable LcsEN_em_IllegalAct "Had to engage in illegal income activities (theft, prostitution)" -lab var LcsEN_em_ResAsset "Mortaged/Sold house or land" +* % of households who adopted one or more emergency coping strategies +gen emergency_coping_EN = (LcsEN_em_ResAsset == 20 | LcsEN_em_ResAsset == 30) | /// + (LcsEN_em_Begged == 20 | LcsEN_em_Begged == 30) | /// + (LcsEN_em_IllegalAct == 20 | LcsEN_em_IllegalAct == 30) -lab var LcsEN_em_Begged "Begged and/or scavenged (asked strangers for money/food/other goods)" +label variable emergency_coping_EN "Did the HH engage in emergency coping strategies?" -lab var LcsEN_em_IllegalAct "Had to engage in illegal income activities (theft, prostitution)" +*------------------------------------------------------------------------------* +* COPING BEHAVIOR +*------------------------------------------------------------------------------* +egen temp_nonmiss_number = rownonmiss(LcsEN_stress_DomAsset LcsEN_stress_Utilities /// + LcsEN_stress_Saving LcsEN_stress_BorrowCash /// + LcsEN_crisis_ProdAssets LcsEN_crisis_Health /// + LcsEN_crisis_OutSchool LcsEN_em_ResAsset /// + LcsEN_em_Begged LcsEN_em_IllegalAct) -foreach var of varlist LcsEN_em_ResAsset LcsEN_em_Begged LcsEN_em_IllegalAct { +* This variable counts the strategies with valid (i.e. non missing) values - normally +* it should be equal to 10 for all respondents +label variable temp_nonmiss_number "Number of strategies with non missing values" -lab val `var' LcsEN_label +gen Max_coping_behaviourEN = . if temp_nonmiss_number > 0 +replace Max_coping_behaviourEN = 2 if stress_coping_EN == 1 +replace Max_coping_behaviourEN = 3 if crisis_coping_EN == 1 +replace Max_coping_behaviourEN = 4 if emergency_coping_EN == 1 -} - - -*% of household who adopted one or more emergency coping strategies - -gen emergency_coping_EN=(LcsEN_em_ResAsset==20 | LcsEN_em_ResAsset==30) | (LcsEN_em_Begged==20 | LcsEN_em_Begged==30) | (LcsEN_em_IllegalAct==20 | LcsEN_em_IllegalAct==30) - - lab var emergency_coping_EN "Did the HH engage in emergency coping strategies?" - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -* COPING BEHAVIOR - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -egen temp_nonmiss_number = rownonmiss(LcsEN_stress_DomAsset LcsEN_stress_Utilities LcsEN_stress_Saving LcsEN_stress_BorrowCash LcsEN_crisis_ProdAssets LcsEN_crisis_Health LcsEN_crisis_OutSchool LcsEN_em_ResAsset LcsEN_em_Begged LcsEN_em_IllegalAct) //this variable counts the strategies with valid (i.e. non missing) values - normally it should be equal to 10 for all respondents -label var temp_nonmiss_number "Number of strategies with non missing values" - -gen Max_coping_behaviourEN=1 if temp_nonmiss_number>0 // the Max_coping_behaviourEN variable will be missing for an observation if answers to strategies are all missing - -replace Max_coping_behaviourEN=2 if stress_coping_EN==1 - -replace Max_coping_behaviourEN=3 if crisis_coping_EN==1 - -replace Max_coping_behaviourEN=4 if emergency_coping_EN==1 - - -lab var Max_coping_behaviourEN "Summary of asset depletion" - -lab def Max_coping_behaviourEN_label 1"HH not adopting coping strategies" 2"Stress coping strategies" 3"Crisis coping strategies" 4"Emergency coping strategies" - -lab val Max_coping_behaviourEN Max_coping_behaviourEN_label +label variable Max_coping_behaviourEN "Summary of asset depletion" +label define Max_coping_behaviourEN_label 1 "HH not adopting coping strategies" /// + 2 "Stress coping strategies" /// + 3 "Crisis coping strategies" /// + 4 "Emergency coping strategies" +label values Max_coping_behaviourEN Max_coping_behaviourEN_label drop temp_nonmiss_number -* tabulate results +* Tabulate results tab Max_coping_behaviourEN, missing -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -* ANALYSE THE REAONS WHY STRATEGIES ARE ADOPTED +*------------------------------------------------------------------------------* +* ANALYZE THE REASONS WHY STRATEGIES ARE ADOPTED +*------------------------------------------------------------------------------* -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* The final question included in the LCS-EN module asks the main reasons why coping strategies were adopted (LhCSIEnAccess). Depending on the format you download the data sets and the import options you select the format of the variable could be different - in general, it is recommend downloading with the multiple response split into seperate columns (i.e. variables) with 1/0. The rest of the syntax assumes that the variable LhCSIEnAccess was exported in this way. +* The final question included in the LCS-EN module asks the main reasons why coping +* strategies were adopted (LhCSIEnAccess). Depending on the format you download the +* data sets and the import options you select, the format of the variable could be +* different. In general, it is recommended to download with the multiple response +* split into separate columns (i.e., variables) with 1/0. The rest of the syntax +* assumes that the variable LhCSIEnAccess was exported in this way. -* In Stata it is assumed that varibales are named using an underscore before the suffix indicating the answer opption (i.e. LhCSIEnAccess_1, LhCSIEnAccess_2...). This is way that variables are automatically named when a dataset is saved from SPSS to Stata (DTA). In SPSS (SAV) a dot is used instead of the underscore (i.e. LhCSIEnAccess.1, LhCSIEnAccess.2...) +* In Stata, it is assumed that variables are named using an underscore before the +* suffix indicating the answer option (i.e., LhCSIEnAccess_1, LhCSIEnAccess_2...). +* This is the way that variables are automatically named when a dataset is saved +* from SPSS to Stata (DTA). In SPSS (SAV), a dot is used instead of the underscore +* (i.e., LhCSIEnAccess.1, LhCSIEnAccess.2...). * Rename variables to remove the underscore foreach i in 1 2 3 4 5 6 7 8 999 { -capture confirm variable LhCSIEnAccess_`i' // check if actually the variables are named with underscore. Otherwise make sure to rename manually. +capture confirm variable LhCSIEnAccess_`i' +// check if actually the variables are named with underscore. Otherwise make sure to rename manually. if !_rc { rename LhCSIEnAccess_`i' LhCSIEnAccess`i' } - else { - capture confirm variable LhCSIEnAccess`i' // check if variable already has correct name - if !_rc { - di "LhCSIEnAccess`i' already named correctly" - } - else { - di "LhCSIEnAccess `i' nned to be renamed manually or does not exist" - } - } + else { + capture confirm variable LhCSIEnAccess`i' + // check if variable already has correct name + if !_rc { + di "LhCSIEnAccess`i' already named correctly" + } + else { + di "LhCSIEnAccess `i' nned to be renamed manually or does not exist" + } + } } -* Label variables -label var LhCSIEnAccess1 "Adopted strategies to buy food" -label var LhCSIEnAccess2 "Adopted strategies to pay for rent" -label var LhCSIEnAccess3 "Adopted strategies to pay school, education costs" -label var LhCSIEnAccess4 "Adopted strategies to cover health expenses" -label var LhCSIEnAccess5 "Adopted strategies to buy essential non-food items (clothes, small furniture)" -label var LhCSIEnAccess6 "Adopted strategies to access water or sanitation facilities" -label var LhCSIEnAccess7 "Adopted strategies to access essential dwelling services (electricity, energy, waste disposal...)" -label var LhCSIEnAccess8 "Adopted strategies to pay for existing debts" -label var LhCSIEnAccess999 "Adopted strategies for other reasons" - -*tabulate results - -tabstat LhCSIEnAccess1 LhCSIEnAccess2 LhCSIEnAccess3 LhCSIEnAccess4 LhCSIEnAccess5 LhCSIEnAccess6 LhCSIEnAccess7 LhCSIEnAccess8 LhCSIEnAccess999,statistics(mean) columns(statistics) - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +* Rename variables to remove the underscore +foreach i in 1 2 3 4 5 6 7 8 999 { + capture confirm variable LhCSIEnAccess_`i' + if !_rc { + rename LhCSIEnAccess_`i' LhCSIEnAccess`i' + } else { + capture confirm variable LhCSIEnAccess`i' + if !_rc { + di "LhCSIEnAccess`i' already named correctly" + } else { + di "LhCSIEnAccess`i' needs to be renamed manually or does not exist" + } + } +} +* Label variables +label variable LhCSIEnAccess1 "Adopted strategies to buy food" +label variable LhCSIEnAccess2 "Adopted strategies to pay for rent" +label variable LhCSIEnAccess3 "Adopted strategies to pay school, education costs" +label variable LhCSIEnAccess4 "Adopted strategies to cover health expenses" +label variable LhCSIEnAccess5 "Adopted strategies to buy essential non-food items (clothes, small furniture)" +label variable LhCSIEnAccess6 "Adopted strategies to access water or sanitation facilities" +label variable LhCSIEnAccess7 "Adopted strategies to access essential dwelling services (electricity, energy, waste disposal...)" +label variable LhCSIEnAccess8 "Adopted strategies to pay for existing debts" +label variable LhCSIEnAccess999 "Adopted strategies for other reasons" + +* Tabulate results +tabstat LhCSIEnAccess1 LhCSIEnAccess2 LhCSIEnAccess3 LhCSIEnAccess4 LhCSIEnAccess5 /// + LhCSIEnAccess6 LhCSIEnAccess7 LhCSIEnAccess8 LhCSIEnAccess999, /// + statistics(mean) columns(statistics) + +*------------------------------------------------------------------------------* * CALCULATING LCS-FS USING THE LCS-EN MODULE +*------------------------------------------------------------------------------* -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* To estimate food insecurity using CARI, the LCS-FS indicator should be used. In this case the LCS-EN inidicator can be converted to the LCS-FS using the final question included in the LCS-EN module asking the main reasons why coping strategies were adopted (LhCSIEnAccess). If "to buy food" is not among the reasons selected for applying livelihood coping strategies then these cases/households should be considered under "not coping" when computing CARI - +* To estimate food insecurity using CARI, the LCS-FS indicator should be used. +* In this case, the LCS-EN indicator can be converted to the LCS-FS using the +* final question included in the LCS-EN module asking the main reasons why +* coping strategies were adopted (LhCSIEnAccess). If "to buy food" is not +* among the reasons selected for applying livelihood coping strategies, then +* these cases/households should be considered under "not coping" when computing CARI. -gen Max_coping_behaviourFS = Max_coping_behaviourEN if Max_coping_behaviourEN!=. // generate variable in order to continue with CARI syntax +gen Max_coping_behaviourFS = Max_coping_behaviourEN if !mi(Max_coping_behaviourEN) +* Generate variable in order to continue with CARI syntax +replace Max_coping_behaviourFS = 1 if LhCSIEnAccess1 == 0 & !mi(Max_coping_behaviourFS) -replace Max_coping_behaviourFS=1 if LhCSIEnAccess1==0 & Max_coping_behaviourFS!=. -label var Max_coping_behaviourFS "Summary of asset depletion (converted from EN to FS)" +label variable Max_coping_behaviourFS "Summary of asset depletion (converted from EN to FS)" -* tabulate results +* Tabulate results tab Max_coping_behaviourFS, missing + +* End of Scripts \ No newline at end of file diff --git a/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.sps b/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.sps index 1156420..72b4e8d 100644 --- a/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.sps +++ b/Indicators/Livelihood-Coping-Strategies-EN/LCS-EN-indicator.sps @@ -1,215 +1,197 @@ -* Encoding: UTF-8. -******************************************************************************** - * SPSS Syntax for the Livelihood Coping Strategy for Food Security (LCS-EN) indicator - ******************************************************************************* - -* Important note: this syntax file is only an example. When calculating the indicator, you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that were selected for your specific case. +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Calculating Livelihood Coping Strategy for Food Security (LCS-EN) +*------------------------------------------------------------------------------* -* Please find more guidance on the indicator at the LCS-EN VAM Resource Center page: https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/livelihood-coping-strategies-essential-needs +* This script calculates the Livelihood Coping Strategy for Food Security (LCS-EN) +* indicator based on household responses to various coping strategies. The indicator +* considers stress, crisis, and emergency strategies and summarizes coping behavior. -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* VALUE LABELS -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +* important note: this syntax file is only an example. when calculating the indicator, +* you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that +* were selected for your specific case. + +* please find more guidance on the indicator at the lcs-en vam resource center page: +* https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/livelihood-coping-strategies-essential-needs +* VALUE LABELS VALUE LABELS - LcsEN_stress_DomAsset - LcsEN_stress_Utilities - LcsEN_stress_Saving - LcsEN_stress_BorrowCash - LcsEN_crisis_ProdAssets - LcsEN_crisis_Health - LcsEN_crisis_OutSchool - LcsEN_em_ResAsset - LcsEN_em_Begged - LcsEN_em_IllegalAct - 10 'No, because we did not need to' - 20 'No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to' - 30 'Yes' - 9999 'Not applicable (do not have children/these assets)'. - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* + LcsEN_stress_DomAsset + LcsEN_stress_Utilities + LcsEN_stress_Saving + LcsEN_stress_BorrowCash + LcsEN_crisis_ProdAssets + LcsEN_crisis_Health + LcsEN_crisis_OutSchool + LcsEN_em_ResAsset + LcsEN_em_Begged + LcsEN_em_IllegalAct + 10 'No, because we did not need to' + 20 'No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to' + 30 'Yes' + 9999 'Not applicable (do not have children/these assets)'. + * TREATMENT OF MISSING VALUES -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* The LCS-EN standard module does not allow for skipping questions, so there should not be missing values. Check that indeed this is the case. -FREQUENCIES LcsEN_stress_DomAsset LcsEN_stress_Utilities LcsEN_stress_Saving LcsEN_stress_BorrowCash LcsEN_crisis_ProdAssets LcsEN_crisis_Health LcsEN_crisis_OutSchool LcsEN_em_ResAsset LcsEN_em_Begged LcsEN_em_IllegalAct. - -* If there are no missings, you can just go ahead. If there are missing values, then you will need to understand why and, based on that, treat these missing values. +* The lcs-en standard module does not allow for skipping questions, so there should not be missing values. check that indeed this is the case. +frequencies lcsen_stress_domasset lcsen_stress_utilities lcsen_stress_saving lcsen_stress_borrowcash lcsen_crisis_prodassets lcsen_crisis_health lcsen_crisis_outschool lcsen_em_resasset lcsen_em_begged lcsen_em_illegalact. - * POTENTIAL REASON 1: Although not recommended, customized modules might include skip patterns to avoid asking about strategies that are not relevant for the household. - *For example, a skip pattern might be introduced so that a question on withdrawing children from school is not asked to households with no children. - *In these cases, it is important to recode missing values to 9999 'Not applicable (don't have children/these assets)'. +* if there are no missings, you can just go ahead. if there are missing values, then you will need to understand why and, based on that, treat these missing values. + * potential reason 1: although not recommended, customized modules might include skip patterns to avoid asking about strategies that are not relevant for the household. + *for example, a skip pattern might be introduced so that a question on withdrawing children from school is not asked to households with no children. + *in these cases, it is important to recode missing values to 9999 'not applicable (don't have children/these assets)'. - * POTENTIAL REASON 2: Although in the standard module questions should be mandatory, customized modules might allow to skip questions (for example because the respondent refuse to answer). - *In these cases, missing values should be left as such. - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* + * potential reason 2: although in the standard module questions should be mandatory, customized modules might allow to skip questions (for example because the respondent refuse to answer). + *in these cases, missing values should be left as such. + +FREQUENCIES + LcsEN_stress_DomAsset + LcsEN_stress_Utilities + LcsEN_stress_Saving + LcsEN_stress_BorrowCash + LcsEN_crisis_ProdAssets + LcsEN_crisis_Health + LcsEN_crisis_OutSchool + LcsEN_em_ResAsset + LcsEN_em_Begged + LcsEN_em_IllegalAct. * STRESS STRATEGIES - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of four stress strategies. You will need to replace with the four strategies selected for your specific case - -*Variable labels: +* reminder: this is just an example of four stress strategies. you will need to replace with the four strategies selected for your specific case VARIABLE LABELS - LcsEN_stress_DomAsset "Sold household assets/goods (radio, furniture, refrigerator, relevision, jewellery, etc.)" - LcsEN_stress_Utilities "Reduced or ceased payments on essential utilities and bills " - LcsEN_stress_Saving "Spent saving" - LcsEN_stress_BorrowCash "Borrowed cash" . - - -*% of household who adopted one or more stress coping strategies - -DO IF LcsEN_stress_DomAsset=20 | LcsEN_stress_DomAsset=30 | LcsEN_stress_Utilities=20 | LcsEN_stress_Utilities=30 | LcsEN_stress_Saving=20 | LcsEN_stress_Saving=30 | LcsEN_stress_BorrowCash=20 | LcsEN_stress_BorrowCash=30. -COMPUTE stress_coping_EN=1. -ELSE. -COMPUTE stress_coping_EN = 0. - END IF. - -VARIABLE LABELS stress_coping_EN "Did the HH engage in stress coping strategies?" . - - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* + LcsEN_stress_DomAsset "Sold household assets/goods (radio, furniture, refrigerator, television, jewellery, etc.)" + LcsEN_stress_Utilities "Reduced or ceased payments on essential utilities and bills" + LcsEN_stress_Saving "Spent savings" + LcsEN_stress_BorrowCash "Borrowed cash". + +DO IF + LcsEN_stress_DomAsset = 20 + | LcsEN_stress_DomAsset = 30 + | LcsEN_stress_Utilities = 20 + | LcsEN_stress_Utilities = 30 + | LcsEN_stress_Saving = 20 + | LcsEN_stress_Saving = 30 + | LcsEN_stress_BorrowCash = 20 + | LcsEN_stress_BorrowCash = 30. + COMPUTE stress_coping_EN = 1. +ELSE. + COMPUTE stress_coping_EN = 0. +END IF. +VARIABLE LABELS stress_coping_EN "Did the HH engage in stress coping strategies?". * CRISIS STRATEGIES - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of three crisis strategies. You will need to replace with the three strategies selected for your specific case - -*Variables lables: - -Variable labels -LcsEN_crisis_ProdAssets "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.) " -LcsEN_crisis_Health "Reduced expenses on health (including drugs)" -LcsEN_crisis_OutSchool "Withdrew children from school". - - -*% of household who adopted one or more crisis coping strategies - -DO IF LcsEN_crisis_ProdAssets = 20 | LcsEN_crisis_ProdAssets = 30 | LcsEN_crisis_Health = 20 | LcsEN_crisis_Health = 30 | LcsEN_crisis_OutSchool =20 | LcsEN_crisis_OutSchool =30. - -COMPUTE crisis_coping_EN =1. -ELSE. -COMPUTE crisis_coping_EN =0. -END IF. - -EXECUTE. - -VARIABLE LABELS crisis_coping_EN "Did the HH engage in crisis coping strategies?" . - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -* EMERGENCY STRATEGIES: - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of three emergency strategies. You will need to replace with the three strategies selected for your specific case - -*Variables lables: +* reminder: this is just an example of three crisis strategies. you will need to replace with the three strategies selected for your specific case VARIABLE LABELS - LcsEN_em_ResAsset "Mortaged/Sold house or land" - LcsEN_em_Begged "Begged and/or scavenged (asked strangers for money/food/other goods)" - LcsEN_em_IllegalAct "Had to engage in illegal income activities (theft, prostitution)" . - -*% of household who adopted one or more emergency coping strategies - -DO IF LcsEN_em_ResAsset = 20 | LcsEN_em_ResAsset = 30 | LcsEN_em_Begged = 20 | LcsEN_em_Begged = 30 | LcsEN_em_IllegalAct =20 | LcsEN_em_IllegalAct =30. - -COMPUTE emergency_coping_EN =1. -ELSE. -COMPUTE emergency_coping_EN =0. -END IF. - -VARIABLE LABELS emergency_coping_EN 'Did the HH engage in emergency coping strategies?'. - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -* COPING behaviour - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* + LcsEN_crisis_ProdAssets "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.)" + LcsEN_crisis_Health "Reduced expenses on health (including drugs)" + LcsEN_crisis_OutSchool "Withdrew children from school". + +DO IF + LcsEN_crisis_ProdAssets = 20 + | LcsEN_crisis_ProdAssets = 30 + | LcsEN_crisis_Health = 20 + | LcsEN_crisis_Health = 30 + | LcsEN_crisis_OutSchool = 20 + | LcsEN_crisis_OutSchool = 30. + COMPUTE crisis_coping_EN = 1. +ELSE. + COMPUTE crisis_coping_EN = 0. +END IF. +VARIABLE LABELS crisis_coping_EN "Did the HH engage in crisis coping strategies?". + +* EMERGENCY STRATEGIES +* reminder: this is just an example of three crisis strategies. you will need to replace with the three strategies selected for your specific case +VARIABLE LABELS + LcsEN_em_ResAsset "Mortgaged/Sold house or land" + LcsEN_em_Begged "Begged and/or scavenged (asked strangers for money/food/other goods)" + LcsEN_em_IllegalAct "Had to engage in illegal income activities (theft, prostitution)". + +DO IF + LcsEN_em_ResAsset = 20 + | LcsEN_em_ResAsset = 30 + | LcsEN_em_Begged = 20 + | LcsEN_em_Begged = 30 + | LcsEN_em_IllegalAct = 20 + | LcsEN_em_IllegalAct = 30. + COMPUTE emergency_coping_EN = 1. +ELSE. + COMPUTE emergency_coping_EN = 0. +END IF. +VARIABLE LABELS emergency_coping_EN "Did the HH engage in emergency coping strategies?". + +* COPING BEHAVIOR * this variable counts the strategies with valid (i.e. non missing) values - normally it should be equal to 10 for all respondents. -COMPUTE temp_nonmiss_number=NVALID(LcsEN_stress_DomAsset, LcsEN_stress_Utilities , LcsEN_stress_Saving , LcsEN_stress_BorrowCash , LcsEN_crisis_ProdAssets , + - LcsEN_crisis_Health , LcsEN_crisis_OutSchool , LcsEN_em_ResAsset , LcsEN_em_Begged , LcsEN_em_IllegalAct). -EXECUTE. -VARIABLE LABELS temp_nonmiss_number "Number of strategies with non missing values". - IF (temp_nonmiss_number>0) Max_coping_behaviourEN=1. -* the Max_coping_behaviourEN variable will be missing for an observation if answers to strategies are all missing. -IF (stress_coping_EN=1) Max_coping_behaviourEN=2. -IF (crisis_coping_EN=1) Max_coping_behaviourEN=3. -IF (emergency_coping_EN=1) Max_coping_behaviourEN=4. - EXECUTE. - -VALUE LABELS Max_coping_behaviourEN 1 'HH not adopting coping strategies' 2 'Stress coping strategies ' 3 'Crisis coping strategies ' 4 'Emergencies coping strategies'. +COMPUTE temp_nonmiss_number = NVALID( + LcsEN_stress_DomAsset, + LcsEN_stress_Utilities, + LcsEN_stress_Saving, + LcsEN_stress_BorrowCash, + LcsEN_crisis_ProdAssets, + LcsEN_crisis_Health, + LcsEN_crisis_OutSchool, + LcsEN_em_ResAsset, + LcsEN_em_Begged, + LcsEN_em_IllegalAct). +VARIABLE LABELS temp_nonmiss_number "Number of strategies with non-missing values". + +IF (temp_nonmiss_number > 0) Max_coping_behaviourEN = 1. +IF (stress_coping_EN = 1) Max_coping_behaviourEN = 2. +IF (crisis_coping_EN = 1) Max_coping_behaviourEN = 3. +IF (emergency_coping_EN = 1) Max_coping_behaviourEN = 4. VARIABLE LABELS Max_coping_behaviourEN "Summary of asset depletion". - +VALUE LABELS Max_coping_behaviourEN + 1 'HH not adopting coping strategies' + 2 'Stress coping strategies' + 3 'Crisis coping strategies' + 4 'Emergency coping strategies'. DELETE VARIABLES temp_nonmiss_number. EXECUTE. -* tabulate results. FREQUENCIES Max_coping_behaviourEN. +* ANALYZE REASONS FOR ADOPTING STRATEGIES +* the final question included in the lcs-en module asks the main reasons why coping strategies were adopted (lhcsienaccess). +* depending on the format you download the data sets and the import options you select the format of the variable could be different. + *in general, it is recommend downloading with the multiple response split into seperate columns (i.e. variables) with 1/0. + *the rest of the syntax assumes that the variable lhcsienaccess was exported in this way. -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -* ANALYSE THE REAONS WHY STRATEGIES ARE ADOPTED +* in spss it is assumed that varibales are named using a dot before the suffix indicating the answer opption (i.e. lhcsienaccess.1, lhcsienaccess.2...). +* this is way that variables are automatically named when a dataset is exported to spss (sav) format (i.e. lhcsienaccess.1, lhcsienaccess.2...) -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* The final question included in the LCS-EN module asks the main reasons why coping strategies were adopted (LhCSIEnAccess). -*Depending on the format you download the data sets and the import options you select the format of the variable could be different. - *In general, it is recommend downloading with the multiple response split into seperate columns (i.e. variables) with 1/0. - *The rest of the syntax assumes that the variable LhCSIEnAccess was exported in this way. - -* In SPSS it is assumed that varibales are named using a dot before the suffix indicating the answer opption (i.e. LhCSIEnAccess.1, LhCSIEnAccess.2...). -* This is way that variables are automatically named when a dataset is exported to SPSS (SAV) format (i.e. LhCSIEnAccess.1, LhCSIEnAccess.2...) - -* Rename variables to remove the dot. -RENAME VARIABLES (LhCSIEnAccess.1 LhCSIEnAccess.2 LhCSIEnAccess.3 LhCSIEnAccess.4 LhCSIEnAccess.5 LhCSIEnAccess.6 LhCSIEnAccess.7 LhCSIEnAccess.8 LhCSIEnAccess.999 = - LhCSIEnAccess1 LhCSIEnAccess2 LhCSIEnAccess3 LhCSIEnAccess4 LhCSIEnAccess5 LhCSIEnAccess6 LhCSIEnAccess7 LhCSIEnAccess8 LhCSIEnAccess999). -EXECUTE. +* rename variables to remove the dot +RENAME VARIABLES (LhCSIEnAccess.1 LhCSIEnAccess.2 LhCSIEnAccess.3 LhCSIEnAccess.4 LhCSIEnAccess.5 LhCSIEnAccess.6 LhCSIEnAccess.7 LhCSIEnAccess.8 LhCSIEnAccess.999 = + LhCSIEnAccess1 LhCSIEnAccess2 LhCSIEnAccess3 LhCSIEnAccess4 LhCSIEnAccess5 LhCSIEnAccess6 LhCSIEnAccess7 LhCSIEnAccess8 LhCSIEnAccess999). VARIABLE LABELS - LhCSIEnAccess1 "Adopted strategies to buy food" - LhCSIEnAccess2 "Adopted strategies to pay for rent" - LhCSIEnAccess3 "Adopted strategies to pay school, education costs" - LhCSIEnAccess4 "Adopted strategies to cover health expenses" - LhCSIEnAccess5 "Adopted strategies to buy essential non-food items (clothes, small furniture)" - LhCSIEnAccess6 "Adopted strategies to access water or sanitation facilities" - LhCSIEnAccess7 "Adopted strategies to access essential dwelling services (electricity, energy, waste disposal...)" - LhCSIEnAccess8 "Adopted strategies to pay for existing debts" - LhCSIEnAccess999 "Adopted strategies for other reasons" . - -*tabulate results . -DESCRIPTIVES VARIABLES=LhCSIEnAccess1 LhCSIEnAccess2 LhCSIEnAccess3 LhCSIEnAccess4 LhCSIEnAccess5 - LhCSIEnAccess6 LhCSIEnAccess7 LhCSIEnAccess8 LhCSIEnAccess999 - /STATISTICS=MEAN. - - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* + LhCSIEnAccess1 "Adopted strategies to buy food" + LhCSIEnAccess2 "Adopted strategies to pay for rent" + LhCSIEnAccess3 "Adopted strategies to pay school, education costs" + LhCSIEnAccess4 "Adopted strategies to cover health expenses" + LhCSIEnAccess5 "Adopted strategies to buy essential non-food items (clothes, small furniture)" + LhCSIEnAccess6 "Adopted strategies to access water or sanitation facilities" + LhCSIEnAccess7 "Adopted strategies to access essential dwelling services (electricity, energy, waste disposal...)" + LhCSIEnAccess8 "Adopted strategies to pay for existing debts" + LhCSIEnAccess999 "Adopted strategies for other reasons". + +* tabulate results +DESCRIPTIVES VARIABLES = LhCSIEnAccess1 LhCSIEnAccess2 LhCSIEnAccess3 LhCSIEnAccess4 LhCSIEnAccess5 LhCSIEnAccess6 LhCSIEnAccess7 LhCSIEnAccess8 LhCSIEnAccess999 + /STATISTICS = MEAN. * CALCULATING LCS-FS USING THE LCS-EN MODULE -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* To estimate food insecurity using CARI, the LCS-FS indicator should be used. -* In this case the LCS-EN inidicator can be converted to the LCS-FS using the final question included in the LCS-EN module asking the main reasons why coping strategies were adopted (LhCSIEnAccess). -* If "to buy food" is not among the reasons selected for applying livelihood coping strategies then these cases/households should be considered under "not coping" when computing CARI - - +* to estimate food insecurity using cari, the lcs-fs indicator should be used. +* in this case the lcs-en inidicator can be converted to the lcs-fs using the final question included in the lcs-en module asking the main reasons why coping strategies were adopted (lhcsienaccess). +* if "to buy food" is not among the reasons selected for applying livelihood coping strategies then these cases/households should be considered under "not coping" when computing cari IF (NOT SYSMIS(Max_coping_behaviourEN)) Max_coping_behaviourFS = Max_coping_behaviourEN. EXECUTE. +IF (LhCSIEnAccess1 = 0 & NOT SYSMIS(Max_coping_behaviourFS)) Max_coping_behaviourFS = 1. +VARIABLE LABELS Max_coping_behaviourFS "Summary of asset depletion (converted from EN to FS)". -IF (LhCSIEnAccess1=0 & NOT SYSMIS(Max_coping_behaviourFS)) Max_coping_behaviourFS=1. -EXECUTE. - -VARIABLE LABELS Max_coping_behaviourFS "Summary of asset depletion (converted from EN to FS)". - - +* End of Scripts \ No newline at end of file diff --git a/Indicators/Livelihood-Coping-Strategies-EN/LCS_EN_indicator_calculation.py b/Indicators/Livelihood-Coping-Strategies-EN/LCS_EN_indicator_calculation.py new file mode 100644 index 0000000..d9c24f1 --- /dev/null +++ b/Indicators/Livelihood-Coping-Strategies-EN/LCS_EN_indicator_calculation.py @@ -0,0 +1,141 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Livelihood Coping Strategy for Food Security (LCS-EN) +#------------------------------------------------------------------------------# + +# This script calculates the Livelihood Coping Strategy for Food Security (LCS-EN) +# indicator based on household responses to various coping strategies. The indicator +# considers stress, crisis, and emergency strategies and summarizes coping behavior. + +# Important note: this script is only an example. When calculating the indicator, +# you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that +# were selected for your specific case. + +# Please find more guidance on the indicator at the LCS-EN VAM Resource Center page: +# https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/livelihood-coping-strategies-essential-needs + +import pandas as pd + +# Load data +#data = pd.read_csv("~/GitHub/RAMResourcesScripts/Static/LCS_EN_Sample_Survey.csv") + +# Assign variable and value labels +var_labels = { + 'LcsEN_stress_DomAsset': "Sold household assets/goods (radio, furniture, refrigerator, television, jewellery, etc.)", + 'LcsEN_stress_Utilities': "Reduced or ceased payments on essential utilities and bills", + 'LcsEN_stress_Saving': "Spent savings", + 'LcsEN_stress_BorrowCash': "Borrowed cash", + 'LcsEN_crisis_ProdAssets': "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.)", + 'LcsEN_crisis_Health': "Reduced expenses on health (including drugs)", + 'LcsEN_crisis_OutSchool': "Withdrew children from school", + 'LcsEN_em_ResAsset': "Mortgaged/Sold house or land", + 'LcsEN_em_Begged': "Begged and/or scavenged (asked strangers for money/food/other goods)", + 'LcsEN_em_IllegalAct': "Had to engage in illegal income activities (theft, prostitution)" +} + +for var, label in var_labels.items(): + data[var] = data[var].astype('category') + data[var].cat.rename_categories({ + 10: "No, because we did not need to", + 20: "No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to do it", + 30: "Yes", + 9999: "Not applicable (don’t have access to this strategy)" + }, inplace=True) + data[var].cat.rename_categories(label, inplace=True) + +# Treatment of missing values +missing_values = data.isna().sum() +print(missing_values) + +# Custom handling for missing values can be added here if required + +# Stress strategies +data['stress_coping_EN'] = ((data['LcsEN_stress_DomAsset'].isin([20, 30])) | + (data['LcsEN_stress_Utilities'].isin([20, 30])) | + (data['LcsEN_stress_Saving'].isin([20, 30])) | + (data['LcsEN_stress_BorrowCash'].isin([20, 30]))).astype(int) + +data['stress_coping_EN'].cat.rename_categories("Did the HH engage in stress coping strategies?", inplace=True) + +# Crisis strategies +data['crisis_coping_EN'] = ((data['LcsEN_crisis_ProdAssets'].isin([20, 30])) | + (data['LcsEN_crisis_Health'].isin([20, 30])) | + (data['LcsEN_crisis_OutSchool'].isin([20, 30]))).astype(int) + +data['crisis_coping_EN'].cat.rename_categories("Did the HH engage in crisis coping strategies?", inplace=True) + +# Emergency strategies +data['emergency_coping_EN'] = ((data['LcsEN_em_ResAsset'].isin([20, 30])) | + (data['LcsEN_em_Begged'].isin([20, 30])) | + (data['LcsEN_em_IllegalAct'].isin([20, 30]))).astype(int) + +data['emergency_coping_EN'].cat.rename_categories("Did the HH engage in emergency coping strategies?", inplace=True) + +# Coping behavior +data['temp_nonmiss_number'] = data[['LcsEN_stress_DomAsset', 'LcsEN_stress_Utilities', 'LcsEN_stress_Saving', + 'LcsEN_stress_BorrowCash', 'LcsEN_crisis_ProdAssets', 'LcsEN_crisis_Health', + 'LcsEN_crisis_OutSchool', 'LcsEN_em_ResAsset', 'LcsEN_em_Begged', 'LcsEN_em_IllegalAct']].notna().sum(axis=1) + +data['max_coping_behaviourEN'] = 1 +data.loc[data['stress_coping_EN'] == 1, 'max_coping_behaviourEN'] = 2 +data.loc[data['crisis_coping_EN'] == 1, 'max_coping_behaviourEN'] = 3 +data.loc[data['emergency_coping_EN'] == 1, 'max_coping_behaviourEN'] = 4 + +data['max_coping_behaviourEN'] = data['max_coping_behaviourEN'].astype('category') +data['max_coping_behaviourEN'].cat.rename_categories({ + 1: "HH not adopting coping strategies", + 2: "Stress coping strategies", + 3: "Crisis coping strategies", + 4: "Emergency coping strategies" +}, inplace=True) + +# Remove temporary variables +data.drop(columns=['temp_nonmiss_number'], inplace=True) + +# Analyze reasons for adopting strategies +data.rename(columns={ + 'LhCSIEnAccess.1': 'LhCSIEnAccess1', + 'LhCSIEnAccess.2': 'LhCSIEnAccess2', + 'LhCSIEnAccess.3': 'LhCSIEnAccess3', + 'LhCSIEnAccess.4': 'LhCSIEnAccess4', + 'LhCSIEnAccess.5': 'LhCSIEnAccess5', + 'LhCSIEnAccess.6': 'LhCSIEnAccess6', + 'LhCSIEnAccess.7': 'LhCSIEnAccess7', + 'LhCSIEnAccess.8': 'LhCSIEnAccess8', + 'LhCSIEnAccess.999': 'LhCSIEnAccess999' +}, inplace=True) + +reason_labels = { + 'LhCSIEnAccess1': "Adopted strategies to buy food", + 'LhCSIEnAccess2': "Adopted strategies to pay for rent", + 'LhCSIEnAccess3': "Adopted strategies to pay school, education costs", + 'LhCSIEnAccess4': "Adopted strategies to cover health expenses", + 'LhCSIEnAccess5': "Adopted strategies to buy essential non-food items (clothes, small furniture)", + 'LhCSIEnAccess6': "Adopted strategies to access water or sanitation facilities", + 'LhCSIEnAccess7': "Adopted strategies to access essential dwelling services (electricity, energy, waste disposal...)", + 'LhCSIEnAccess8': "Adopted strategies to pay for existing debts", + 'LhCSIEnAccess999': "Adopted strategies for other reasons" +} + +for var, label in reason_labels.items(): + data[var] = data[var].astype('category') + data[var].cat.rename_categories(label, inplace=True) + +desc_stats = data[[ + 'LhCSIEnAccess1', 'LhCSIEnAccess2', 'LhCSIEnAccess3', 'LhCSIEnAccess4', + 'LhCSIEnAccess5', 'LhCSIEnAccess6', 'LhCSIEnAccess7', 'LhCSIEnAccess8', + 'LhCSIEnAccess999' +]].mean() + +print(desc_stats) + +# Calculating LCS-FS using the LCS-EN module +data['max_coping_behaviourFS'] = data['max_coping_behaviourEN'] +data.loc[data['LhCSIEnAccess1'] == 0, 'max_coping_behaviourFS'] = 1 + +data['max_coping_behaviourFS'] = data['max_coping_behaviourFS'].astype('category') +data['max_coping_behaviourFS'].cat.rename_categories({ + 1: "Summary of asset depletion (converted from EN to FS)" +}, inplace=True) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.R b/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.R index 93a80ed..de8d378 100644 --- a/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.R +++ b/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.R @@ -1,81 +1,104 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Livelihood Coping Strategy for Food Security (LCS-FS) +#------------------------------------------------------------------------------# + +# This script calculates the Livelihood Coping Strategy for Food Security (LCS-FS) +# indicator based on household responses to various coping strategies. The indicator +# considers stress, crisis, and emergency strategies and summarizes coping behavior. + +# Important note: this script is only an example. When calculating the indicator, +# you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that +# were selected for your specific case. + +# Please find more guidance on the indicator at the LCS-FS VAM Resource Center page: +# https://resources.vam.wfp.org/data-analysis/quantitative/food-security/livelihood-coping-strategies-food-security + library(tidyverse) library(labelled) library(expss) -#add sample data -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/LCS_Sample_Survey/LHCS_FS_Sample_Survey.csv") - -#assign variable and value labels -#variable labels -var_label(data$Lcs_stress_DomAsset) <- "Sold household assets/goods (radio, furniture, refrigerator, television, jewellery etc.) due to lack of food" -var_label(data$Lcs_stress_Saving) <- "Spent savings due to lack of food" -var_label(data$Lcs_stress_EatOut) <- "Sent household members to eat elsewhere/live with family or friends due to lack of food" -var_label(data$Lcs_stress_CrdtFood) <- "Purchased food/non-food on credit (incur debts) due to lack of food" -var_label(data$Lcs_crisis_ProdAssets) <- "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.) due to lack of food" -var_label(data$Lcs_crisis_Health) <- "Reduced expenses on health (including drugs)" -var_label(data$Lcs_crisis_OutSchool) <- "Withdrew children from school due to lack of food" -var_label(data$Lcs_em_ResAsset) <- "Mortgaged/Sold house or land due to lack of food" -var_label(data$Lcs_em_Begged) <- "Begged and/or scavenged (asked strangers for money/food) due to lack of food" -var_label(data$Lcs_em_IllegalAct) <- "Engaged in illegal income activities (theft, prostitution) due to lack of food" -#value labels +# Load data +#data <- read_csv("~/GitHub/RAMResourcesScripts/Static/LCS_FS_Sample_Survey.csv") + +# Assign variable labels +var_label(data$Lcs_stress_DomAsset) <- "Sold household assets/goods (radio, furniture, refrigerator, television, jewellery, etc.)" +var_label(data$Lcs_stress_Utilities) <- "Reduced or ceased payments on essential utilities and bills" +var_label(data$Lcs_stress_Saving) <- "Spent savings" +var_label(data$Lcs_stress_BorrowCash) <- "Borrowed cash" +var_label(data$Lcs_crisis_ProdAssets) <- "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.)" +var_label(data$Lcs_crisis_Health) <- "Reduced expenses on health (including drugs)" +var_label(data$Lcs_crisis_OutSchool) <- "Withdrew children from school" +var_label(data$Lcs_em_ResAsset) <- "Mortgaged/Sold house or land" +var_label(data$Lcs_em_Begged) <- "Begged and/or scavenged (asked strangers for money/food/other goods)" +var_label(data$Lcs_em_IllegalAct) <- "Had to engage in illegal income activities (theft, prostitution)" + +# Assign value labels data <- data %>% - mutate(across(c(Lcs_stress_DomAsset,Lcs_stress_Saving,Lcs_stress_EatOut,Lcs_stress_CrdtFood,Lcs_crisis_ProdAssets,Lcs_crisis_Health,Lcs_crisis_OutSchool,Lcs_em_ResAsset,Lcs_em_Begged,Lcs_em_IllegalAct), ~labelled(., labels = c( - "No, because I did not need to" = 10, - "No, because I already sold those assets or have engaged in this activity within the last 12 months and cannot continue to do it" = 20, - "Yes" = 30, - "Not applicable (don’t have access to this strategy)" = 9999 - )))) - -#create a variable to specify if the household used any of the strategies by severity -#stress + mutate(across(c(Lcs_stress_DomAsset, Lcs_stress_Utilities, Lcs_stress_Saving, + Lcs_stress_BorrowCash, Lcs_crisis_ProdAssets, Lcs_crisis_Health, + Lcs_crisis_OutSchool, Lcs_em_ResAsset, Lcs_em_Begged, Lcs_em_IllegalAct), + ~ labelled(., labels = c( + "No, because we did not need to" = 10, + "No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to do it" = 20, + "Yes" = 30, + "Not applicable (don’t have access to this strategy)" = 9999 + )))) + +# Check for missing values +missing_values <- sapply(data, function(x) sum(is.na(x))) +print(missing_values) + +# Stress strategies data <- data %>% mutate(stress_coping_FS = case_when( - Lcs_stress_DomAsset == 20 | Lcs_stress_DomAsset == 30 ~ 1, - Lcs_stress_Saving == 20 | Lcs_stress_Saving == 30 ~ 1, - Lcs_stress_EatOut == 20 | Lcs_stress_EatOut == 30 ~ 1, - Lcs_stress_CrdtFood == 20 | Lcs_stress_CrdtFood == 30 ~1, + Lcs_stress_DomAsset %in% c(20, 30) | + Lcs_stress_Utilities %in% c(20, 30) | + Lcs_stress_Saving %in% c(20, 30) | + Lcs_stress_BorrowCash %in% c(20, 30) ~ 1, TRUE ~ 0)) -var_label(data$stress_coping_FS) <- "Did the HH engage in stress coping strategies" -#Crisis +var_label(data$stress_coping_FS) <- "Did the HH engage in stress coping strategies?" + +# Crisis strategies data <- data %>% mutate(crisis_coping_FS = case_when( - Lcs_crisis_ProdAssets == 20 | Lcs_crisis_ProdAssets == 30 ~ 1, - Lcs_crisis_Health == 20 | Lcs_crisis_Health == 30 ~ 1, - Lcs_crisis_OutSchool == 20 | Lcs_crisis_OutSchool == 30 ~ 1, + Lcs_crisis_ProdAssets %in% c(20, 30) | + Lcs_crisis_Health %in% c(20, 30) | + Lcs_crisis_OutSchool %in% c(20, 30) ~ 1, TRUE ~ 0)) -var_label(data$crisis_coping_FS) <- "Did the HH engage in crisis coping strategies" -#Emergency +var_label(data$crisis_coping_FS) <- "Did the HH engage in crisis coping strategies?" + +# Emergency strategies data <- data %>% mutate(emergency_coping_FS = case_when( - Lcs_em_ResAsset == 20 | Lcs_em_ResAsset == 30 ~ 1, - Lcs_em_Begged == 20 | Lcs_em_Begged == 30 ~ 1, - Lcs_em_IllegalAct == 20 | Lcs_em_IllegalAct == 30 ~ 1, + Lcs_em_ResAsset %in% c(20, 30) | + Lcs_em_Begged %in% c(20, 30) | + Lcs_em_IllegalAct %in% c(20, 30) ~ 1, TRUE ~ 0)) -var_label(data$emergency_coping_FS) <- "Did the HH engage in emergency coping strategies" +var_label(data$emergency_coping_FS) <- "Did the HH engage in emergency coping strategies?" + +# Coping behavior +data <- data %>% mutate(temp_nonmiss_number = rowSums(!is.na(select(., + Lcs_stress_DomAsset, Lcs_stress_Utilities, Lcs_stress_Saving, Lcs_stress_BorrowCash, + Lcs_crisis_ProdAssets, Lcs_crisis_Health, Lcs_crisis_OutSchool, Lcs_em_ResAsset, + Lcs_em_Begged, Lcs_em_IllegalAct)))) -#calculate Max_coping_behaviour data <- data %>% mutate(Max_coping_behaviourFS = case_when( - emergency_coping_FS == 1 ~ 4, - crisis_coping_FS == 1 ~ 3, - stress_coping_FS == 1 ~ 2, - TRUE ~ 1)) + temp_nonmiss_number > 0 ~ 1, + stress_coping_FS == 1 ~ 2, + crisis_coping_FS == 1 ~ 3, + emergency_coping_FS == 1~ 4, + TRUE ~ NA_real_)) var_label(data$Max_coping_behaviourFS) <- "Summary of asset depletion" -val_lab(data$Max_coping_behaviourFS) = num_lab(" - 1 HH not adopting coping strategies - 2 Stress coping strategies - 3 Crisis coping strategies - 4 Emergencies coping strategies +val_lab(data$Max_coping_behaviourFS) <- num_lab(" + 1 'HH not adopting coping strategies' + 2 'Stress coping strategies' + 3 'Crisis coping strategies' + 4 'Emergency coping strategies' ") +# Remove temporary variable +data <- data %>% select(-temp_nonmiss_number) -#creates a table of the weighted percentage of Max_coping_behaviourFS by -#creating a temporary variable to display value labels -#and providing the option to use weights if needed - +# Tabulate results +Max_coping_behaviourFS_table <- data %>% count(Max_coping_behaviourFS, sort = TRUE) +print(Max_coping_behaviourFS_table) -Max_coping_behaviourFS_table_wide <- data %>% - drop_na(Max_coping_behaviourFS) %>% - count(Max_coping_behaviourFS_lab = as.character(Max_coping_behaviourFS)) %>% # if weights are needed use instead the row below - #count(Max_coping_behaviourFS_lab = as.character(Max_coping_behaviourFS), wt = nameofweightvariable) - mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = Max_coping_behaviourFS_lab, - values_from = Percentage, - values_fill = 0) +# End of Scripts \ No newline at end of file diff --git a/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.do b/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.do index af8251c..562b6af 100644 --- a/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.do +++ b/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.do @@ -1,157 +1,146 @@ -******************************************************************************** - * STATA Syntax for the Livelihood Coping Strategy for Food Security (LCS-FS) indicator - ******************************************************************************* - -* Important note: this syntax file is only an example. When calculating the indicator, you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that were selected for your specific case. +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Calculating Livelihood Coping Strategy for Food Security (LCS-FS) +*------------------------------------------------------------------------------* -* Please find more guidance on the indicator at the LCS-FS VAM Resource Center page: https://resources.vam.wfp.org/data-analysis/quantitative/food-security/livelihood-coping-strategies-food-security +* This script calculates the Livelihood Coping Strategy for Food Security (LCS-FS) +* indicator based on household responses to various coping strategies. The indicator +* considers stress, crisis, and emergency strategies and summarizes coping behavior. -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +* Important note: this syntax file is only an example. When calculating the indicator, +* you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that +* were selected for your specific case. +* Please find more guidance on the indicator at the LCS-FS VAM Resource Center page: +* https://resources.vam.wfp.org/data-analysis/quantitative/food-security/livelihood-coping-strategies-food-security + +*------------------------------------------------------------------------------* * VALUE LABELS -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* + +label define LcsFS_label /// + 10 "No, because we did not need to" /// + 20 "No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to" /// + 30 "Yes" /// + 9999 "Not applicable (don't have children/these assets)" -lab def Lcs_label /// - 10 "No, because we did not need to" /// - 20 "No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to" /// - 30 "Yes" /// - 9999 "Not applicable (don't have children/these assets)" - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +label values Lcs_stress_DomAsset Lcs_stress_Utilities Lcs_stress_Saving /// + Lcs_stress_BorrowCash Lcs_crisis_ProdAssets Lcs_crisis_Health /// + Lcs_crisis_OutSchool Lcs_em_ResAsset Lcs_em_Begged /// + Lcs_em_IllegalAct LcsFS_label +*------------------------------------------------------------------------------* * TREATMENT OF MISSING VALUES -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* The LCS-FS standard module does not allow for skipping questions, so there should not be missing values. Check that indeed this is the case. +*------------------------------------------------------------------------------* + +* The LCS-FS standard module does not allow for skipping questions, so there should +* not be missing values. Check that indeed this is the case. + foreach var of varlist Lcs_stress_DomAsset Lcs_stress_Utilities Lcs_stress_Saving Lcs_stress_BorrowCash Lcs_crisis_ProdAssets Lcs_crisis_Health Lcs_crisis_OutSchool Lcs_em_ResAsset Lcs_em_Begged Lcs_em_IllegalAct { -tab `var' , missing + tab `var', missing } -* If there are no missings, you can just go ahead. If there are missing values, then you will need to understand why and, based on that, treat these missing values. +* If there are no missings, you can just go ahead. If there are missing values, then +* you will need to understand why and, based on that, treat these missing values. - * POTENTIAL REASON 1: Although not recommended, customized modules might include skip patterns to avoid asking about strategies that are not relevant for the household. For example, a skip pattern might be introduced so that a question on withdrawing children from school is not asked to households with no children. In these cases, it is important to recode missing values to 9999 "Not applicable (don't have children/these assets)". - - * POTENTIAL REASON 2: Although in the standard module questions should be mandatory, customized modules might allow to skip questions (for example because the respondent refuse to answer). In these cases, missing values should be left as such. +* POTENTIAL REASON 1: Although not recommended, customized modules might include skip +* patterns to avoid asking about strategies that are not relevant for the household. +* For example, a skip pattern might be introduced so that a question on withdrawing +* children from school is not asked to households with no children. In these cases, +* it is important to recode missing values to 9999 "Not applicable (don't have children/these assets)". -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +* POTENTIAL REASON 2: Although in the standard module questions should be mandatory, +* customized modules might allow to skip questions (for example because the respondent +* refuses to answer). In these cases, missing values should be left as such. +*------------------------------------------------------------------------------* * STRESS STRATEGIES +*------------------------------------------------------------------------------* -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of four stress strategies. You will need to replace with the four strategies selected for your specific case - -*Variable labels: - -lab var Lcs_stress_DomAsset "Sold household assets/goods (radio, furniture, refrigerator, relevision, jewellery, etc.)" - -lab var Lcs_stress_Utilities "Reduced or ceased payments on essential utilities and bills " - -lab var Lcs_stress_Saving "Spent saving" - -lab var Lcs_stress_BorrowCash "Borrowed cash" - +* Reminder: this is just an example of four stress strategies. You will need to +* replace with the four strategies selected for your specific case -foreach var of varlist Lcs_stress_DomAsset Lcs_stress_Utilities Lcs_stress_Saving Lcs_stress_BorrowCash { +* Variable labels +label variable Lcs_stress_DomAsset "Sold household assets/goods (radio, furniture, refrigerator, television, jewellery, etc.)" +label variable Lcs_stress_Utilities "Reduced or ceased payments on essential utilities and bills" +label variable Lcs_stress_Saving "Spent savings" +label variable Lcs_stress_BorrowCash "Borrowed cash" -lab val `var' Lcs_label -} +* % of households who adopted one or more stress coping strategies +gen stress_coping_FS = (Lcs_stress_DomAsset == 20 | Lcs_stress_DomAsset == 30) | /// + (Lcs_stress_Utilities == 20 | Lcs_stress_Utilities == 30) | /// + (Lcs_stress_Saving == 20 | Lcs_stress_Saving == 30) | /// + (Lcs_stress_BorrowCash == 20 | Lcs_stress_BorrowCash == 30) - -*% of household who adopted one or more stress coping strategies - -gen stress_coping_FS=(Lcs_stress_DomAsset==20 | Lcs_stress_DomAsset==30) | (Lcs_stress_Utilities==20 | Lcs_stress_Utilities==30) | (Lcs_stress_Saving==20 | Lcs_stress_Saving==30) | (Lcs_stress_BorrowCash==20 | Lcs_stress_BorrowCash==30) - - -lab var stress_coping_FS "Did the HH engage in stress coping strategies?" - - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +label variable stress_coping_FS "Did the HH engage in stress coping strategies?" +*------------------------------------------------------------------------------* * CRISIS STRATEGIES +*------------------------------------------------------------------------------* -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of three crisis strategies. You will need to replace with the three strategies selected for your specific case - -*Variables lables: - -lab var Lcs_crisis_ProdAssets "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.)" - -lab var Lcs_crisis_Health "Reduced expenses on health (including medicines)" - -lab var Lcs_crisis_OutSchool "Withdrew children from school" - - -foreach var of varlist Lcs_crisis_ProdAssets Lcs_crisis_Health Lcs_crisis_OutSchool { - -lab val `var' Lcs_label - -} - - -*% of household who adopted one or more crisis coping strategies - -gen crisis_coping_FS=(Lcs_crisis_ProdAssets==20 | Lcs_crisis_ProdAssets==30) | (Lcs_crisis_Health==20 | Lcs_crisis_Health==30) | (Lcs_crisis_OutSchool==20 | Lcs_crisis_OutSchool==30) - - -lab var crisis_coping_FS "Did HH engage in crisis coping strategies?" - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -* EMERGENCY STRATEGIES: - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of three emergency strategies. You will need to replace with the three strategies selected for your specific case - -*Variables lables: - -lab var Lcs_em_ResAsset "Mortaged/Sold house or land" - -lab var Lcs_em_Begged "Begged and/or scavenged (asked strangers for money/food/other goods)" - -lab var Lcs_em_IllegalAct "Had to engage in illegal income activities (theft, prostitution)" - - -foreach var of varlist Lcs_em_ResAsset Lcs_em_Begged Lcs_em_IllegalAct { - -lab val `var' Lcs_label - -} - +* Reminder: this is just an example of three crisis strategies. You will need to +* replace with the three strategies selected for your specific case -*% of household who adopted one or more emergency coping strategies +* Variable labels +label variable Lcs_crisis_ProdAssets "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.)" +label variable Lcs_crisis_Health "Reduced expenses on health (including drugs)" +label variable Lcs_crisis_OutSchool "Withdrew children from school" -gen emergency_coping_FS=(Lcs_em_ResAsset==20 | Lcs_em_ResAsset==30) | (Lcs_em_Begged==20 | Lcs_em_Begged==30) | (Lcs_em_IllegalAct==20 | Lcs_em_IllegalAct==30) +* % of households who adopted one or more crisis coping strategies +gen crisis_coping_FS = (Lcs_crisis_ProdAssets == 20 | Lcs_crisis_ProdAssets == 30) | /// + (Lcs_crisis_Health == 20 | Lcs_crisis_Health == 30) | /// + (Lcs_crisis_OutSchool == 20 | Lcs_crisis_OutSchool == 30) - lab var emergency_coping_FS "Did the HH engage in emergency coping strategies?" +label variable crisis_coping_FS "Did the HH engage in crisis coping strategies?" -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* +* EMERGENCY STRATEGIES +*------------------------------------------------------------------------------* -* COPING BEHAVIOR +* Reminder: this is just an example of three emergency strategies. You will need to +* replace with the three strategies selected for your specific case -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +* Variable labels +label variable Lcs_em_ResAsset "Mortgaged/Sold house or land" +label variable Lcs_em_Begged "Begged and/or scavenged (asked strangers for money/food/other goods)" +label variable Lcs_em_IllegalAct "Had to engage in illegal income activities (theft, prostitution)" -egen temp_nonmiss_number = rownonmiss(Lcs_stress_DomAsset Lcs_stress_Utilities Lcs_stress_Saving Lcs_stress_BorrowCash Lcs_crisis_ProdAssets Lcs_crisis_Health Lcs_crisis_OutSchool Lcs_em_ResAsset Lcs_em_Begged Lcs_em_IllegalAct) //this variable counts the strategies with valid (i.e. non missing) values - normally it should be equal to 10 for all respondents -label var temp_nonmiss_number "Number of strategies with non missing values" - -gen Max_coping_behaviourFS=1 if temp_nonmiss_number>0 // the Max_coping_behaviourFS variable will be missing for an observation if answers to strategies are all missing +* % of households who adopted one or more emergency coping strategies +gen emergency_coping_FS = (Lcs_em_ResAsset == 20 | Lcs_em_ResAsset == 30) | /// + (Lcs_em_Begged == 20 | Lcs_em_Begged == 30) | /// + (Lcs_em_IllegalAct == 20 | Lcs_em_IllegalAct == 30) -replace Max_coping_behaviourFS=2 if stress_coping_FS==1 +label variable emergency_coping_FS "Did the HH engage in emergency coping strategies?" -replace Max_coping_behaviourFS=3 if crisis_coping_FS==1 +*------------------------------------------------------------------------------* +* COPING BEHAVIOR +*------------------------------------------------------------------------------* -replace Max_coping_behaviourFS=4 if emergency_coping_FS==1 +egen temp_nonmiss_number = rownonmiss(Lcs_stress_DomAsset Lcs_stress_Utilities /// + Lcs_stress_Saving Lcs_stress_BorrowCash /// + Lcs_crisis_ProdAssets Lcs_crisis_Health /// + Lcs_crisis_OutSchool Lcs_em_ResAsset /// + Lcs_em_Begged Lcs_em_IllegalAct) - -lab var Max_coping_behaviourFS "Summary of asset depletion" +* This variable counts the strategies with valid (i.e. non missing) values - normally +* it should be equal to 10 for all respondents +label variable temp_nonmiss_number "Number of strategies with non missing values" -lab def Max_coping_behaviourFS_label 1"HH not adopting coping strategies" 2"Stress coping strategies" 3"Crisis coping strategies" 4"Emergency coping strategies" +gen Max_coping_behaviourFS = . if temp_nonmiss_number > 0 +replace Max_coping_behaviourFS = 2 if stress_coping_FS == 1 +replace Max_coping_behaviourFS = 3 if crisis_coping_FS == 1 +replace Max_coping_behaviourFS = 4 if emergency_coping_FS == 1 -lab val Max_coping_behaviourFS Max_coping_behaviourFS_label +label variable Max_coping_behaviourFS "Summary of asset depletion" +label define Max_coping_behaviourFS_label 1 "HH not adopting coping strategies" /// + 2 "Stress coping strategies" /// + 3 "Crisis coping strategies" /// + 4 "Emergency coping strategies" +label values Max_coping_behaviourFS Max_coping_behaviourFS_label drop temp_nonmiss_number -* tabulate results +* Tabulate results tab Max_coping_behaviourFS, missing +* End of Scripts \ No newline at end of file diff --git a/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.py b/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.py new file mode 100644 index 0000000..733ec15 --- /dev/null +++ b/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.py @@ -0,0 +1,95 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Livelihood Coping Strategy for Food Security (LCS-FS) +#------------------------------------------------------------------------------# + +# This script calculates the Livelihood Coping Strategy for Food Security (LCS-FS) +# indicator based on household responses to various coping strategies. The indicator +# considers stress, crisis, and emergency strategies and summarizes coping behavior. + +# Important note: this script is only an example. When calculating the indicator, +# you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that +# were selected for your specific case. + +# Please find more guidance on the indicator at the LCS-FS VAM Resource Center page: +# https://resources.vam.wfp.org/data-analysis/quantitative/food-security/livelihood-coping-strategies-food-security + +import pandas as pd + +# Load data +data = pd.read_csv("~/GitHub/RAMResourcesScripts/Static/LCS_FS_Sample_Survey.csv") + +# Assign variable labels +variable_labels = { + 'Lcs_stress_DomAsset': "Sold household assets/goods (radio, furniture, refrigerator, television, jewellery, etc.)", + 'Lcs_stress_Utilities': "Reduced or ceased payments on essential utilities and bills", + 'Lcs_stress_Saving': "Spent savings", + 'Lcs_stress_BorrowCash': "Borrowed cash", + 'Lcs_crisis_ProdAssets': "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.)", + 'Lcs_crisis_Health': "Reduced expenses on health (including drugs)", + 'Lcs_crisis_OutSchool': "Withdrew children from school", + 'Lcs_em_ResAsset': "Mortgaged/Sold house or land", + 'Lcs_em_Begged': "Begged and/or scavenged (asked strangers for money/food/other goods)", + 'Lcs_em_IllegalAct': "Had to engage in illegal income activities (theft, prostitution)" +} + +# Assign value labels +value_labels = { + 10: "No, because we did not need to", + 20: "No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to do it", + 30: "Yes", + 9999: "Not applicable (don’t have access to this strategy)" +} + +# Function to label values +def label_values(series, labels): + return series.map(labels) + +for col in variable_labels.keys(): + data[col] = label_values(data[col], value_labels) + +# Check for missing values +missing_values = data.isnull().sum() +print(missing_values) + +# Stress strategies +data['stress_coping_FS'] = data.apply( + lambda row: 1 if any(row[col] in [20, 30] for col in ['Lcs_stress_DomAsset', 'Lcs_stress_Utilities', 'Lcs_stress_Saving', 'Lcs_stress_BorrowCash']) else 0, + axis=1 +) + +# Crisis strategies +data['crisis_coping_FS'] = data.apply( + lambda row: 1 if any(row[col] in [20, 30] for col in ['Lcs_crisis_ProdAssets', 'Lcs_crisis_Health', 'Lcs_crisis_OutSchool']) else 0, + axis=1 +) + +# Emergency strategies +data['emergency_coping_FS'] = data.apply( + lambda row: 1 if any(row[col] in [20, 30] for col in ['Lcs_em_ResAsset', 'Lcs_em_Begged', 'Lcs_em_IllegalAct']) else 0, + axis=1 +) + +# Coping behavior +data['temp_nonmiss_number'] = data.apply( + lambda row: row[['Lcs_stress_DomAsset', 'Lcs_stress_Utilities', 'Lcs_stress_Saving', 'Lcs_stress_BorrowCash', + 'Lcs_crisis_ProdAssets', 'Lcs_crisis_Health', 'Lcs_crisis_OutSchool', + 'Lcs_em_ResAsset', 'Lcs_em_Begged', 'Lcs_em_IllegalAct']].notnull().sum(), axis=1 +) + +data['Max_coping_behaviourFS'] = data.apply( + lambda row: 4 if row['emergency_coping_FS'] == 1 else ( + 3 if row['crisis_coping_FS'] == 1 else ( + 2 if row['stress_coping_FS'] == 1 else ( + 1 if row['temp_nonmiss_number'] > 0 else None))), + axis=1 +) + +# Remove temporary variable +data.drop(columns=['temp_nonmiss_number'], inplace=True) + +# Tabulate results +max_coping_behaviourFS_table = data['Max_coping_behaviourFS'].value_counts().sort_index() +print(max_coping_behaviourFS_table) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.sps b/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.sps index ab233ca..118f372 100644 --- a/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.sps +++ b/Indicators/Livelihood-Coping-Strategies-FS/LCS-FS-indicator.sps @@ -1,16 +1,20 @@ -* Encoding: UTF-8. -******************************************************************************** - * SPSS Syntax for the Livelihood Coping Strategy for Food Security (LCS-FS) indicator - ******************************************************************************* - -* Important note: this syntax file is only an example. When calculating the indicator, you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that were selected for your specific case. +*------------------------------------------------------------------------------* +* WFP Standardized Scripts +* Calculating Livelihood Coping Strategy for Food Security (LCS-FS) +*------------------------------------------------------------------------------* -* Please find more guidance on the indicator at the LCS-FS VAM Resource Center page: https://resources.vam.wfp.org/data-analysis/quantitative/food-security/livelihood-coping-strategies-food-security +* This script calculates the Livelihood Coping Strategy for Food Security (LCS-FS) +* indicator based on household responses to various coping strategies. The indicator +* considers stress, crisis, and emergency strategies and summarizes coping behavior. -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* VALUE LABELS -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +* Important note: this syntax file is only an example. When calculating the indicator, +* you will need to include the 10 strategies (4 stress, 3 crisis, 3 emergency) that +* were selected for your specific case. + +* Please find more guidance on the indicator at the LCS-FS VAM Resource Center page: +* https://resources.vam.wfp.org/data-analysis/quantitative/food-security/livelihood-coping-strategies-food-security +* VALUE LABELS VALUE LABELS Lcs_stress_DomAsset Lcs_stress_Utilities @@ -25,145 +29,155 @@ VALUE LABELS 10 'No, because we did not need to' 20 'No, because we already sold those assets or have engaged in this activity within the last 12 months and cannot continue to' 30 'Yes' - 9999 'Not applicable (do not have children/these assets)'. - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* + 9999 'Not applicable (do not have children/these assets)'. * TREATMENT OF MISSING VALUES -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* * The LCS-FS standard module does not allow for skipping questions, so there should not be missing values. Check that indeed this is the case. -FREQUENCIES Lcs_stress_DomAsset Lcs_stress_Utilities Lcs_stress_Saving Lcs_stress_BorrowCash Lcs_crisis_ProdAssets Lcs_crisis_Health Lcs_crisis_OutSchool Lcs_em_ResAsset Lcs_em_Begged Lcs_em_IllegalAct. - +FREQUENCIES + Lcs_stress_DomAsset + Lcs_stress_Utilities + Lcs_stress_Saving + Lcs_stress_BorrowCash + Lcs_crisis_ProdAssets + Lcs_crisis_Health + Lcs_crisis_OutSchool + Lcs_em_ResAsset + Lcs_em_Begged + Lcs_em_IllegalAct. + * If there are no missings, you can just go ahead. If there are missing values, then you will need to understand why and, based on that, treat these missing values. - * POTENTIAL REASON 1: Although not recommended, customized modules might include skip patterns to avoid asking about strategies that are not relevant for the household. - *For example, a skip pattern might be introduced so that a question on withdrawing children from school is not asked to households with no children. - *In these cases, it is important to recode missing values to 9999 'Not applicable (don't have children/these assets)'. - - * POTENTIAL REASON 2: Although in the standard module questions should be mandatory, customized modules might allow to skip questions (for example because the respondent refuse to answer). - *In these cases, missing values should be left as such. + * POTENTIAL REASON 1: Although not recommended, customized modules might include skip patterns to avoid asking about strategies that are not relevant for the household. + * For example, a skip pattern might be introduced so that a question on withdrawing children from school is not asked to households with no children. + * In these cases, it is important to recode missing values to 9999 'Not applicable (don't have children/these assets)'. -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* + * POTENTIAL REASON 2: Although in the standard module questions should be mandatory, customized modules might allow to skip questions (for example because the respondent refuse to answer). + * In these cases, missing values should be left as such. * STRESS STRATEGIES +* Reminder: this is just an example of four stress strategies. You will need to replace with the four strategies selected for your specific case -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of four stress strategies. You will need to replace with the four strategies selected for your specific case - -*Variable labels: - +* Variable labels: VARIABLE LABELS - Lcs_stress_DomAsset "Sold household assets/goods (radio, furniture, refrigerator, relevision, jewellery, etc.)" - Lcs_stress_Utilities "Reduced or ceased payments on essential utilities and bills " - Lcs_stress_Saving "Spent saving" - Lcs_stress_BorrowCash "Borrowed cash" . - - -*% of household who adopted one or more stress coping strategies - -DO IF Lcs_stress_DomAsset=20 | Lcs_stress_DomAsset=30 | Lcs_stress_Utilities=20 | Lcs_stress_Utilities=30 | Lcs_stress_Saving=20 | Lcs_stress_Saving=30 | Lcs_stress_BorrowCash=20 | Lcs_stress_BorrowCash=30. -COMPUTE stress_coping_FS=1. -ELSE. -COMPUTE stress_coping_FS = 0. - END IF. - -VARIABLE LABELS stress_coping_FS "Did the HH engage in stress coping strategies?" . - - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* + Lcs_stress_DomAsset "Sold household assets/goods (radio, furniture, refrigerator, television, jewellery, etc.)" + Lcs_stress_Utilities "Reduced or ceased payments on essential utilities and bills" + Lcs_stress_Saving "Spent savings" + Lcs_stress_BorrowCash "Borrowed cash". + +* % of households who adopted one or more stress coping strategies +DO IF + Lcs_stress_DomAsset = 20 | + Lcs_stress_DomAsset = 30 | + Lcs_stress_Utilities = 20 | + Lcs_stress_Utilities = 30 | + Lcs_stress_Saving = 20 | + Lcs_stress_Saving = 30 | + Lcs_stress_BorrowCash = 20 | + Lcs_stress_BorrowCash = 30. + COMPUTE stress_coping_FS = 1. +ELSE. + COMPUTE stress_coping_FS = 0. +END IF. +VARIABLE LABELS + stress_coping_FS "Did the HH engage in stress coping strategies?". * CRISIS STRATEGIES +* Reminder: this is just an example of three crisis strategies. You will need to replace with the three strategies selected for your specific case -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of three crisis strategies. You will need to replace with the three strategies selected for your specific case - -*Variables lables: - -Variable labels -Lcs_crisis_ProdAssets "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.) " -Lcs_crisis_Health "Reduced expenses on health (including drugs)" -Lcs_crisis_OutSchool "Withdrew children from school". - - -*% of household who adopted one or more crisis coping strategies - -DO IF Lcs_crisis_ProdAssets = 20 | Lcs_crisis_ProdAssets = 30 | Lcs_crisis_Health = 20 | Lcs_crisis_Health = 30 | Lcs_crisis_OutSchool =20 | Lcs_crisis_OutSchool =30. - -COMPUTE crisis_coping_FS =1. -ELSE. -COMPUTE crisis_coping_FS =0. -END IF. - -EXECUTE. - -VARIABLE LABELS crisis_coping_FS "Did the HH engage in crisis coping strategies?" . - - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -* EMERGENCY STRATEGIES: - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* reminder: this is just an example of three emergency strategies. You will need to replace with the three strategies selected for your specific case - -*Variables lables: - +* Variable labels: VARIABLE LABELS - Lcs_em_ResAsset "Mortaged/Sold house or land" - Lcs_em_Begged "Begged and/or scavenged (asked strangers for money/food/other goods)" - Lcs_em_IllegalAct "Had to engage in illegal income activities (theft, prostitution)" . - -*% of household who adopted one or more emergency coping strategies - -DO IF Lcs_em_ResAsset = 20 | Lcs_em_ResAsset = 30 | Lcs_em_Begged = 20 | Lcs_em_Begged = 30 | Lcs_em_IllegalAct =20 | Lcs_em_IllegalAct =30. - -COMPUTE emergency_coping_FS =1. -ELSE. -COMPUTE emergency_coping_FS =0. -END IF. - -VARIABLE LABELS emergency_coping_FS 'Did the HH engage in emergency coping strategies?'. - -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -* COPING behaviour + Lcs_crisis_ProdAssets "Sold productive assets or means of transport (sewing machine, wheelbarrow, bicycle, car, etc.)" + Lcs_crisis_Health "Reduced expenses on health (including drugs)" + Lcs_crisis_OutSchool "Withdrew children from school". + +* % of households who adopted one or more crisis coping strategies +DO IF + Lcs_crisis_ProdAssets = 20 | + Lcs_crisis_ProdAssets = 30 | + Lcs_crisis_Health = 20 | + Lcs_crisis_Health = 30 | + Lcs_crisis_OutSchool = 20 | + Lcs_crisis_OutSchool = 30. + COMPUTE crisis_coping_FS = 1. +ELSE. + COMPUTE crisis_coping_FS = 0. +END IF. +EXECUTE. +VARIABLE LABELS + crisis_coping_FS "Did the HH engage in crisis coping strategies?". -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +* EMERGENCY STRATEGIES +* Reminder: this is just an example of three emergency strategies. You will need to replace with the three strategies selected for your specific case -* this variable counts the strategies with valid (i.e. non missing) values - normally it should be equal to 10 for all respondents. -COMPUTE temp_nonmiss_number=NVALID(Lcs_stress_DomAsset, Lcs_stress_Utilities , Lcs_stress_Saving , Lcs_stress_BorrowCash , Lcs_crisis_ProdAssets , Lcs_crisis_Health , Lcs_crisis_OutSchool , Lcs_em_ResAsset , Lcs_em_Begged , Lcs_em_IllegalAct). +* Variable labels: +VARIABLE LABELS + Lcs_em_ResAsset "Mortgaged/Sold house or land" + Lcs_em_Begged "Begged and/or scavenged (asked strangers for money/food/other goods)" + Lcs_em_IllegalAct "Had to engage in illegal income activities (theft, prostitution)". + +* % of households who adopted one or more emergency coping strategies +DO IF + Lcs_em_ResAsset = 20 | + Lcs_em_ResAsset = 30 | + Lcs_em_Begged = 20 | + Lcs_em_Begged = 30 | + Lcs_em_IllegalAct = 20 | + Lcs_em_IllegalAct = 30. + COMPUTE emergency_coping_FS = 1. +ELSE. + COMPUTE emergency_coping_FS = 0. +END IF. +VARIABLE LABELS + emergency_coping_FS "Did the HH engage in emergency coping strategies?". + +* COPING BEHAVIOR +* This variable counts the strategies with valid (i.e. non-missing) values - normally it should be equal to 10 for all respondents. +COMPUTE temp_nonmiss_number = NVALID( + Lcs_stress_DomAsset, + Lcs_stress_Utilities, + Lcs_stress_Saving, + Lcs_stress_BorrowCash, + Lcs_crisis_ProdAssets, + Lcs_crisis_Health, + Lcs_crisis_OutSchool, + Lcs_em_ResAsset, + Lcs_em_Begged, + Lcs_em_IllegalAct). EXECUTE. -VARIABLE LABELS temp_nonmiss_number "Number of strategies with non missing values". +VARIABLE LABELS + temp_nonmiss_number "Number of strategies with non-missing values". - -DO IF temp_nonmiss_number>0. -COMPUTE Max_coping_behaviourFS=1. +DO IF temp_nonmiss_number > 0. + COMPUTE Max_coping_behaviourFS = 1. END IF. -* the Max_coping_behaviourFS variable will be missing for an observation if answers to strategies are all missing. - -DO IF stress_coping_FS=1. -COMPUTE Max_coping_behaviourFS=2. +* The Max_coping_behaviourFS variable will be missing for an observation if answers to strategies are all missing. +DO IF stress_coping_FS = 1. + COMPUTE Max_coping_behaviourFS = 2. END IF. - -DO IF crisis_coping_FS=1 . -COMPUTE Max_coping_behaviourFS=3. +DO IF crisis_coping_FS = 1. + COMPUTE Max_coping_behaviourFS = 3. END IF. - -DO IF emergency_coping_FS=1. -COMPUTE Max_coping_behaviourFS=4. +DO IF emergency_coping_FS = 1. + COMPUTE Max_coping_behaviourFS = 4. END IF. - EXECUTE. - -VALUE LABELS Max_coping_behaviourFS 1 'HH not adopting coping strategies' 2 'Stress coping strategies ' 3 'Crisis coping strategies ' 4 'Emergencies coping strategies'. -VARIABLE LABELS Max_coping_behaviourFS "Summary of asset depletion". - +EXECUTE. -DELETE VARIABLES temp_nonmiss_number. +VALUE LABELS + Max_coping_behaviourFS + 1 'HH not adopting coping strategies' + 2 'Stress coping strategies' + 3 'Crisis coping strategies' + 4 'Emergency coping strategies'. +VARIABLE LABELS + Max_coping_behaviourFS "Summary of asset depletion". + +DELETE VARIABLES + temp_nonmiss_number. EXECUTE. -* tabulate results. -FREQUENCIES Max_coping_behaviourFS. +* Tabulate results. +FREQUENCIES + Max_coping_behaviourFS. +* End of Scripts \ No newline at end of file diff --git a/Indicators/Multidimensional-deprivation-index/MDDI-indicator-tidyverse.R b/Indicators/Multidimensional-deprivation-index/MDDI-indicator-tidyverse.R new file mode 100644 index 0000000..11ce258 --- /dev/null +++ b/Indicators/Multidimensional-deprivation-index/MDDI-indicator-tidyverse.R @@ -0,0 +1,164 @@ +#------------------------------------------------------------------------------ +# WFP Standardized Scripts +# Multidimensional Deprivation Index (MDDI) Calculation +#------------------------------------------------------------------------------ + +# Construction of the Multidimensional Deprivation Index (MDDI) is based on the +# codebook questions prepared for the MDDI module available at: +# https://docs.wfp.org/api/documents/WFP-0000134356/download/ + +library(tidyverse) +library(labelled) + +# Load the data +data <- read_csv("path/to/your/data.csv") + +#------------------------------------------------------------------------------ +# 1. Creation of variables of deprivations for each dimension +#------------------------------------------------------------------------------ + +# FOOD DIMENSION + +# Define labels +var_label(data$FCSStap) <- "Consumption over the past 7 days (cereals and tubers)" +var_label(data$FCSVeg) <- "Consumption over the past 7 days (vegetables)" +var_label(data$FCSFruit) <- "Consumption over the past 7 days (fruit)" +var_label(data$FCSPr) <- "Consumption over the past 7 days (protein-rich foods)" +var_label(data$FCSPulse) <- "Consumption over the past 7 days (pulses)" +var_label(data$FCSDairy) <- "Consumption over the past 7 days (dairy products)" +var_label(data$FCSFat) <- "Consumption over the past 7 days (oil)" +var_label(data$FCSSugar) <- "Consumption over the past 7 days (sugar)" + +# Calculate FCS +data <- data %>% + mutate(FCS = (FCSStap * 2) + FCSVeg + FCSFruit + (FCSPr * 4) + + (FCSPulse * 3) + (FCSDairy * 4) + (FCSFat * 0.5) + (FCSSugar * 0.5)) + +# Categorize FCS +data <- data %>% + mutate(FCSCat28 = case_when( + FCS <= 28 ~ 1, + FCS <= 42 ~ 2, + TRUE ~ 3 + )) + +data <- data %>% + mutate(FCSCat21 = case_when( + FCS <= 21 ~ 1, + FCS <= 35 ~ 2, + TRUE ~ 3 + )) + +val_labels(data$FCSCat28) <- c("poor" = 1, "borderline" = 2, "acceptable" = 3) +val_labels(data$FCSCat21) <- c("poor" = 1, "borderline" = 2, "acceptable" = 3) + +# Turn into MDDI variable +data <- data %>% + mutate(MDDI_food1 = FCSCat28 %in% c(1, 2)) + +# rCSI (Reduced Consumption Strategies Index) +data <- data %>% + mutate(rCSI = (rCSILessQlty * 1) + (rCSIBorrow * 2) + (rCSIMealNb * 1) + + (rCSIMealSize * 1) + (rCSIMealAdult * 3)) + +data <- data %>% + mutate(MDDI_food2 = rCSI > 18) + +# EDUCATION DIMENSION +data <- data %>% + mutate(MDDI_edu1 = HHNoSchool == 1) + +# HEALTH DIMENSION +data <- data %>% + mutate(MDDI_health1 = HHENHealthMed %in% c(0, 1)) + +data <- data %>% + mutate(HHSickNb = rowSums(select(data, HHDisabledNb, HHChronIllNb), na.rm = TRUE)) %>% + mutate(HHSickShare = HHSickNb / HHSizeCalc) %>% + mutate(MDDI_health2 = (HHSickNb > 1 | HHSickShare > 0.5)) + +# SHELTER DIMENSION +data <- data %>% + mutate(MDDI_shelter1 = HEnerCookSRC %in% c(0, 100, 102, 200, 500, 600, 900, 999)) + +data <- data %>% + mutate(MDDI_shelter2 = !HEnerLightSRC %in% c(401, 402)) + +data <- data %>% + mutate(crowding = HHSizeCalc / HHRoomUsed) %>% + mutate(MDDI_shelter3 = crowding > 3) + +# WASH DIMENSION +data <- data %>% + mutate(MDDI_wash1 = HToiletType %in% c(20100, 20200, 20300, 20400, 20500)) + +data <- data %>% + mutate(MDDI_wash2 = HWaterSRC %in% c(500, 600, 700, 800)) + +# SAFETY DIMENSION +data <- data %>% + mutate(MDDI_safety1 = HHPercSafe == 0 | HHShInsec1Y == 1) + +data <- data %>% + mutate(interview_date = as.Date("2021-11-25"), + Arrival_time = as.numeric(difftime(interview_date, as.Date(HHHDisplArrive, origin = "1970-01-01"), units = "days")) / 30, + MDDI_safety2 = ifelse(HHDispl == 0, 0, Arrival_time < 13 & HHDisplChoice == 0)) + +#------------------------------------------------------------------------------ +# 2. Calculate deprivation score of each dimension +#------------------------------------------------------------------------------ + +data <- data %>% + mutate(MDDI_food = (MDDI_food1 * 1 / 2) + (MDDI_food2 * 1 / 2), + MDDI_edu = MDDI_edu1 * 1, + MDDI_health = (MDDI_health1 * 1 / 2) + (MDDI_health2 * 1 / 2), + MDDI_shelter = (MDDI_shelter1 * 1 / 3) + (MDDI_shelter2 * 1 / 3) + (MDDI_shelter3 * 1 / 3), + MDDI_wash = (MDDI_wash1 * 1 / 2) + (MDDI_wash2 * 1 / 2), + MDDI_safety = (MDDI_safety1 * 1 / 2) + (MDDI_safety2 * 1 / 2)) + +# Label variables +var_label(data$MDDI_food) <- "Deprivation score for food dimension" +var_label(data$MDDI_edu) <- "Deprivation score for education dimension" +var_label(data$MDDI_health) <- "Deprivation score for health dimension" +var_label(data$MDDI_shelter) <- "Deprivation score for shelter dimension" +var_label(data$MDDI_wash) <- "Deprivation score for WASH dimension" +var_label(data$MDDI_safety) <- "Deprivation score for safety and displacement dimension" + +data %>% + summarise(across(starts_with("MDDI_"), list(mean = mean, sd = sd, min = min, max = max), na.rm = TRUE)) + +#------------------------------------------------------------------------------ +# 3. Calculate MDDI-related measures +#------------------------------------------------------------------------------ + +# Calculate the overall MDDI Score +data <- data %>% + mutate(MDDI = (MDDI_food + MDDI_edu + MDDI_health + MDDI_shelter + MDDI_wash + MDDI_safety) / 6) + +var_label(data$MDDI) <- "MDDI score" + +# Calculate MDDI Incidence (H) +data <- data %>% + mutate(MDDI_poor_severe = MDDI >= 0.50, + MDDI_poor = MDDI >= 0.33) + +val_labels(data$MDDI_poor) <- c("HH is not deprived" = 0, "HH is deprived" = 1) +val_labels(data$MDDI_poor_severe) <- c("HH is not deprived" = 0, "HH is deprived" = 1) + +# Calculate the Average MDDI Intensity (A) +data <- data %>% + mutate(MDDI_intensity = ifelse(MDDI_poor == 1, MDDI, NA)) + +var_label(data$MDDI_intensity) <- "Average MDDI Intensity (A)" + +# Calculate Combined MDDI (M = H x A) +data <- data %>% + mutate(MDDI_combined = ifelse(MDDI_poor == 1, MDDI_poor * MDDI_intensity, 0)) + +var_label(data$MDDI_combined) <- "Combined MDDI (M)" + +# Show results +data %>% + summarise(across(c(MDDI_poor, MDDI_poor_severe, MDDI_intensity, MDDI_combined), mean, na.rm = TRUE)) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Multidimensional-deprivation-index/MDDI-indicator.do b/Indicators/Multidimensional-deprivation-index/MDDI-indicator.do index 33b7554..5a6bb58 100644 --- a/Indicators/Multidimensional-deprivation-index/MDDI-indicator.do +++ b/Indicators/Multidimensional-deprivation-index/MDDI-indicator.do @@ -1,207 +1,211 @@ - -******************************************************************************** -* STATA Syntax for the Multidimensional Deprivation Index (MDDI) -******************************************************************************** - -*Construction of the Multidimensional Deprivation Index (MDDI) is based on the codebook questions prepared for the MDDI module available at: https://docs.wfp.org/api/documents/WFP-0000134356/download/ - -*-------------------------------------------------------------------------------* -* 1. Creation of variables of deprivations for each dimension -*-------------------------------------------------------------------------------* - -*** FOOD DIMENSION - - ** Food Consumption Score - -*Define labels (skip if already done) -lab var FCSStap "Consumption over the past 7 days (cereals and tubers)" -lab var FCSVeg "Consumption over the past 7 days (vegetables)" -lab var FCSFruit "Consumption over the past 7 days (fruit)" -lab var FCSPr "Consumption over the past 7 days (protein-rich foods)" -lab var FCSPulse "Consumption over the past 7 days (pulses)" -lab var FCSDairy "Consumption over the past 7 days (dairy products)" -lab var FCSFat "Consumption over the past 7 days (oil)" -lab var FCSSugar "Consumption over the past 7 days (sugar)" - -*Calculate FCS (skip if already done) -gen FCS=(FCSStap*2) + FCSVeg + FCSFruit + (FCSPr*4) + (FCSPulse*3) + (FCSDairy*4) + (FCSFat*0.5) + (FCSSugar*0.5) -lab var FCS "Food Consumption Score" - -*Categorize FCS (skip if already done) - *Use this when analyzing a country with high consumption of sugar and oil – thresholds 28-42 -recode FCS (0/28=1 "poor") (28.5/42=2 "borderline") (42.5/max=3 "acceptable"), gen(FCSCat28) -lab var FCSCat28 "FCS Categories" -sum FCSCat28 - - *Use this when analyzing a country with low consumption of sugar and oil - thresholds 21-35 -recode FCS (0/21=1 "poor") (21.5/35=2 "borderline") (35.5/max=3 "acceptable"), gen (FCSCat21) -lab var FCSCat21 "FCS Categories" -sum FCSCat21 - -*Turn into MDDI variable (with high consumption of sugar and oil countries) - * Note: Use FCSCat21 for low consumption of sugar and oil countries -gen MDDI_food1= (FCSCat28==1 | FCSCat28==2) if FCSCat28!=. -lab var MDDI_food1 "HH with unacceptable food consumption" -tab MDDI_food1 - - **rCSI (Reduced Consumption Strategies Index) - -*Define Lables (skip if already done) -lab var rCSILessQlty "Relied on less preferred, less expensive food" -lab var rCSIBorrow "Borrowed food or relied on help from friends or relatives" -lab var rCSIMealNb "Reduced the number of meals eaten per day" -lab var rCSIMealSize "Reduced portion size of meals at meals time" +*------------------------------------------------------------------------------ +* WFP Standardized Scripts +* Multidimensional Deprivation Index (MDDI) Calculation +*------------------------------------------------------------------------------ + +* Construction of the Multidimensional Deprivation Index (MDDI) is based on the +* codebook questions prepared for the MDDI module available at: +* https://docs.wfp.org/api/documents/WFP-0000134356/download/ + +*------------------------------------------------------------------------------ +* 1. Creation of variables of deprivations for each dimension +*------------------------------------------------------------------------------ + +*** FOOD DIMENSION *** + + ** Food Consumption Score ** + +* Define labels (skip if already done) +lab var FCSStap "Consumption over the past 7 days (cereals and tubers)" +lab var FCSVeg "Consumption over the past 7 days (vegetables)" +lab var FCSFruit "Consumption over the past 7 days (fruit)" +lab var FCSPr "Consumption over the past 7 days (protein-rich foods)" +lab var FCSPulse "Consumption over the past 7 days (pulses)" +lab var FCSDairy "Consumption over the past 7 days (dairy products)" +lab var FCSFat "Consumption over the past 7 days (oil)" +lab var FCSSugar "Consumption over the past 7 days (sugar)" + +* Calculate FCS (skip if already done) +gen FCS = (FCSStap * 2) + FCSVeg + FCSFruit + (FCSPr * 4) + (FCSPulse * 3) + (FCSDairy * 4) + (FCSFat * 0.5) + (FCSSugar * 0.5) +lab var FCS "Food Consumption Score" + +* Categorize FCS (skip if already done) + * Use this when analyzing a country with high consumption of sugar and oil – thresholds 28-42 +recode FCS (0/28 = 1 "poor") (28.5/42 = 2 "borderline") (42.5/max = 3 "acceptable"), gen(FCSCat28) +lab var FCSCat28 "FCS Categories" +sum FCSCat28 + + * Use this when analyzing a country with low consumption of sugar and oil - thresholds 21-35 +recode FCS (0/21 = 1 "poor") (21.5/35 = 2 "borderline") (35.5/max = 3 "acceptable"), gen(FCSCat21) +lab var FCSCat21 "FCS Categories" +sum FCSCat21 + +* Turn into MDDI variable (with high consumption of sugar and oil countries) + * Note: Use FCSCat21 for low consumption of sugar and oil countries +gen MDDI_food1 = (FCSCat28 == 1 | FCSCat28 == 2) if FCSCat28 != . +lab var MDDI_food1 "HH with unacceptable food consumption" +tab MDDI_food1 + + ** rCSI (Reduced Consumption Strategies Index) ** + +* Define labels (skip if already done) +lab var rCSILessQlty "Relied on less preferred, less expensive food" +lab var rCSIBorrow "Borrowed food or relied on help from friends or relatives" +lab var rCSIMealNb "Reduced the number of meals eaten per day" +lab var rCSIMealSize "Reduced portion size of meals at meals time" lab var rCSIMealAdult "Restrict consumption by adults in order for young-children to eat" -*Compute rCSI (skip if already done) -gen rCSI=(rCSILessQlty*1) + (rCSIBorrow*2) + (rCSIMealNb*1) + (rCSIMealSize*1) + (rCSIMealAdult*3) -lab var rCSI "Reduced Consumption Strategies Index" - -*Turn into MDDI variable - *For the rCSI, use the threshold as 18 - this is defined as IPC3+ -gen MDDI_food2= rCSI>18 if rCSI!=. -lab var MDDI_food2 "HH with high level of consumption coping strategies" -tab MDDI_food2 - -*** EDUCATION DIMENSION - - **At least one school age children (6-17) (adjust to country context) not attending school in the last 6 months -gen MDDI_edu1= HHNoSchool==1 -lab var MDDI_edu1 "HH with at least one school-age children not attending school" -tab MDDI_edu1 - -*** HEALTH DIMENSION - - **Medical treatment - Did household members being chronically or acutely ill receive medical attention while sick? (answers - 0="No", 1="Yes, some of them", 2="Yes, all of them") -gen MDDI_health1=(HHENHealthMed==0 | HHENHealthMed==1) if HHENHealthMed!=. -lab var MDDI_health1 "HH with at least one member did not receive medical treatment while sick" -tab MDDI_health1 - - **Number of sick or disabled people > 1 or >50% of household members -egen HHSickNb=rowtotal(HHDisabledNb HHChronIllNb) -replace HHSickNb= . if HHDisabledNb==. & HHChronIllNb==. -gen HHSickShare= HHSickNb/HHSizeCalc -gen MDDI_health2=(HHSickNb>1 | HHSickShare>0.5) -replace MDDI_health2=. if HHSickNb==. & HHSickShare==. -lab var MDDI_health2 "HH with more than half members or more than one member sick" -tab MDDI_health2 - -*** SHELTER DIMENSION - - **Source of energy for cooking - HH uses solid fuels for cooking -gen MDDI_shelter1=(HEnerCookSRC==0 | HEnerCookSRC==100 | HEnerCookSRC==200 | HEnerCookSRC==500 | HEnerCookSRC==600 | HEnerCookSRC==900 | HEnerCookSRC==999) -replace MDDI_shelter1=. if HEnerCookSRC==. +* Compute rCSI (skip if already done) +gen rCSI = (rCSILessQlty * 1) + (rCSIBorrow * 2) + (rCSIMealNb * 1) + (rCSIMealSize * 1) + (rCSIMealAdult * 3) +lab var rCSI "Reduced Consumption Strategies Index" + +* Turn into MDDI variable + * For the rCSI, use the threshold as 18 - this is defined as IPC3+ +gen MDDI_food2 = rCSI > 18 if rCSI != . +lab var MDDI_food2 "HH with high level of consumption coping strategies" +tab MDDI_food2 + +*** EDUCATION DIMENSION *** + +* At least one school age children (6-17) (adjust to country context) not attending school in the last 6 months +gen MDDI_edu1 = HHNoSchool == 1 +lab var MDDI_edu1 "HH with at least one school-age children not attending school" +tab MDDI_edu1 + +*** HEALTH DIMENSION *** + +* Medical treatment - Did household members being chronically or acutely ill receive medical attention while sick? +* (answers - 0="No", 1="Yes, some of them", 2="Yes, all of them") +gen MDDI_health1 = (HHENHealthMed == 0 | HHENHealthMed == 1) if HHENHealthMed != . +lab var MDDI_health1 "HH with at least one member did not receive medical treatment while sick" +tab MDDI_health1 + +* Number of sick or disabled people > 1 or >50% of household members +egen HHSickNb = rowtotal(HHDisabledNb HHChronIllNb) +replace HHSickNb = . if HHDisabledNb == . & HHChronIllNb == . +gen HHSickShare = HHSickNb / HHSizeCalc +gen MDDI_health2 = (HHSickNb > 1 | HHSickShare > 0.5) +replace MDDI_health2 = . if HHSickNb == . & HHSickShare == . +lab var MDDI_health2 "HH with more than half members or more than one member sick" +tab MDDI_health2 + +*** SHELTER DIMENSION *** + +* Source of energy for cooking - HH uses solid fuels for cooking +gen MDDI_shelter1 = (HEnerCookSRC == 0 | HEnerCookSRC == 100 | HEnerCookSRC == 200 | HEnerCookSRC == 500 | HEnerCookSRC == 600 | HEnerCookSRC == 900 | HEnerCookSRC == 999) +replace MDDI_shelter1 = . if HEnerCookSRC == . lab var MDDI_shelter1 "HH with no improved energy source for cooking" -tab MDDI_shelter1 +tab MDDI_shelter1 - **Source of energy for lighting - HH has no electricity -gen MDDI_shelter2= HEnerLightSRC!=401 & HEnerLightSRC!=402 -replace MDDI_shelter2=. if HEnerLightSRC==. +* Source of energy for lighting - HH has no electricity +gen MDDI_shelter2 = HEnerLightSRC != 401 & HEnerLightSRC != 402 +replace MDDI_shelter2 = . if HEnerLightSRC == . lab var MDDI_shelter2 "HH with not improved source of energy for lighting" -tab MDDI_shelter2 +tab MDDI_shelter2 - **Crowding Index - (Number of HH members/Number of rooms (excluding kitchen, corridors))>3 -gen crowding=HHSizeCalc/HHRoomUsed -gen MDDI_shelter3=crowding>3 -replace MDDI_shelter3=. if crowding==. +* Crowding Index - (Number of HH members/Number of rooms (excluding kitchen, corridors)) > 3 +gen crowding = HHSizeCalc / HHRoomUsed +gen MDDI_shelter3 = crowding > 3 +replace MDDI_shelter3 = . if crowding == . lab var MDDI_shelter3 "HH with at least 3 HH members sharing one room to sleep" -tab MDDI_shelter3 - -*** WASH DIMENSION - - **Toilet Type (not-improved facility) -gen MDDI_wash1=HToiletType==20100 | HToiletType==20200 | HToiletType==20300 | HToiletType==20400 | HToiletType==20500 -replace MDDI_wash1=. if HToiletType==. -lab var MDDI_wash1 "HH with not improved toilet facility" -tab MDDI_wash1 - - **Water source (not-improved source) -gen MDDI_wash2=(HWaterSRC==500 | HWaterSRC==600 | HWaterSRC==700 | HWaterSRC==800) -replace MDDI_wash2=. if HWaterSRC ==. -lab var MDDI_wash2 "HH with not improved drinking water source" -tab MDDI_wash2 - -** SAFETY DIMENSION - - **Safety: HH felt unsafe or suffered violence -gen MDDI_safety1=HHPercSafe==0 | HHShInsec1Y==1 -replace MDDI_safety1=. if HHPercSafe==. & HHShInsec1Y ==. -lab var MDDI_safety1 "HH with one or more members who felt unsafe or suffered violence" -tab MDDI_safety1 - - **Displaced by forced in the last 12 months - *Example of calculating months since arrival (adjust if you already have a variable for the date of data collection and use it instead of `interview_date' variable) - -* Step 1. Create fictitious day of data collection -gen interview_date = date("11/25/21", "MD20Y") - -*Step 2. Show current date in date format (check if HHHDisplArrive is not already in %td) -format interview_date HHHDisplArrive %td - -*Step 3. Compute the difference -gen Arrival_time = datediff(interview_date, HHHDisplArrive,"month") - -*Step 4. Turn into MDDI variable -gen MDDI_safety2=Arrival_time<13 & HHDisplChoice==0 -replace MDDI_safety2=. if (Arrival_time==. | HHDisplChoice==.) & (HHDispl==1 | HHDispl==.) -lab var MDDI_safety2 "HH displaced by force in the last 12 months" -tab MDDI_safety2 - -*-------------------------------------------------------------------------------* -* 2. Calculate deprivation score of each dimension -*-------------------------------------------------------------------------------* - -*Weighting: Method of nesting with equal weights. -*Note: by default if any indicator is missing for a case, its deprivation score for the dimension of that indicator will be missing. -*Consequently, also MDDI measures will be missing. Be careful with indicators that are missing for many observations (e.g. >10% of the sample). - -gen MDDI_food=(MDDI_food1*1/2) + (MDDI_food2*1/2) -gen MDDI_edu=MDDI_edu1*1 -gen MDDI_health=(MDDI_health1*1/2) + (MDDI_health2*1/2) -gen MDDI_shelter=(MDDI_shelter1*1/3) +(MDDI_shelter2*1/3) + (MDDI_shelter3*1/3) -gen MDDI_wash=(MDDI_wash1*1/2) + (MDDI_wash2*1/2) -gen MDDI_safety=(MDDI_safety1*1/2) + (MDDI_safety2*1/2) - -*Label Variables: -lab var MDDI_food "Deprivation score for food dimension" -lab var MDDI_edu "Deprivation score for education dimension" -lab var MDDI_health "Deprivation score for health dimension" -lab var MDDI_shelter "Deprivation score for shelter dimension" -lab var MDDI_wash "Deprivation score for WASH dimension" -lab var MDDI_safety "Deprivation score for safety and displacement dimension" +tab MDDI_shelter3 + +*** WASH DIMENSION *** + +* Toilet Type (not-improved facility) +gen MDDI_wash1 = (HToiletType == 20100 | HToiletType == 20200 | HToiletType == 20300 | HToiletType == 20400 | HToiletType == 20500) +replace MDDI_wash1 = . if HToiletType == . +lab var MDDI_wash1 "HH with not improved toilet facility" +tab MDDI_wash1 + +* Water source (not-improved source) +gen MDDI_wash2 = (HWaterSRC == 500 | HWaterSRC == 600 | HWaterSRC == 700 | HWaterSRC == 800) +replace MDDI_wash2 = . if HWaterSRC == . +lab var MDDI_wash2 "HH with not improved drinking water source" +tab MDDI_wash2 + +*** SAFETY DIMENSION *** + +* Safety: HH felt unsafe or suffered violence +gen MDDI_safety1 = HHPercSafe == 0 | HHShInsec1Y == 1 +replace MDDI_safety1 = . if HHPercSafe == . & HHShInsec1Y == . +lab var MDDI_safety1 "HH with one or more members who felt unsafe or suffered violence" +tab MDDI_safety1 + +* Displaced by force in the last 12 months +* Example of calculating months since arrival (adjust if you already have a variable for the date of data collection and use it instead of `interview_date' variable) + +* Step 1. Create fictitious day of data collection +gen interview_date = date("11/25/21", "MD20Y") + +* Step 2. Show current date in date format (check if HHHDisplArrive is not already in %td) +format interview_date HHHDisplArrive %td + +* Step 3. Compute the difference +gen Arrival_time = datediff(interview_date, HHHDisplArrive, "month") + +* Step 4. Turn into MDDI variable +gen MDDI_safety2 = Arrival_time < 13 & HHDisplChoice == 0 +replace MDDI_safety2 = 0 if HHDispl == 0 +replace MDDI_safety2 = . if (Arrival_time == . | HHDisplChoice == .) & (HHDispl == 1 | HHDispl == .) +lab var MDDI_safety2 "HH displaced by force in the last 12 months" +tab MDDI_safety2 + +*------------------------------------------------------------------------------ +* 2. Calculate deprivation score of each dimension +*------------------------------------------------------------------------------ + +* Weighting: Method of nesting with equal weights +* Note: by default if any indicator is missing for a case, its deprivation score for the dimension of that indicator will be missing. +* Consequently, also MDDI measures will be missing. Be careful with indicators that are missing for many observations (e.g. >10% of the sample). + +gen MDDI_food = (MDDI_food1 * 1 / 2) + (MDDI_food2 * 1 / 2) +gen MDDI_edu = MDDI_edu1 * 1 +gen MDDI_health = (MDDI_health1 * 1 / 2) + (MDDI_health2 * 1 / 2) +gen MDDI_shelter = (MDDI_shelter1 * 1 / 3) + (MDDI_shelter2 * 1 / 3) + (MDDI_shelter3 * 1 / 3) +gen MDDI_wash = (MDDI_wash1 * 1 / 2) + (MDDI_wash2 * 1 / 2) +gen MDDI_safety = (MDDI_safety1 * 1 / 2) + (MDDI_safety2 * 1 / 2) + +* Label Variables +lab var MDDI_food "Deprivation score for food dimension" +lab var MDDI_edu "Deprivation score for education dimension" +lab var MDDI_health "Deprivation score for health dimension" +lab var MDDI_shelter "Deprivation score for shelter dimension" +lab var MDDI_wash "Deprivation score for WASH dimension" +lab var MDDI_safety "Deprivation score for safety and displacement dimension" tabstat MDDI_food MDDI_edu MDDI_health MDDI_shelter MDDI_wash MDDI_safety, stat(mean sd min max) -*-------------------------------------------------------------------------------* -* 3. Calculate MDDI-related measures -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------ +* 3. Calculate MDDI-related measures +*------------------------------------------------------------------------------ -*Calculate the overall MDDI Score -gen MDDI= (MDDI_food+MDDI_edu+MDDI_health+MDDI_shelter+MDDI_wash+MDDI_safety)/6 -lab var MDDI "MDDI score" +* Calculate the overall MDDI Score +gen MDDI = (MDDI_food + MDDI_edu + MDDI_health + MDDI_shelter + MDDI_wash + MDDI_safety) / 6 +lab var MDDI "MDDI score" -*Calculate MDDI Incidence (H) - *Thresholds are 0.50 for severe deprivation and 0.33 for deprivation – it can be adjusted according to the context -gen MDDI_poor_severe=MDDI>=0.50 +* Calculate MDDI Incidence (H) + * Thresholds are 0.50 for severe deprivation and 0.33 for deprivation – it can be adjusted according to the context +gen MDDI_poor_severe = MDDI >= 0.50 lab var MDDI_poor_severe "MDDI Incidence – severe deprivation" -gen MDDI_poor=MDDI>=0.33 -lab var MDDI_poor "MDDI Incidence" +gen MDDI_poor = MDDI >= 0.33 +lab var MDDI_poor "MDDI Incidence" -lab def MDDI_label 0 "HH is not deprived" 1 "HH is deprived" +lab def MDDI_label 0 "HH is not deprived" 1 "HH is deprived" lab val MDDI_poor_severe MDDI_label -lab val MDDI_poor MDDI_label +lab val MDDI_poor MDDI_label -*Calculate the Average MDDI Intensity (A) -gen MDDI_intensity=MDDI if MDDI_poor==1 // the variable is missing for non MDDI-poor households +* Calculate the Average MDDI Intensity (A) +gen MDDI_intensity = MDDI if MDDI_poor == 1 // the variable is missing for non MDDI-poor households lab var MDDI_intensity "Average MDDI Intensity (A)" -*Calculate Combined MDDI (M= HxA) -gen MDDI_combined=MDDI_poor*MDDI_intensity if MDDI_poor==1 -replace MDDI_combined = 0 if MDDI_poor==0 // for household non MDDI poor, combined MDDI is zero +* Calculate Combined MDDI (M = H x A) +gen MDDI_combined = MDDI_poor * MDDI_intensity if MDDI_poor == 1 +replace MDDI_combined = 0 if MDDI_poor == 0 // for household non MDDI poor, combined MDDI is zero lab var MDDI_combined "Combined MDDI (M)" -*Show results +* Show results tabstat MDDI_poor MDDI_poor_severe MDDI_intensity MDDI_combined, stat(mean) - +* End of Scripts \ No newline at end of file diff --git a/Indicators/Multidimensional-deprivation-index/MDDI-indicator.py b/Indicators/Multidimensional-deprivation-index/MDDI-indicator.py new file mode 100644 index 0000000..939b677 --- /dev/null +++ b/Indicators/Multidimensional-deprivation-index/MDDI-indicator.py @@ -0,0 +1,103 @@ +#------------------------------------------------------------------------------ +# WFP Standardized Scripts +# Multidimensional Deprivation Index (MDDI) Calculation +#------------------------------------------------------------------------------ + +# Construction of the Multidimensional Deprivation Index (MDDI) is based on the +# codebook questions prepared for the MDDI module available at: +# https://docs.wfp.org/api/documents/WFP-0000134356/download/ + +import pandas as pd +import numpy as np + +# Load the data +data = pd.read_csv("path/to/your/data.csv") + +#------------------------------------------------------------------------------ +# 1. Creation of variables of deprivations for each dimension +#------------------------------------------------------------------------------ + +# FOOD DIMENSION + +# Calculate FCS +data['FCS'] = (data['FCSStap'] * 2) + data['FCSVeg'] + data['FCSFruit'] + \ + (data['FCSPr'] * 4) + (data['FCSPulse'] * 3) + (data['FCSDairy'] * 4) + \ + (data['FCSFat'] * 0.5) + (data['FCSSugar'] * 0.5) + +# Categorize FCS +data['FCSCat28'] = pd.cut(data['FCS'], bins=[-np.inf, 28, 42, np.inf], labels=[1, 2, 3]) +data['FCSCat21'] = pd.cut(data['FCS'], bins=[-np.inf, 21, 35, np.inf], labels=[1, 2, 3]) + +# Turn into MDDI variable +data['MDDI_food1'] = data['FCSCat28'].isin([1, 2]).astype(int) + +# rCSI (Reduced Consumption Strategies Index) +data['rCSI'] = (data['rCSILessQlty'] * 1) + (data['rCSIBorrow'] * 2) + (data['rCSIMealNb'] * 1) + \ + (data['rCSIMealSize'] * 1) + (data['rCSIMealAdult'] * 3) + +data['MDDI_food2'] = (data['rCSI'] > 18).astype(int) + +# EDUCATION DIMENSION +data['MDDI_edu1'] = (data['HHNoSchool'] == 1).astype(int) + +# HEALTH DIMENSION +data['MDDI_health1'] = data['HHENHealthMed'].isin([0, 1]).astype(int) + +data['HHSickNb'] = data[['HHDisabledNb', 'HHChronIllNb']].sum(axis=1, skipna=True) +data['HHSickShare'] = data['HHSickNb'] / data['HHSizeCalc'] +data['MDDI_health2'] = ((data['HHSickNb'] > 1) | (data['HHSickShare'] > 0.5)).astype(int) + +# SHELTER DIMENSION +data['MDDI_shelter1'] = data['HEnerCookSRC'].isin([0, 100, 102, 200, 500, 600, 900, 999]).astype(int) +data['MDDI_shelter2'] = ~data['HEnerLightSRC'].isin([401, 402]).astype(int) +data['crowding'] = data['HHSizeCalc'] / data['HHRoomUsed'] +data['MDDI_shelter3'] = (data['crowding'] > 3).astype(int) + +# WASH DIMENSION +data['MDDI_wash1'] = data['HToiletType'].isin([20100, 20200, 20300, 20400, 20500]).astype(int) +data['MDDI_wash2'] = data['HWaterSRC'].isin([500, 600, 700, 800]).astype(int) + +# SAFETY DIMENSION +data['MDDI_safety1'] = ((data['HHPercSafe'] == 0) | (data['HHShInsec1Y'] == 1)).astype(int) + +# Example of calculating months since arrival +data['interview_date'] = pd.to_datetime('2021-11-25') +data['HHHDisplArrive'] = pd.to_datetime(data['HHHDisplArrive'], origin='1970-01-01', errors='coerce') +data['Arrival_time'] = (data['interview_date'] - data['HHHDisplArrive']).dt.days / 30 +data['MDDI_safety2'] = ((data['Arrival_time'] < 13) & (data['HHDisplChoice'] == 0)).astype(int) +data.loc[data['HHDispl'] == 0, 'MDDI_safety2'] = 0 + +#------------------------------------------------------------------------------ +# 2. Calculate deprivation score of each dimension +#------------------------------------------------------------------------------ + +data['MDDI_food'] = (data['MDDI_food1'] * 1 / 2) + (data['MDDI_food2'] * 1 / 2) +data['MDDI_edu'] = data['MDDI_edu1'] * 1 +data['MDDI_health'] = (data['MDDI_health1'] * 1 / 2) + (data['MDDI_health2'] * 1 / 2) +data['MDDI_shelter'] = (data['MDDI_shelter1'] * 1 / 3) + (data['MDDI_shelter2'] * 1 / 3) + (data['MDDI_shelter3'] * 1 / 3) +data['MDDI_wash'] = (data['MDDI_wash1'] * 1 / 2) + (data['MDDI_wash2'] * 1 / 2) +data['MDDI_safety'] = (data['MDDI_safety1'] * 1 / 2) + (data['MDDI_safety2'] * 1 / 2) + +#------------------------------------------------------------------------------ +# 3. Calculate MDDI-related measures +#------------------------------------------------------------------------------ + +# Calculate the overall MDDI Score +data['MDDI'] = (data['MDDI_food'] + data['MDDI_edu'] + data['MDDI_health'] + data['MDDI_shelter'] + data['MDDI_wash'] + data['MDDI_safety']) / 6 + +# Calculate MDDI Incidence (H) +data['MDDI_poor_severe'] = (data['MDDI'] >= 0.50).astype(int) +data['MDDI_poor'] = (data['MDDI'] >= 0.33).astype(int) + +# Calculate the Average MDDI Intensity (A) +data['MDDI_intensity'] = data['MDDI'].where(data['MDDI_poor'] == 1) + +# Calculate Combined MDDI (M = H x A) +data['MDDI_combined'] = data['MDDI_poor'] * data['MDDI_intensity'] +data.loc[data['MDDI_poor'] == 0, 'MDDI_combined'] = 0 + +# Show results +results = data[['MDDI_poor', 'MDDI_poor_severe', 'MDDI_intensity', 'MDDI_combined']].mean() +print(results) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Multidimensional-deprivation-index/MDDI-indicator.sps b/Indicators/Multidimensional-deprivation-index/MDDI-indicator.sps index 88dde0d..0ea163c 100644 --- a/Indicators/Multidimensional-deprivation-index/MDDI-indicator.sps +++ b/Indicators/Multidimensional-deprivation-index/MDDI-indicator.sps @@ -1,246 +1,248 @@ -* Encoding: UTF-8. +*------------------------------------------------------------------------------ +* WFP Standardized Scripts +* Multidimensional Deprivation Index (MDDI) Calculation +*------------------------------------------------------------------------------ -******************************************************************************** -* SPSS Syntax for the Multidimensional Deprivation Index (MDDI) -******************************************************************************** - -*Construction of the Multidimensional Deprivation Index (MDDI) is based on the codebook questions prepared for the MDDI module available at: -https://docs.wfp.org/api/documents/WFP-0000134356/download/ +* Construction of the Multidimensional Deprivation Index (MDDI) is based on the +* codebook questions prepared for the MDDI module available at: +* https://docs.wfp.org/api/documents/WFP-0000134356/download/ -*-------------------------------------------------------------------------------* -* 1. Creation of variables of deprivations for each dimension -*-------------------------------------------------------------------------------* +*------------------------------------------------------------------------------ +* 1. Creation of variables of deprivations for each dimension +*------------------------------------------------------------------------------ -*** FOOD DIMENSION +*** FOOD DIMENSION *** - ** Food Consumption Score - -*Define labels (skip if already done). + ** Food Consumption Score ** + +* Define labels (skip if already done) variable labels -FCSStap Consumption over the past 7 days (cereals and tubers) -FCSVeg Consumption over the past 7 days (vegetables) -FCSFruit Consumption over the past 7 days (fruit) -FCSPr Consumption over the past 7 days (protein-rich foods) -FCSPulse Consumption over the past 7 days (pulses) -FCSDairy Consumption over the past 7 days (dairy products) -FCSFat Consumption over the past 7 days (oil) -FCSSugar Consumption over the past 7 days (sugar). - -*Calculate FCS (skip if already done). + FCSStap "Consumption over the past 7 days (cereals and tubers)" + FCSVeg "Consumption over the past 7 days (vegetables)" + FCSFruit "Consumption over the past 7 days (fruit)" + FCSPr "Consumption over the past 7 days (protein-rich foods)" + FCSPulse "Consumption over the past 7 days (pulses)" + FCSDairy "Consumption over the past 7 days (dairy products)" + FCSFat "Consumption over the past 7 days (oil)" + FCSSugar "Consumption over the past 7 days (sugar)". + +* Calculate FCS (skip if already done) compute FCS = sum(FCSStap*2, FCSVeg, FCSFruit, FCSPr*4, FCSPulse*3, FCSDairy*4, FCSFat*0.5, FCSSugar*0.5). variable labels FCS "Food Consumption Score". execute. -*Categorize FCS (skip if already done). +* Categorize FCS (skip if already done) - *Use this when analyzing a country with high consumption of sugar and oil – thresholds 28-42. -recode FCS (0 thru 28 =1) (28.5 thru 42 =2) (42.5 thru highest =3) into FCSCat28. +* Use this when analyzing a country with high consumption of sugar and oil – thresholds 28-42 +recode FCS (0 thru 28 = 1) (28.5 thru 42 = 2) (42.5 thru highest = 3) into FCSCat28. variable labels FCSCat28 "FCS Categories". execute. - *Use this when analyzing a country with low consumption of sugar and oil - thresholds 21-35. -recode FCS (0 thru 21 =1) (21.5 thru 35 =2) (35.5 thru highest =3) into FCSCat21. +* Use this when analyzing a country with low consumption of sugar and oil - thresholds 21-35 +recode FCS (0 thru 21 = 1) (21.5 thru 35 = 2) (35.5 thru highest = 3) into FCSCat21. variable labels FCSCat21 "FCS Categories". execute. -*Define labels for "FCS Categories". +* Define labels for "FCS Categories" value labels FCSCat21 - 1.00 'poor' - 2.00 'borderline' - 3.00 'acceptable '. + 1 'poor' + 2 'borderline' + 3 'acceptable'. value labels FCSCat28 - 1.00 'poor' - 2.00 'borderline' - 3.00 'acceptable '. + 1 'poor' + 2 'borderline' + 3 'acceptable'. execute. frequencies FCSCat21 FCSCat28. -*Turn into MDDI variable (with high consumption of sugar and oil countries). - /* Note: Use FCSCat21 for low consumption of sugar and oil countries. -compute MDDI_food1 = (FCSCat28=1 | FCSCat28=2). +* Turn into MDDI variable (with high consumption of sugar and oil countries) +* Note: Use FCSCat21 for low consumption of sugar and oil countries +compute MDDI_food1 = (FCSCat28 = 1 | FCSCat28 = 2). execute. frequencies MDDI_food1. -variable labels MDDI_food1 ‘HH with unacceptable food consumption’. +variable labels MDDI_food1 "HH with unacceptable food consumption". + + *** rCSI (Reduced Consumption Strategies Index) *** - ***rCSI (Reduced Consumption Strategies Index). - -/***variable labels -/*1. Relied on less preferred, less expensive food -rCSILessQlty -/*2. Borrowed food or relied on help from friends or relatives-rCSIBorrow -/*3. Reduced the number of meals eaten per day- rCSIMealNb -/*4. Reduced portion size of meals at meals time-rCSIMealSize -/*5. Restrict consumption by adults in order for young-children to eat-rCSIMealAdult +* Define labels +variable labels + rCSILessQlty "Relied on less preferred, less expensive food" + rCSIBorrow "Borrowed food or relied on help from friends or relatives" + rCSIMealNb "Reduced the number of meals eaten per day" + rCSIMealSize "Reduced portion size of meals at meals time" + rCSIMealAdult "Restrict consumption by adults in order for young-children to eat". -*Compute rCSI (skip if already done). -compute rCSI=(rCSILessQlty * 1) + (rCSIBorrow* 2) + (rCSIMealNb * 1) + (rCSIMealSize * 1) + (rCSIMealAdult * 3). +* Compute rCSI (skip if already done) +compute rCSI = (rCSILessQlty * 1) + (rCSIBorrow * 2) + (rCSIMealNb * 1) + (rCSIMealSize * 1) + (rCSIMealAdult * 3). execute. -*Turn into MDDI variable - *For the rCSI, use the threshold as 18 - this is defined as IPC3+. -compute MDDI_food2 = rCSI>18. +* Turn into MDDI variable +* For the rCSI, use the threshold as 18 - this is defined as IPC3+ +compute MDDI_food2 = rCSI > 18. execute. -variable labels MDDI_food2 ‘HH with high level of consumption coping strategies’. +variable labels MDDI_food2 "HH with high level of consumption coping strategies". frequencies MDDI_food2. -*** EDUCATION DIMENSION +*** EDUCATION DIMENSION *** - **At least one school age children (6-17) (adjust to country context) not attending school in the last 6 months. -compute MDDI_edu1= HHNoSchool=1. +* At least one school age children (6-17) (adjust to country context) not attending school in the last 6 months +compute MDDI_edu1 = HHNoSchool = 1. execute. -variable labels MDDI_edu1 ‘HH with at least one school-age children not attending school’. +variable labels MDDI_edu1 "HH with at least one school-age children not attending school". frequencies MDDI_edu1. -*** HEALTH DIMENSION - - **Medical treatment - Did household members being chronically or acutely ill receive medical attention while sick? (answers - 0="No", 1="Yes, some of them", 2="Yes, all of them"). -compute MDDI_health1= (HHENHealthMed=0 | HHENHealthMed=1). +*** HEALTH DIMENSION *** + +* Medical treatment - Did household members being chronically or acutely ill receive medical attention while sick? +* (answers - 0="No", 1="Yes, some of them", 2="Yes, all of them") +compute MDDI_health1 = (HHENHealthMed = 0 | HHENHealthMed = 1). execute. -variable labels MDDI_health1 ‘HH with at least one member did not receive medical treatment while sick’. +variable labels MDDI_health1 "HH with at least one member did not receive medical treatment while sick". frequencies MDDI_health1. - **Number of sick or disabled people > 1 or >50% of household members. -compute HHSickNb= sum(HHDisabledNb, HHChronIllNb). -compute HHSickShare= HHSickNb/ HHSizeCalc. -compute MDDI_health2 = (HHSickNb>1 | HHSickShare>0.5). +* Number of sick or disabled people > 1 or >50% of household members +compute HHSickNb = sum(HHDisabledNb, HHChronIllNb). +compute HHSickShare = HHSickNb / HHSizeCalc. +compute MDDI_health2 = (HHSickNb > 1 | HHSickShare > 0.5). execute. -variable labels MDDI_health2 ‘HH with more than half members or more than one member sick’. +variable labels MDDI_health2 "HH with more than half members or more than one member sick". frequencies MDDI_health2. -*** SHELTER DIMENSION +*** SHELTER DIMENSION *** - **Source of energy for cooking - HH uses solid fuels for cooking. -compute MDDI_shelter1= ( HEnerCookSRC=0 | HEnerCookSRC=100 | HEnerCookSRC=102 | HEnerCookSRC=200 | HEnerCookSRC=500 | HEnerCookSRC=600 | HEnerCookSRC=900 | HEnerCookSRC=999) . +* Source of energy for cooking - HH uses solid fuels for cooking +compute MDDI_shelter1 = (HEnerCookSRC = 0 | HEnerCookSRC = 100 | HEnerCookSRC = 102 | HEnerCookSRC = 200 | HEnerCookSRC = 500 | HEnerCookSRC = 600 | HEnerCookSRC = 900 | HEnerCookSRC = 999). execute. -variable labels MDDI_shelter1 ‘HH with no improved energy source for cooking’. +variable labels MDDI_shelter1 "HH with no improved energy source for cooking". frequencies MDDI_shelter1. - **Source of energy for lighting - HH has no electricity. -compute MDDI_shelter2= (HEnerLightSRC<>401 AND HEnerLightSRC<>402) . +* Source of energy for lighting - HH has no electricity +compute MDDI_shelter2 = (HEnerLightSRC <> 401 AND HEnerLightSRC <> 402). execute. -variable labels MDDI_shelter2 ‘HH with no improved source of energy for lighting’. +variable labels MDDI_shelter2 "HH with no improved source of energy for lighting". execute. frequencies MDDI_shelter2. - **Crowding Index - (Number of HH members/Number of rooms (excluding kitchen, corridors))>3 . -compute crowding= HHSizeCalc/HHRoomUsed. -compute MDDI_shelter3= ( crowding > 3). +* Crowding Index - (Number of HH members/Number of rooms (excluding kitchen, corridors)) > 3 +compute crowding = HHSizeCalc / HHRoomUsed. +compute MDDI_shelter3 = (crowding > 3). execute. -variable labels MDDI_shelter3 ‘HH with at least 3 HH members sharing one room to sleep’. - -*** WASH DIMENSION +variable labels MDDI_shelter3 "HH with at least 3 HH members sharing one room to sleep". +frequencies MDDI_shelter3. + +*** WASH DIMENSION *** - **Toilet Type (not-improved facility). -compute MDDI_wash1= ( HToiletType=20100 | HToiletType=20200 | HToiletType=20300 | HToiletType=20400 | HToiletType=20500). +* Toilet Type (not-improved facility) +compute MDDI_wash1 = (HToiletType = 20100 | HToiletType = 20200 | HToiletType = 20300 | HToiletType = 20400 | HToiletType = 20500). execute. -variable labels MDDI_wash1 ‘HH with not improved toilet facility’. +variable labels MDDI_wash1 "HH with not improved toilet facility". frequencies MDDI_wash1. - - **Water source (not-improved source). -compute MDDI_wash2= ( HWaterSRC=500 | HWaterSRC=600 | HWaterSRC=700 | HWaterSRC=800). + +* Water source (not-improved source) +compute MDDI_wash2 = (HWaterSRC = 500 | HWaterSRC = 600 | HWaterSRC = 700 | HWaterSRC = 800). execute. -variable labels MDDI_wash2 'HH with not improved drinking water source'. +variable labels MDDI_wash2 "HH with not improved drinking water source". frequencies MDDI_wash2. - -** SAFETY DIMENSION +*** SAFETY DIMENSION *** - **Safety: HH felt unsafe or suffered violence. -compute MDDI_safety1 = (HHPercSafe=0 OR HHShInsec1Y=1). +* Safety: HH felt unsafe or suffered violence +compute MDDI_safety1 = (HHPercSafe = 0 OR HHShInsec1Y = 1). execute. -variable labels MDDI_safety1 ‘HH with one or more members who felt unsafe or suffered violence’. +variable labels MDDI_safety1 "HH with one or more members who felt unsafe or suffered violence". frequencies MDDI_safety1. - **Displaced by forced in the last 12 months - /*Example of calculating months since arrival (adjust if you already have a variable for the date of data collection and use it instead of ‘interview_date’ variable) - -*Step 1. Create fictitious day of data collection. -string interview_date_str (A10). -compute interview_date_str='25.11.2021'. -compute interview_date=number(interview_date_str, DATE10). +* Displaced by force in the last 12 months +* Example of calculating months since arrival (adjust if you already have a variable for the date of data collection and use it instead of ‘interview_date’ variable) +* Step 1. Create fictitious day of data collection +string interview_date_str (A10). +compute interview_date_str = '25.11.2021'. +compute interview_date = number(interview_date_str, DATE10). execute. -*Step 2. Show current date in date format. -formats interview_date HHHDisplArrive (edate10). +* Step 2. Show current date in date format +formats interview_date HHHDisplArrive (edate10). -*Step 3. Compute the difference. -compute Arrival_time = datediff(interview_date, HHHDisplArrive,'months'). +* Step 3. Compute the difference +compute Arrival_time = datediff(interview_date, HHHDisplArrive, 'months'). execute. -formats Arrival_time (f4). /* don't show decimal places. +formats Arrival_time (f4). /* don't show decimal places -*Step 4. Turn into MDDI variable. -compute MDDI_safety2= (Arrival_time < 13 AND HHDisplChoice=0). -if (HHDispl=0) MDDI_safety2 = 0. /* household not deprived if not displaced. +* Step 4. Turn into MDDI variable +compute MDDI_safety2 = (Arrival_time < 13 AND HHDisplChoice = 0). +if (HHDispl = 0) MDDI_safety2 = 0. /* household not deprived if not displaced execute. frequencies MDDI_safety2. -variable labels MDDI_safety2 ‘HH displaced by force in the last 12 months’. +variable labels MDDI_safety2 "HH displaced by force in the last 12 months". + +*------------------------------------------------------------------------------ +* 2. Calculate deprivation score of each dimension +*------------------------------------------------------------------------------ -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* 2. Calculate deprivation score of each dimension -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -/*Weighting : Method of nesting with equal weights -/* Note: by default if any indicator is missing for a case, its deprivation score for the dimension of that indicator will be missing. -/* Consequently, also MDDI measures will be missing. Be careful with indicators that are missing for many observations (e.g. >10% of the sample). +* Weighting: Method of nesting with equal weights +* Note: by default if any indicator is missing for a case, its deprivation score for the dimension of that indicator will be missing. +* Consequently, also MDDI measures will be missing. Be careful with indicators that are missing for many observations (e.g. >10% of the sample). -compute MDDI_food= (MDDI_food1*1/2)+ (MDDI_food2*1/2). -compute MDDI_edu=MDDI_edu1*1. -compute MDDI_health= (MDDI_health1*1/2)+ (MDDI_health2*1/2). -compute MDDI_shelter=(MDDI_shelter1*1/3)+(MDDI_shelter2*1/3)+ (MDDI_shelter3*1/3). -compute MDDI_wash=(MDDI_wash1*1/2) + (MDDI_wash2*1/2). -compute MDDI_safety= (MDDI_safety1*1/2) + (MDDI_safety2*1/2). +compute MDDI_food = (MDDI_food1 * 1 / 2) + (MDDI_food2 * 1 / 2). +compute MDDI_edu = MDDI_edu1 * 1. +compute MDDI_health = (MDDI_health1 * 1 / 2) + (MDDI_health2 * 1 / 2). +compute MDDI_shelter = (MDDI_shelter1 * 1 / 3) + (MDDI_shelter2 * 1 / 3) + (MDDI_shelter3 * 1 / 3). +compute MDDI_wash = (MDDI_wash1 * 1 / 2) + (MDDI_wash2 * 1 / 2). +compute MDDI_safety = (MDDI_safety1 * 1 / 2) + (MDDI_safety2 * 1 / 2). execute. variable labels -MDDI_food ‘Deprivation score for food dimension’ -MDDI_edu ‘Deprivation score for education dimension’ -MDDI_health ‘Deprivation score for health dimension’ -MDDI_shelter ‘Deprivation score for shelter dimension’ -MDDI_wash ‘Deprivation score for WASH dimension’ -MDDI_safety ‘Deprivation score for safety and displacement dimension’. + MDDI_food "Deprivation score for food dimension" + MDDI_edu "Deprivation score for education dimension" + MDDI_health "Deprivation score for health dimension" + MDDI_shelter "Deprivation score for shelter dimension" + MDDI_wash "Deprivation score for WASH dimension" + MDDI_safety "Deprivation score for safety and displacement dimension". execute. frequencies MDDI_food MDDI_edu MDDI_health MDDI_shelter MDDI_wash MDDI_safety. -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* 3. Calculate MDDI-related measures -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +*------------------------------------------------------------------------------ +* 3. Calculate MDDI-related measures +*------------------------------------------------------------------------------ -*Calculate the overall MDDI Score. -compute MDDI=sum(MDDI_food, MDDI_edu, MDDI_health, MDDI_shelter, MDDI_wash, MDDI_safety)/6. +* Calculate the overall MDDI Score +compute MDDI = sum(MDDI_food, MDDI_edu, MDDI_health, MDDI_shelter, MDDI_wash, MDDI_safety) / 6. execute. -variable labels MDDI ‘MDDI score’. +variable labels MDDI "MDDI score". frequencies MDDI. -*Calculate MDDI Incidence (H) - *Thresholds are 0.50 for severe deprivation and 0.33 for deprivation – it can be adjusted according to the context. -compute MDDI_poor_severe= MDDI GE 0.50. -variable labels MDDI_poor_severe ‘MDDI Incidence – severe deprivation’. +* Calculate MDDI Incidence (H) +* Thresholds are 0.50 for severe deprivation and 0.33 for deprivation – it can be adjusted according to the context +compute MDDI_poor_severe = MDDI GE 0.50. +variable labels MDDI_poor_severe "MDDI Incidence – severe deprivation". execute. compute MDDI_poor = MDDI GE 0.33. -variable labels MDDI_poor ‘MDDI Incidence’. +variable labels MDDI_poor "MDDI Incidence". execute. -Value labels MDDI_poor MDDI_poor_severe - 1 ‘ HH is deprived’ - 0 ‘HH is not deprived’. +value labels MDDI_poor MDDI_poor_severe + 1 "HH is deprived" + 0 "HH is not deprived". +execute. -*Calculate the Average MDDI Intensity (A). -if (MDDI_poor=1) MDDI_intensity=MDDI. /* the variable is missing for non MDDI-poor households. -variable labels MDDI_intensity 'Average MDDI Intensity (A)'. +* Calculate the Average MDDI Intensity (A) +if (MDDI_poor = 1) MDDI_intensity = MDDI. /* the variable is missing for non MDDI-poor households +variable labels MDDI_intensity "Average MDDI Intensity (A)". execute. frequencies MDDI_intensity. -/***Calculate Combined MDDI (M= HxA). -compute MDDI_combined=MDDI_poor*MDDI_intensity. -if (MDDI_poor=0) MDDI_combined=0. -variable labels MDDI_combined ‘Combined MDDI (M)’. +* Calculate Combined MDDI (M = H x A) +compute MDDI_combined = MDDI_poor * MDDI_intensity. +if (MDDI_poor = 0) MDDI_combined = 0. +variable labels MDDI_combined "Combined MDDI (M)". execute. -*Show results. +* Show results descriptives variables = MDDI_poor MDDI_poor_severe MDDI_intensity MDDI_combined -/statistics = mean. - + /statistics = mean. +* End of Scripts \ No newline at end of file diff --git a/Indicators/Nutrition-MAD/nutMAD.do b/Indicators/Nutrition-MAD/nutMAD.do new file mode 100644 index 0000000..de1f185 --- /dev/null +++ b/Indicators/Nutrition-MAD/nutMAD.do @@ -0,0 +1,216 @@ +******************************************************************************** +* WFP Standardized Scripts +* Minimum Acceptable Diet (MAD) Calculation +******************************************************************************** + +* Construction of the Minimum Acceptable Diet (MAD) is based on the +* codebook questions prepared for the MAD module. + +*-------------------------------------------------------------------------------* +* 1. Rename variables to remove group names +*-------------------------------------------------------------------------------* + +rename MAD_submoduleRepeatMADPCMADChildAge_months PCMADChildAge_months +rename MAD_submoduleRepeatMADPCMADBreastfeed PCMADBreastfeed +rename MAD_submoduleRepeatMADPCMADInfFormula PCMADInfFormula +rename MAD_submoduleRepeatMADPCMADInfFormulaNum PCMADInfFormulaNum +rename MAD_submoduleRepeatMADPCMADMilk PCMADMilk +rename MAD_submoduleRepeatMADPCMADMilkNum PCMADMilkNum +rename MAD_submoduleRepeatMADPCMADYogurtDrink PCMADYogurtDrink +rename MAD_submoduleRepeatMADPCMADYogurtDrinkNum PCMADYogurtDrinkNum +rename MAD_submoduleRepeatMADPCMADYogurt PCMADYogurt +rename MAD_submoduleRepeatMADPCMADStapCer PCMADStapCer +rename MAD_submoduleRepeatMADPCMADVegOrg PCMADVegOrg +rename MAD_submoduleRepeatMADPCMADStapRoo PCMADStapRoo +rename MAD_submoduleRepeatMADPCMADVegGre PCMADVegGre +rename MAD_submoduleRepeatMADPCMADVegOth PCMADVegOth +rename MAD_submoduleRepeatMADPCMADFruitOrg PCMADFruitOrg +rename MAD_submoduleRepeatMADPCMADFruitOth PCMADFruitOth +rename MAD_submoduleRepeatMADPCMADPrMeatO PCMADPrMeatO +rename MAD_submoduleRepeatMADPCMADPrMeatPro PCMADPrMeatPro +rename MAD_submoduleRepeatMADPCMADPrMeatF PCMADPrMeatF +rename MAD_submoduleRepeatMADPCMADPrEgg PCMADPrEgg +rename MAD_submoduleRepeatMADPCMADPrFish PCMADPrFish +rename MAD_submoduleRepeatMADPCMADPulse PCMADPulse +rename MAD_submoduleRepeatMADPCMADCheese PCMADCheese +rename MAD_submoduleRepeatMADPCMADSnf PCMADSnf +rename MAD_submoduleRepeatMADPCMADMeals PCMADMeals + +*-------------------------------------------------------------------------------* +* 2. Define variable and value labels +*-------------------------------------------------------------------------------* + +label variable PCMADChildAge_months "What is the age in months of ${PCMADChildName} ?" +label variable PCMADBreastfeed "Was ${PCMADChildName} breastfed yesterday during the day or at night?" +label variable PCMADInfFormula "Infant formula, such as [insert local names of common formula]?" +label variable PCMADInfFormulaNum "How many times did ${PCMADChildName} drink formula?" +label variable PCMADMilk "Milk from animals, such as fresh, tinned or powdered milk?" +label variable PCMADMilkNum "How many times did ${PCMADChildName} drink milk from animals, such as fresh, tinned or powdered milk?" +label variable PCMADYogurtDrink "Yogurt drinks such as [insert local names of common types of yogurt drinks]?" +label variable PCMADYogurtDrinkNum "How many times did ${PCMADChildName} drink Yogurt drinks such as [insert local names of common types of yogurt drinks]?" +label variable PCMADYogurt "Yogurt, other than yogurt drinks?" +label variable PCMADStapCer "Porridge, bread, rice, noodles, pasta or [insert other commonly consumed grains, including foods made from grains like rice dishes, noodle dishes, etc.]?" +label variable PCMADVegOrg "Pumpkin, carrots, sweet red peppers, squash or sweet potatoes that are yellow or orange inside?" +label variable PCMADStapRoo "Plantains, white potatoes, white yams, manioc, cassava or [insert other commonly consumed starchy tubers or starchy tuberous roots that are white or pale inside]?" +label variable PCMADVegGre "Dark green leafy vegetables, such as [insert commonly consumed vitamin A-rich dark green leafy vegetables]?" +label variable PCMADVegOth "Any other vegetables, such as [insert commonly consumed vegetables]?" +label variable PCMADFruitOrg "Ripe mangoes or ripe papayas or [insert other commonly consumed vitamin A-rich fruits]?" +label variable PCMADFruitOth "Any other fruits, such as [insert commonly consumed fruits]?" +label variable PCMADPrMeatO "Liver, kidney, heart or [insert other commonly consumed organ meats]?" +label variable PCMADPrMeatPro "Sausages, hot dogs/frankfurters, ham, bacon, salami, canned meat or [insert other commonly consumed processed meats]?" +label variable PCMADPrMeatF "Any other meat, such as beef, pork, lamb, goat, chicken, duck or [insert other commonly consumed meat]?" +label variable PCMADPrEgg "Eggs" +label variable PCMADPrFish "Fresh or dried fish, shellfish or seafood" +label variable PCMADPulse "Beans, peas, lentils, nuts, seeds or [insert commonly consumed foods made from beans, peas, lentils, nuts, or seeds]?" +label variable PCMADCheese "Hard or soft cheese such as [insert commonly consumed types of cheese]?" +label variable PCMADSnf "Specialized Nutritious Foods (SNF) such as [insert the SNFs distributed by WFP]?" +label variable PCMADMeals "How many times did ${PCMADChildName} eat any solid, semi-solid or soft foods yesterday during the day or night?" + +label define yesno 0 "No" 1 "Yes" 888 "Don't know" +label values PCMADBreastfeed PCMADInfFormula PCMADMilk PCMADYogurtDrink PCMADYogurt PCMADStapCer PCMADVegOrg PCMADStapRoo PCMADVegGre PCMADVegOth PCMADFruitOrg PCMADFruitOth PCMADPrMeatO PCMADPrMeatPro PCMADPrMeatF PCMADPrEgg PCMADPrFish PCMADPulse PCMADCheese PCMADSnf yesno + +*-------------------------------------------------------------------------------* +* 3. Create Minimum Dietary Diversity 6-23 months (MDD) for population assessments +*-------------------------------------------------------------------------------* + +gen MAD_BreastMilk = 0 +replace MAD_BreastMilk = 1 if PCMADBreastfeed == 1 + +gen MAD_PWMDDWStapCer = 0 +replace MAD_PWMDDWStapCer = 1 if PCMADStapCer == 1 | PCMADStapRoo == 1 | PCMADSnf == 1 + +gen MAD_PulsesNutsSeeds = 0 +replace MAD_PulsesNutsSeeds = 1 if PCMADPulse == 1 + +gen MAD_Dairy = 0 +replace MAD_Dairy = 1 if PCMADInfFormula == 1 | PCMADMilk == 1 | PCMADYogurtDrink == 1 | PCMADYogurt == 1 | PCMADCheese == 1 + +gen MAD_MeatFish = 0 +replace MAD_MeatFish = 1 if PCMADPrMeatO == 1 | PCMADPrMeatPro == 1 | PCMADPrMeatF == 1 | PCMADPrFish == 1 + +gen MAD_Eggs = 0 +replace MAD_Eggs = 1 if PCMADPrEgg == 1 + +gen MAD_VitA = 0 +replace MAD_VitA = 1 if PCMADVegOrg == 1 | PCMADVegGre == 1 | PCMADFruitOrg == 1 + +gen MAD_OtherVegFruits = 0 +replace MAD_OtherVegFruits = 1 if PCMADFruitOth == 1 | PCMADVegOth == 1 + +* Add together food groups to see how many food groups consumed +gen MDD_score = MAD_BreastMilk + MAD_PWMDDWStapCer + MAD_PulsesNutsSeeds + MAD_Dairy + MAD_MeatFish + MAD_Eggs + MAD_VitA + MAD_OtherVegFruits + +* Create MDD variable which records whether child consumed five or more food groups +gen MDD = 0 +replace MDD = 1 if MDD_score >= 5 +label variable MDD "Minimum Dietary Diversity (MDD)" +label define MDD_label 0 "Does not meet MDD" 1 "Meets MDD" +label values MDD MDD_label + +*-------------------------------------------------------------------------------* +* 4. Create Minimum Dietary Diversity 6-23 months (MDD) for WFP programme monitoring +*-------------------------------------------------------------------------------* + +gen MAD_BreastMilk_wfp = 0 +replace MAD_BreastMilk_wfp = 1 if PCMADBreastfeed == 1 + +gen MAD_PWMDDWStapCer_wfp = 0 +replace MAD_PWMDDWStapCer_wfp = 1 if PCMADStapCer == 1 | PCMADStapRoo == 1 + +gen MAD_PulsesNutsSeeds_wfp = 0 +replace MAD_PulsesNutsSeeds_wfp = 1 if PCMADPulse == 1 + +gen MAD_Dairy_wfp = 0 +replace MAD_Dairy_wfp = 1 if PCMADInfFormula == 1 | PCMADMilk == 1 | PCMADYogurtDrink == 1 | PCMADYogurt == 1 | PCMADCheese == 1 + +gen MAD_MeatFish_wfp = 0 +replace MAD_MeatFish_wfp = 1 if PCMADPrMeatO == 1 | PCMADPrMeatPro == 1 | PCMADPrMeatF == 1 | PCMADPrFish == 1 | PCMADSnf == 1 + +gen MAD_Eggs_wfp = 0 +replace MAD_Eggs_wfp = 1 if PCMADPrEgg == 1 + +gen MAD_VitA_wfp = 0 +replace MAD_VitA_wfp = 1 if PCMADVegOrg == 1 | PCMADVegGre == 1 | PCMADFruitOrg == 1 + +gen MAD_OtherVegFruits_wfp = 0 +replace MAD_OtherVegFruits_wfp = 1 if PCMADFruitOth == 1 | PCMADVegOth == 1 + +* Add together food groups to see how many food groups consumed +gen MDD_score_wfp = MAD_BreastMilk_wfp + MAD_PWMDDWStapCer_wfp + MAD_PulsesNutsSeeds_wfp + MAD_Dairy_wfp + MAD_MeatFish_wfp + MAD_Eggs_wfp + MAD_VitA_wfp + MAD_OtherVegFruits_wfp + +* Create MDD variable which records whether child consumed five or more food groups +gen MDD_wfp = 0 +replace MDD_wfp = 1 if MDD_score_wfp >= 5 +label variable MDD_wfp "Minimum Dietary Diversity for WFP program monitoring (MDD)" +label define MDD_wfp_label 0 "Does not meet MDD" 1 "Meets MDD" +label values MDD_wfp MDD_wfp_label + +*-------------------------------------------------------------------------------* +* 5. Calculate Minimum Meal Frequency 6-23 months (MMF) +*-------------------------------------------------------------------------------* + +* Recode into new variables turning don't know and missing values into 0 - this makes syntax for calculation simpler +gen PCMADBreastfeed_yn = 0 +replace PCMADBreastfeed_yn = 1 if PCMADBreastfeed == 1 + +gen PCMADMeals_r = 0 +replace PCMADMeals_r = PCMADMeals if inrange(PCMADMeals, 1, 7) + +gen PCMADInfFormulaNum_r = 0 +replace PCMADInfFormulaNum_r = PCMADInfFormulaNum if inrange(PCMADInfFormulaNum, 1, 7) + +gen PCMADMilkNum_r = 0 +replace PCMADMilkNum_r = PCMADMilkNum if inrange(PCMADMilkNum, 1, 7) + +gen PCMADYogurtDrinkNum_r = 0 +replace PCMADYogurtDrinkNum_r = PCMADYogurtDrinkNum if inrange(PCMADYogurtDrinkNum, 1, 7) + +gen MMF = 0 +replace MMF = 1 if PCMADBreastfeed_yn == 1 & inrange(PCMADChildAge_months, 6, 8) & PCMADMeals_r >= 2 +replace MMF = 1 if PCMADBreastfeed_yn == 1 & inrange(PCMADChildAge_months, 9, 23) & PCMADMeals_r >= 3 +replace MMF = 1 if PCMADBreastfeed_yn == 0 & PCMADMeals_r >= 1 & (PCMADMeals_r + PCMADInfFormulaNum_r + PCMADMilkNum_r + PCMADYogurtDrinkNum_r >= 4) + +label variable MMF "Minimum Meal Frequency (MMF)" +label define MMF_label 0 "Does not meet MMF" 1 "Meets MMF" +label values MMF MMF_label + +*-------------------------------------------------------------------------------* +* 6. Calculate Minimum Milk Feeding Frequency for non-breastfed children 6-23 months (MMFF) +*-------------------------------------------------------------------------------* + +gen MMFF = 0 +replace MMFF = 1 if PCMADBreastfeed_yn == 0 & (PCMADInfFormulaNum_r + PCMADMilkNum_r + PCMADYogurtDrinkNum_r >= 2) + +label variable MMFF "Minimum Milk Feeding Frequency for non-breastfed children (MMFF)" +label define MMFF_label 0 "Does not meet MMFF" 1 "Meets MMFF" +label values MMFF MMFF_label + +*-------------------------------------------------------------------------------* +* 7. Calculate Minimum Acceptable Diet (MAD) +*-------------------------------------------------------------------------------* + +* For breastfed infants: if MDD and MMF are both achieved, then MAD is achieved +* For non-breastfed infants: if MDD, MMF and MMFF are all achieved, then MAD is achieved + +* Using MDD for population assessments +gen MAD = 0 +replace MAD = 1 if PCMADBreastfeed_yn == 1 & MDD == 1 & MMF == 1 +replace MAD = 1 if PCMADBreastfeed_yn == 0 & MDD == 1 & MMF == 1 & MMFF == 1 + +* Using MDD for WFP program monitoring +gen MAD_wfp = 0 +replace MAD_wfp = 1 if PCMADBreastfeed_yn == 1 & MDD_wfp == 1 & MMF == 1 +replace MAD_wfp = 1 if PCMADBreastfeed_yn == 0 & MDD_wfp == 1 & MMF == 1 & MMFF == 1 + +label variable MAD "Minimum Acceptable Diet (MAD)" +label define MAD_label 0 "Does not meet MAD" 1 "Meets MAD" +label values MAD MAD_label + +*-------------------------------------------------------------------------------* +* 8. Frequency of MAD +*-------------------------------------------------------------------------------* + +tabulate MAD +tabulate MAD_wfp + +* End of Scripts \ No newline at end of file diff --git a/Indicators/Nutrition-MAD/nutMAD.py b/Indicators/Nutrition-MAD/nutMAD.py new file mode 100644 index 0000000..5400a3d --- /dev/null +++ b/Indicators/Nutrition-MAD/nutMAD.py @@ -0,0 +1,235 @@ +# ------------------------------------------------------------------------------ +# WFP Standardized Scripts +# Minimum Acceptable Diet (MAD) Calculation +# ------------------------------------------------------------------------------ + +# Construction of the Minimum Acceptable Diet (MAD) is based on the +# codebook questions prepared for the MAD module. + +import pandas as pd +import numpy as np + +# Load the dataset +data = pd.read_csv("path_to_your_file/MAD_submodule_RepeatMAD.csv") + +#------------------------------------------------------------------------------- +# 1. Rename variables to remove group names +#------------------------------------------------------------------------------- + +data.rename(columns={ + 'MAD_submodule/RepeatMAD/PCMADChildAge_months': 'PCMADChildAge_months', + 'MAD_submodule/RepeatMAD/PCMADBreastfeed': 'PCMADBreastfeed', + 'MAD_submodule/RepeatMAD/PCMADInfFormula': 'PCMADInfFormula', + 'MAD_submodule/RepeatMAD/PCMADInfFormulaNum': 'PCMADInfFormulaNum', + 'MAD_submodule/RepeatMAD/PCMADMilk': 'PCMADMilk', + 'MAD_submodule/RepeatMAD/PCMADMilkNum': 'PCMADMilkNum', + 'MAD_submodule/RepeatMAD/PCMADYogurtDrink': 'PCMADYogurtDrink', + 'MAD_submodule/RepeatMAD/PCMADYogurtDrinkNum': 'PCMADYogurtDrinkNum', + 'MAD_submodule/RepeatMAD/PCMADYogurt': 'PCMADYogurt', + 'MAD_submodule/RepeatMAD/PCMADStapCer': 'PCMADStapCer', + 'MAD_submodule/RepeatMAD/PCMADVegOrg': 'PCMADVegOrg', + 'MAD_submodule/RepeatMAD/PCMADStapRoo': 'PCMADStapRoo', + 'MAD_submodule/RepeatMAD/PCMADVegGre': 'PCMADVegGre', + 'MAD_submodule/RepeatMAD/PCMADVegOth': 'PCMADVegOth', + 'MAD_submodule/RepeatMAD/PCMADFruitOrg': 'PCMADFruitOrg', + 'MAD_submodule/RepeatMAD/PCMADFruitOth': 'PCMADFruitOth', + 'MAD_submodule/RepeatMAD/PCMADPrMeatO': 'PCMADPrMeatO', + 'MAD_submodule/RepeatMAD/PCMADPrMeatPro': 'PCMADPrMeatPro', + 'MAD_submodule/RepeatMAD/PCMADPrMeatF': 'PCMADPrMeatF', + 'MAD_submodule/RepeatMAD/PCMADPrEgg': 'PCMADPrEgg', + 'MAD_submodule/RepeatMAD/PCMADPrFish': 'PCMADPrFish', + 'MAD_submodule/RepeatMAD/PCMADPulse': 'PCMADPulse', + 'MAD_submodule/RepeatMAD/PCMADCheese': 'PCMADCheese', + 'MAD_submodule/RepeatMAD/PCMADSnf': 'PCMADSnf', + 'MAD_submodule/RepeatMAD/PCMADMeals': 'PCMADMeals' +}, inplace=True) + +#------------------------------------------------------------------------------- +# 2. Define variable and value labels +#------------------------------------------------------------------------------- + +variable_labels = { + 'PCMADChildAge_months': 'What is the age in months of ${PCMADChildName}?', + 'PCMADBreastfeed': 'Was ${PCMADChildName} breastfed yesterday during the day or at night?', + 'PCMADInfFormula': 'Infant formula, such as [insert local names of common formula]?', + 'PCMADInfFormulaNum': 'How many times did ${PCMADChildName} drink formula?', + 'PCMADMilk': 'Milk from animals, such as fresh, tinned or powdered milk?', + 'PCMADMilkNum': 'How many times did ${PCMADChildName} drink milk from animals, such as fresh, tinned or powdered milk?', + 'PCMADYogurtDrink': 'Yogurt drinks such as [insert local names of common types of yogurt drinks]?', + 'PCMADYogurtDrinkNum': 'How many times did ${PCMADChildName} drink Yogurt drinks such as [insert local names of common types of yogurt drinks]?', + 'PCMADYogurt': 'Yogurt, other than yogurt drinks?', + 'PCMADStapCer': 'Porridge, bread, rice, noodles, pasta or [insert other commonly consumed grains, including foods made from grains like rice dishes, noodle dishes, etc.]?', + 'PCMADVegOrg': 'Pumpkin, carrots, sweet red peppers, squash or sweet potatoes that are yellow or orange inside?', + 'PCMADStapRoo': 'Plantains, white potatoes, white yams, manioc, cassava or [insert other commonly consumed starchy tubers or starchy tuberous roots that are white or pale inside]?', + 'PCMADVegGre': 'Dark green leafy vegetables, such as [insert commonly consumed vitamin A-rich dark green leafy vegetables]?', + 'PCMADVegOth': 'Any other vegetables, such as [insert commonly consumed vegetables]?', + 'PCMADFruitOrg': 'Ripe mangoes or ripe papayas or [insert other commonly consumed vitamin A-rich fruits]?', + 'PCMADFruitOth': 'Any other fruits, such as [insert commonly consumed fruits]?', + 'PCMADPrMeatO': 'Liver, kidney, heart or [insert other commonly consumed organ meats]?', + 'PCMADPrMeatPro': 'Sausages, hot dogs/frankfurters, ham, bacon, salami, canned meat or [insert other commonly consumed processed meats]?', + 'PCMADPrMeatF': 'Any other meat, such as beef, pork, lamb, goat, chicken, duck or [insert other commonly consumed meat]?', + 'PCMADPrEgg': 'Eggs', + 'PCMADPrFish': 'Fresh or dried fish, shellfish or seafood', + 'PCMADPulse': 'Beans, peas, lentils, nuts, seeds or [insert commonly consumed foods made from beans, peas, lentils, nuts, or seeds]?', + 'PCMADCheese': 'Hard or soft cheese such as [insert commonly consumed types of cheese]?', + 'PCMADSnf': 'Specialized Nutritious Foods (SNF) such as [insert the SNFs distributed by WFP]?', + 'PCMADMeals': 'How many times did ${PCMADChildName} eat any solid, semi-solid or soft foods yesterday during the day or night?' +} + +value_labels = { + 0: "No", + 1: "Yes", + 888: "Don't know" +} + +for col in data.columns: + if col in variable_labels: + data[col].attrs['label'] = variable_labels[col] + if col in value_labels: + data[col] = data[col].astype('category') + data[col].cat.rename_categories(value_labels, inplace=True) + +#------------------------------------------------------------------------------- +# 3. Create Minimum Dietary Diversity 6-23 months (MDD) for population assessments +#------------------------------------------------------------------------------- + +data['MAD_BreastMilk'] = np.where(data['PCMADBreastfeed'] == 1, 1, 0) +data['MAD_PWMDDWStapCer'] = np.where((data['PCMADStapCer'] == 1) | (data['PCMADStapRoo'] == 1) | (data['PCMADSnf'] == 1), 1, 0) +data['MAD_PulsesNutsSeeds'] = np.where(data['PCMADPulse'] == 1, 1, 0) +data['MAD_Dairy'] = np.where((data['PCMADInfFormula'] == 1) | (data['PCMADMilk'] == 1) | (data['PCMADYogurtDrink'] == 1) | (data['PCMADYogurt'] == 1) | (data['PCMADCheese'] == 1), 1, 0) +data['MAD_MeatFish'] = np.where((data['PCMADPrMeatO'] == 1) | (data['PCMADPrMeatPro'] == 1) | (data['PCMADPrMeatF'] == 1) | (data['PCMADPrFish'] == 1), 1, 0) +data['MAD_Eggs'] = np.where(data['PCMADPrEgg'] == 1, 1, 0) +data['MAD_VitA'] = np.where((data['PCMADVegOrg'] == 1) | (data['PCMADVegGre'] == 1) | (data['PCMADFruitOrg'] == 1), 1, 0) +data['MAD_OtherVegFruits'] = np.where((data['PCMADFruitOth'] == 1) | (data['PCMADVegOth'] == 1), 1, 0) + +# Add together food groups to see how many food groups consumed +data['MDD_score'] = data[['MAD_BreastMilk', 'MAD_PWMDDWStapCer', 'MAD_PulsesNutsSeeds', 'MAD_Dairy', 'MAD_MeatFish', 'MAD_Eggs', 'MAD_VitA', 'MAD_OtherVegFruits']].sum(axis=1) + +# Create MDD variable which records whether child consumed five or more food groups +data['MDD'] = np.where(data['MDD_score'] >= 5, 1, 0) +data['MDD'].attrs['label'] = 'Minimum Dietary Diversity (MDD)' +data['MDD'] = data['MDD'].astype('category') +data['MDD'].cat.rename_categories({ + 0: 'Does not meet MDD', + 1: 'Meets MDD' +}, inplace=True) + +#------------------------------------------------------------------------------- +# 4. Create Minimum Dietary Diversity 6-23 months (MDD) for WFP programme monitoring +#------------------------------------------------------------------------------- + +data['MAD_BreastMilk_wfp'] = np.where(data['PCMADBreastfeed'] == 1, 1, 0) +data['MAD_PWMDDWStapCer_wfp'] = np.where((data['PCMADStapCer'] == 1) | (data['PCMADStapRoo'] == 1), 1, 0) +data['MAD_PulsesNutsSeeds_wfp'] = np.where(data['PCMADPulse'] == 1, 1, 0) +data['MAD_Dairy_wfp'] = np.where((data['PCMADInfFormula'] == 1) | (data['PCMADMilk'] == 1) | (data['PCMADYogurtDrink'] == 1) | (data['PCMADYogurt'] == 1) | (data['PCMADCheese'] == 1), 1, 0) +data['MAD_MeatFish_wfp'] = np.where((data['PCMADPrMeatO'] == 1) | (data['PCMADPrMeatPro'] == 1) | (data['PCMADPrMeatF'] == 1) | (data['PCMADPrFish'] == 1) | (data['PCMADSnf'] == 1), 1, 0) +data['MAD_Eggs_wfp'] = np.where(data['PCMADPrEgg'] == 1, 1, 0) +data['MAD_VitA_wfp'] = np.where((data['PCMADVegOrg'] == 1) | (data['PCMADVegGre'] == 1) | (data['PCMADFruitOrg'] == 1), 1, 0) +data['MAD_OtherVegFruits_wfp'] = np.where((data['PCMADFruitOth'] == 1) | (data['PCMADVegOth'] == 1), 1, 0) + +# Add together food groups to see how many food groups consumed +data['MDD_score_wfp'] = data[['MAD_BreastMilk_wfp', 'MAD_PWMDDWStapCer_wfp', 'MAD_PulsesNutsSeeds_wfp', 'MAD_Dairy_wfp', 'MAD_MeatFish_wfp', 'MAD_Eggs_wfp', 'MAD_VitA_wfp', 'MAD_OtherVegFruits_wfp']].sum(axis=1) + +# Create MDD variable which records whether child consumed five or more food groups +data['MDD_wfp'] = np.where(data['MDD_score_wfp'] >= 5, 1, 0) +data['MDD_wfp'].attrs['label'] = 'Minimum Dietary Diversity for WFP program monitoring (MDD)' +data['MDD_wfp'] = data['MDD_wfp'].astype('category') +data['MDD_wfp'].cat.rename_categories({ + 0: 'Does not meet MDD', + 1: 'Meets MDD' +}, inplace=True) + +#------------------------------------------------------------------------------- +# 5. Calculate Minimum Meal Frequency 6-23 months (MMF) +#------------------------------------------------------------------------------- + +# Recode into new variables turning don't know and missing values into 0 - this makes syntax for calculation simpler +data['PCMADBreastfeed_yn'] = np.where(data['PCMADBreastfeed'] == 1, 1, 0) +data['PCMADMeals_r'] = np.where(data['PCMADMeals'].between(1, 7), data['PCMADMeals'], 0) +data['PCMADInfFormulaNum_r'] = np.where(data['PCMADInfFormulaNum'].between(1, 7), data['PCMADInfFormulaNum'], 0) +data['PCMADMilkNum_r'] = np.where(data['PCMADMilkNum'].between(1, 7), data['PCMADMilkNum'], 0) +data['PCMADYogurtDrinkNum_r'] = np.where(data['PCMADYogurtDrinkNum'].between(1, 7), data['PCMADYogurtDrinkNum'], 0) + +data['MMF'] = np.where( + (data['PCMADBreastfeed_yn'] == 1) & (data['PCMADChildAge_months'].between(6, 8)) & (data['PCMADMeals_r'] >= 2), 1, + np.where( + (data['PCMADBreastfeed_yn'] == 1) & (data['PCMADChildAge_months'].between(9, 23)) & (data['PCMADMeals_r'] >= 3), 1, + np.where( + (data['PCMADBreastfeed_yn'] == 0) & (data['PCMADMeals_r'] >= 1) & (data['PCMADMeals_r'] + data['PCMADInfFormulaNum_r'] + data['PCMADMilkNum_r'] + data['PCMADYogurtDrinkNum_r'] >= 4), 1, + 0 + ) + ) +) + +data['MMF'].attrs['label'] = 'Minimum Meal Frequency (MMF)' +data['MMF'] = data['MMF'].astype('category') +data['MMF'].cat.rename_categories({ + 0: 'Does not meet MMF', + 1: 'Meets MMF' +}, inplace=True) + +#------------------------------------------------------------------------------- +# 6. Calculate Minimum Milk Feeding Frequency for non-breastfed children 6-23 months (MMFF) +#------------------------------------------------------------------------------- + +data['MMFF'] = np.where( + (data['PCMADBreastfeed_yn'] == 0) & (data['PCMADInfFormulaNum_r'] + data['PCMADMilkNum_r'] + data['PCMADYogurtDrinkNum_r'] >= 2), 1, 0 +) + +data['MMFF'].attrs['label'] = 'Minimum Milk Feeding Frequency for non-breastfed children (MMFF)' +data['MMFF'] = data['MMFF'].astype('category') +data['MMFF'].cat.rename_categories({ + 0: 'Does not meet MMFF', + 1: 'Meets MMFF' +}, inplace=True) + +#------------------------------------------------------------------------------- +# 7. Calculate Minimum Acceptable Diet (MAD) +#------------------------------------------------------------------------------- + +# For breastfed infants: if MDD and MMF are both achieved, then MAD is achieved +# For non-breastfed infants: if MDD, MMF and MMFF are all achieved, then MAD is achieved + +# Using MDD for population assessments +data['MAD'] = np.where( + (data['PCMADBreastfeed_yn'] == 1) & (data['MDD'] == 1) & (data['MMF'] == 1), 1, + np.where( + (data['PCMADBreastfeed_yn'] == 0) & (data['MDD'] == 1) & (data['MMF'] == 1) & (data['MMFF'] == 1), 1, 0 + ) +) + +data['MAD'].attrs['label'] = 'Minimum Acceptable Diet (MAD)' +data['MAD'] = data['MAD'].astype('category') +data['MAD'].cat.rename_categories({ + 0: 'Does not meet MAD', + 1: 'Meets MAD' +}, inplace=True) + +# Using MDD for WFP program monitoring +data['MAD_wfp'] = np.where( + (data['PCMADBreastfeed_yn'] == 1) & (data['MDD_wfp'] == 1) & (data['MMF'] == 1), 1, + np.where( + (data['PCMADBreastfeed_yn'] == 0) & (data['MDD_wfp'] == 1) & (data['MMF'] == 1) & (data['MMFF'] == 1), 1, 0 + ) +) + +data['MAD_wfp'].attrs['label'] = 'Minimum Acceptable Diet for WFP program monitoring (MAD)' +data['MAD_wfp'] = data['MAD_wfp'].astype('category') +data['MAD_wfp'].cat.rename_categories({ + 0: 'Does not meet MAD', + 1: 'Meets MAD' +}, inplace=True) + +#------------------------------------------------------------------------------- +# 8. Frequency of MAD +#------------------------------------------------------------------------------- + +mad_freq = data['MAD'].value_counts(normalize=True) * 100 +mad_wfp_freq = data['MAD_wfp'].value_counts(normalize=True) * 100 + +print("Frequency of MAD:") +print(mad_freq) +print("\nFrequency of MAD_wfp:") +print(mad_wfp_freq) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Nutrition-MAD/nutMAD.sps b/Indicators/Nutrition-MAD/nutMAD.sps index e564936..c980014 100644 --- a/Indicators/Nutrition-MAD/nutMAD.sps +++ b/Indicators/Nutrition-MAD/nutMAD.sps @@ -1,15 +1,21 @@ -* Encoding: UTF-8. +*------------------------------------------------------------------------------ +* WFP Standardized Scripts +* Minimum Acceptable Diet (MAD) Calculation +*------------------------------------------------------------------------------ -*can only download repeat csv data as zip file from moda with group names - will update this code to remove group names -*rename to remove group names - because of the variable length SPSS changes name slightly +* Construction of the Minimum Acceptable Diet (MAD) is based on the +* codebook questions prepared for the MAD module. +*-------------------------------------------------------------------------------* +* 1. Rename variables to remove group names +*-------------------------------------------------------------------------------* -RENAME VARIABLES (MAD_submoduleRepeatMADPCMADChildAge_months = PCMADChildAge_months ). -RENAME VARIABLES (MAD_submoduleRepeatMADPCMADBreastfeed = PCMADBreastfeed ). +RENAME VARIABLES (MAD_submoduleRepeatMADPCMADChildAge_months = PCMADChildAge_months). +RENAME VARIABLES (MAD_submoduleRepeatMADPCMADBreastfeed = PCMADBreastfeed). RENAME VARIABLES (MAD_submoduleRepeatMADPCMADInfFormula = PCMADInfFormula). RENAME VARIABLES (MAD_submoduleRepeatMADPCMADInfFormulaNum = PCMADInfFormulaNum). RENAME VARIABLES (MAD_submoduleRepeatMADPCMADMilk = PCMADMilk). -RENAME VARIABLES (MAD_submoduleRepeatMADPCMADMilkNum = PCMADMilkNum). +RENAME VARIABLES (MAD_submoduleRepeatMADPCMADMilkNum = PCMADMilkNum). RENAME VARIABLES (MAD_submoduleRepeatMADPCMADYogurtDrink = PCMADYogurtDrink). RENAME VARIABLES (MAD_submoduleRepeatMADPCMADYogurtDrinkNum = PCMADYogurtDrinkNum). RENAME VARIABLES (MAD_submoduleRepeatMADPCMADYogurt = PCMADYogurt). @@ -30,150 +36,162 @@ RENAME VARIABLES (MAD_submoduleRepeatMADPCMADCheese = PCMADCheese). RENAME VARIABLES (MAD_submoduleRepeatMADPCMADSnf = PCMADSnf). RENAME VARIABLES (MAD_submoduleRepeatMADPCMADMeals = PCMADMeals). -Variable labels PCMADChildAge_months "What is the age in months of ${PCMADChildName} ?" . -Variable labels PCMADBreastfeed "Was ${PCMADChildName} breastfed yesterday during the day or at night?". -Variable labels PCMADInfFormula "Infant formula, such as [insert local names of common formula]?". -Variable labels PCMADInfFormulaNum "How many times did ${PCMADChildName} drink formula". -Variable labels PCMADMilk "Milk from animals, such as fresh, tinned or powdered milk?". -Variable labels PCMADMilkNum "How many times did ${PCMADChildName} drink milk from animals, such as fresh, tinned or powdered milk?". -Variable labels PCMADYogurtDrink "Yogurt drinks such as [insert local names of common types of yogurt drinks]?". -Variable labels PCMADYogurtDrinkNum "How many times did ${PCMADChildName} drink Yogurt drinks such as [insert local names of common types of yogurt drinks]?". -Variable labels PCMADYogurt "Yogurt, other than yogurt drinks ?". -Variable labels PCMADStapCer "Porridge, bread, rice, noodles, pasta or [insert other commonly consumed grains, including foods made from grains like rice dishes, noodle dishes, etc.]?". -Variable labels PCMADVegOrg "Pumpkin, carrots, sweet red peppers, squash or sweet potatoes that are yellow or orange inside? [any additions to this list should meet “Criteria for defining foods and liquids as ‘sources’ of vitamin A”]". -Variable labels PCMADStapRoo "Plantains, white potatoes, white yams, manioc, cassava or [insert other commonly consumed starchy tubers or starchy tuberous roots that are white or pale inside]". -Variable labels PCMADVegGre "Dark green leafy vegetables, such as [insert commonly consumed vitamin A-rich dark green leafy vegetables]?". -Variable labels PCMADVegOth "Any other vegetables, such as [insert commonly consumed vegetables]?". -Variable labels PCMADFruitOrg "Ripe mangoes or ripe papayas or [insert other commonly consumed vitamin A-rich fruits]?". -Variable labels PCMADFruitOth "Any other fruits, such as [insert commonly consumed fruits]?". -Variable labels PCMADPrMeatO "Liver, kidney, heart or [insert other commonly consumed organ meats]?". -Variable labels PCMADPrMeatPro "Sausages, hot dogs/frankfurters, ham, bacon, salami, canned meat or [insert other commonly consumed processed meats]?". -Variable labels PCMADPrMeatF "Any other meat, such as beef, pork, lamb, goat, chicken, duck or [insert other commonly consumed meat]?". -Variable labels PCMADPrEgg "Eggs". -Variable labels PCMADPrFish "Fresh or dried fish, shellfish or seafood". -Variable labels PCMADPulse "Beans, peas, lentils, nuts , seeds or [insert commonly consumed foods made from beans, peas, lentils, nuts, or seeds]?". -Variable labels PCMADCheese "Hard or soft cheese such as [insert commonly consumed types of cheese]?". -Variable labels PCMADSnf "Specialized Nutritious Foods (SNF) such as [insert the SNFs distributed by WFP]?". -Variable labels PCMADMeals "How many times did ${PCMADChildName} eat any solid, semi -solid or soft foods yesterday during the day or night?" . - -Value labels PCMADBreastfeed,PCMADInfFormula,PCMADMilk,PCMADYogurtDrink, PCMADYogurt,PCMADStapCer,PCMADVegOrg,PCMADStapRoo,PCMADVegGre,PCMADVegOth,PCMADFruitOrg, - PCMADFruitOth,PCMADPrMeatO,PCMADPrMeatPro,PCMADPrMeatF,PCMADPrEgg,PCMADPrFish,PCMADPulse,PCMADCheese,PCMADSnf 1 "Yes" 0 "No" 888 "Don't know". - - *Creat Minimum Dietary Diversity 6-23 months (MDD) -* for population assesments - SNF is counted in cereals group (MDD) -*for WFP programme monitoring - SNF is counted in meats group (MDD_wfp) - -*this version of MDD is for population assessments - SNF is counted in cereals group - -Compute MAD_BreastMilk = 0. -if PCMADBreastfeed = 1 MAD_BreastMilk = 1. -Compute MAD_PWMDDWStapCer = 0. -if PCMADStapCer = 1 | PCMADStapRoo = 1 | PCMADSnf = 1 MAD_PWMDDWStapCer= 1. -Compute MAD_PulsesNutsSeeds = 0. -if PCMADPulse = 1 MAD_PulsesNutsSeeds = 1. -Compute MAD_Dairy = 0. -if PCMADInfFormula = 1 | PCMADMilk = 1 | PCMADYogurtDrink = 1 | PCMADYogurt = 1 | PCMADCheese = 1 MAD_Dairy= 1. -Compute MAD_MeatFish = 0. -if PCMADPrMeatO = 1 | PCMADPrMeatPro = 1 | PCMADPrMeatF = 1 | PCMADPrFish = 1 MAD_MeatFish= 1. -Compute MAD_Eggs = 0. -if PCMADPrEgg = 1 MAD_Eggs = 1. -Compute MAD_VitA = 0. -if PCMADVegOrg = 1 | PCMADVegGre = 1 | PCMADFruitOrg = 1 MAD_VitA = 1. -Compute MAD_OtherVegFruits = 0. -if PCMADFruitOth = 1 | PCMADVegOth = 1 MAD_OtherVegFruits= 1. - -*add together food groups to see how many food groups consumed - -compute MDD_score = sum(MAD_BreastMilk,MAD_PWMDDWStapCer,MAD_PulsesNutsSeeds,MAD_Dairy,MAD_MeatFish,MAD_Eggs,MAD_VitA,MAD_OtherVegFruits). - -*create MDD variable which records whether child consumed five or more food groups - -Compute MDD = 0. -if (MDD_score >= 5) MDD = 1. -Variable labels MDD "Minimum Dietary Diversity (MDD)". -Value labels MDD 1 'Meets MDD' 0 'Does not meet MDD'. - -*this version of MDD for WFP programme monitoring - SNF is counted in meats group - -Compute MAD_BreastMilk_wfp = 0. -if PCMADBreastfeed = 1 MAD_BreastMilk_wfp = 1. -Compute MAD_PWMDDWStapCer_wfp = 0. -if PCMADStapCer = 1 | PCMADStapRoo = 1 MAD_PWMDDWStapCer_wfp= 1. -Compute MAD_PulsesNutsSeeds_wfp = 0. -if PCMADPulse = 1 MAD_PulsesNutsSeeds_wfp = 1. -Compute MAD_Dairy_wfp = 0. -if PCMADInfFormula = 1 | PCMADMilk = 1 | PCMADYogurtDrink = 1 | PCMADYogurt = 1 | PCMADCheese = 1 MAD_Dairy_wfp= 1. -Compute MAD_MeatFish_wfp = 0. -if PCMADPrMeatO = 1 | PCMADPrMeatPro = 1 | PCMADPrMeatF = 1 | PCMADPrFish = 1 | PCMADSnf = 1 MAD_MeatFish_wfp= 1. -Compute MAD_Eggs_wfp = 0. -if PCMADPrEgg = 1 MAD_Eggs_wfp = 1. -Compute MAD_VitA_wfp = 0. -if PCMADVegOrg = 1 | PCMADVegGre = 1 | PCMADFruitOrg = 1 MAD_VitA_wfp = 1. -Compute MAD_OtherVegFruits_wfp = 0. -if PCMADFruitOth = 1 | PCMADVegOth = 1 MAD_OtherVegFruits_wfp= 1. - -*add together food groups to see how many food groups consumed - -compute MDD_score_wfp = sum(MAD_BreastMilk_wfp,MAD_PWMDDWStapCer_wfp,MAD_PulsesNutsSeeds_wfp,MAD_Dairy_wfp,MAD_MeatFish_wfp,MAD_Eggs_wfp,MAD_VitA_wfp,MAD_OtherVegFruits_wfp). - -*create MDD variable which records whether child consumed five or more food groups - -Compute MDD_wfp = 0. -if (MDD_score_wfp >= 5) MDD_wfp = 1. -Variable labels MDD_wfp "Minimum Dietary Diversity for WFP program monitoring (MDD)". -Value labels MDD_wfp 1 'Meets MDD' 0 'Does not meet MDD'. - -*Calculate Minimum Meal Frequency 6-23 months (MMF) -*Recode into new variables turning dont know and missing valules into 0 - this makes syntax for calculation simpler - +*-------------------------------------------------------------------------------* +* 2. Define variable and value labels +*-------------------------------------------------------------------------------* + +VARIABLE LABELS + PCMADChildAge_months "What is the age in months of ${PCMADChildName} ?" + PCMADBreastfeed "Was ${PCMADChildName} breastfed yesterday during the day or at night?" + PCMADInfFormula "Infant formula, such as [insert local names of common formula]?" + PCMADInfFormulaNum "How many times did ${PCMADChildName} drink formula?" + PCMADMilk "Milk from animals, such as fresh, tinned or powdered milk?" + PCMADMilkNum "How many times did ${PCMADChildName} drink milk from animals, such as fresh, tinned or powdered milk?" + PCMADYogurtDrink "Yogurt drinks such as [insert local names of common types of yogurt drinks]?" + PCMADYogurtDrinkNum "How many times did ${PCMADChildName} drink Yogurt drinks such as [insert local names of common types of yogurt drinks]?" + PCMADYogurt "Yogurt, other than yogurt drinks?" + PCMADStapCer "Porridge, bread, rice, noodles, pasta or [insert other commonly consumed grains, including foods made from grains like rice dishes, noodle dishes, etc.]?" + PCMADVegOrg "Pumpkin, carrots, sweet red peppers, squash or sweet potatoes that are yellow or orange inside?" + PCMADStapRoo "Plantains, white potatoes, white yams, manioc, cassava or [insert other commonly consumed starchy tubers or starchy tuberous roots that are white or pale inside]?" + PCMADVegGre "Dark green leafy vegetables, such as [insert commonly consumed vitamin A-rich dark green leafy vegetables]?" + PCMADVegOth "Any other vegetables, such as [insert commonly consumed vegetables]?" + PCMADFruitOrg "Ripe mangoes or ripe papayas or [insert other commonly consumed vitamin A-rich fruits]?" + PCMADFruitOth "Any other fruits, such as [insert commonly consumed fruits]?" + PCMADPrMeatO "Liver, kidney, heart or [insert other commonly consumed organ meats]?" + PCMADPrMeatPro "Sausages, hot dogs/frankfurters, ham, bacon, salami, canned meat or [insert other commonly consumed processed meats]?" + PCMADPrMeatF "Any other meat, such as beef, pork, lamb, goat, chicken, duck or [insert other commonly consumed meat]?" + PCMADPrEgg "Eggs" + PCMADPrFish "Fresh or dried fish, shellfish or seafood" + PCMADPulse "Beans, peas, lentils, nuts, seeds or [insert commonly consumed foods made from beans, peas, lentils, nuts, or seeds]?" + PCMADCheese "Hard or soft cheese such as [insert commonly consumed types of cheese]?" + PCMADSnf "Specialized Nutritious Foods (SNF) such as [insert the SNFs distributed by WFP]?" + PCMADMeals "How many times did ${PCMADChildName} eat any solid, semi-solid or soft foods yesterday during the day or night?". + +VALUE LABELS PCMADBreastfeed PCMADInfFormula PCMADMilk PCMADYogurtDrink PCMADYogurt PCMADStapCer PCMADVegOrg PCMADStapRoo PCMADVegGre PCMADVegOth PCMADFruitOrg PCMADFruitOth PCMADPrMeatO PCMADPrMeatPro PCMADPrMeatF PCMADPrEgg PCMADPrFish PCMADPulse PCMADCheese PCMADSnf + 1 "Yes" + 0 "No" + 888 "Don't know". +EXECUTE. + +*-------------------------------------------------------------------------------* +* 3. Create Minimum Dietary Diversity 6-23 months (MDD) for population assessments +*-------------------------------------------------------------------------------* + +COMPUTE MAD_BreastMilk = 0. +IF PCMADBreastfeed = 1 MAD_BreastMilk = 1. +COMPUTE MAD_PWMDDWStapCer = 0. +IF PCMADStapCer = 1 OR PCMADStapRoo = 1 OR PCMADSnf = 1 MAD_PWMDDWStapCer = 1. +COMPUTE MAD_PulsesNutsSeeds = 0. +IF PCMADPulse = 1 MAD_PulsesNutsSeeds = 1. +COMPUTE MAD_Dairy = 0. +IF PCMADInfFormula = 1 OR PCMADMilk = 1 OR PCMADYogurtDrink = 1 OR PCMADYogurt = 1 OR PCMADCheese = 1 MAD_Dairy = 1. +COMPUTE MAD_MeatFish = 0. +IF PCMADPrMeatO = 1 OR PCMADPrMeatPro = 1 OR PCMADPrMeatF = 1 OR PCMADPrFish = 1 MAD_MeatFish = 1. +COMPUTE MAD_Eggs = 0. +IF PCMADPrEgg = 1 MAD_Eggs = 1. +COMPUTE MAD_VitA = 0. +IF PCMADVegOrg = 1 OR PCMADVegGre = 1 OR PCMADFruitOrg = 1 MAD_VitA = 1. +COMPUTE MAD_OtherVegFruits = 0. +IF PCMADFruitOth = 1 OR PCMADVegOth = 1 MAD_OtherVegFruits = 1. + +* Add together food groups to see how many food groups consumed +COMPUTE MDD_score = SUM(MAD_BreastMilk, MAD_PWMDDWStapCer, MAD_PulsesNutsSeeds, MAD_Dairy, MAD_MeatFish, MAD_Eggs, MAD_VitA, MAD_OtherVegFruits). + +* Create MDD variable which records whether child consumed five or more food groups +COMPUTE MDD = 0. +IF MDD_score >= 5 MDD = 1. +VARIABLE LABELS MDD "Minimum Dietary Diversity (MDD)". +VALUE LABELS MDD 1 'Meets MDD' 0 'Does not meet MDD'. +EXECUTE. + +*-------------------------------------------------------------------------------* +* 4. Create Minimum Dietary Diversity 6-23 months (MDD) for WFP programme monitoring +*-------------------------------------------------------------------------------* + +COMPUTE MAD_BreastMilk_wfp = 0. +IF PCMADBreastfeed = 1 MAD_BreastMilk_wfp = 1. +COMPUTE MAD_PWMDDWStapCer_wfp = 0. +IF PCMADStapCer = 1 OR PCMADStapRoo = 1 MAD_PWMDDWStapCer_wfp = 1. +COMPUTE MAD_PulsesNutsSeeds_wfp = 0. +IF PCMADPulse = 1 MAD_PulsesNutsSeeds_wfp = 1. +COMPUTE MAD_Dairy_wfp = 0. +IF PCMADInfFormula = 1 OR PCMADMilk = 1 OR PCMADYogurtDrink = 1 OR PCMADYogurt = 1 OR PCMADCheese = 1 MAD_Dairy_wfp = 1. +COMPUTE MAD_MeatFish_wfp = 0. +IF PCMADPrMeatO = 1 OR PCMADPrMeatPro = 1 OR PCMADPrMeatF = 1 OR PCMADPrFish = 1 OR PCMADSnf = 1 MAD_MeatFish_wfp = 1. +COMPUTE MAD_Eggs_wfp = 0. +IF PCMADPrEgg = 1 MAD_Eggs_wfp = 1. +COMPUTE MAD_VitA_wfp = 0. +IF PCMADVegOrg = 1 OR PCMADVegGre = 1 OR PCMADFruitOrg = 1 MAD_VitA_wfp = 1. +COMPUTE MAD_OtherVegFruits_wfp = 0. +IF PCMADFruitOth = 1 OR PCMADVegOth = 1 MAD_OtherVegFruits_wfp = 1. + +* Add together food groups to see how many food groups consumed +COMPUTE MDD_score_wfp = SUM(MAD_BreastMilk_wfp, MAD_PWMDDWStapCer_wfp, MAD_PulsesNutsSeeds_wfp, MAD_Dairy_wfp, MAD_MeatFish_wfp, MAD_Eggs_wfp, MAD_VitA_wfp, MAD_OtherVegFruits_wfp). + +* Create MDD variable which records whether child consumed five or more food groups +COMPUTE MDD_wfp = 0. +IF MDD_score_wfp >= 5 MDD_wfp = 1. +VARIABLE LABELS MDD_wfp "Minimum Dietary Diversity for WFP program monitoring (MDD)". +VALUE LABELS MDD_wfp 1 'Meets MDD' 0 'Does not meet MDD'. +EXECUTE. + +*-------------------------------------------------------------------------------* +* 5. Calculate Minimum Meal Frequency 6-23 months (MMF) +*-------------------------------------------------------------------------------* + +* Recode into new variables turning don't know and missing values into 0 - this makes syntax for calculation simpler RECODE PCMADBreastfeed (1=1) (ELSE=0) INTO PCMADBreastfeed_yn. -RECODE PCMADMeals (1 thru 7=Copy) (ELSE=0) INTO PCMADMeals_r. -RECODE PCMADInfFormulaNum (1 thru 7=Copy) (ELSE=0) INTO PCMADInfFormulaNum_r. -RECODE PCMADMilkNum (1 thru 7=Copy) (ELSE=0) INTO PCMADMilkNum_r. -RECODE PCMADYogurtDrinkNum (1 thru 7=Copy) (ELSE=0) INTO PCMADYogurtDrinkNum_r. - -Compute MMF = 0. -if PCMADBreastfeed_yn = 1 & (PCMADChildAge_months >= 6 & PCMADChildAge_months <= 8) & PCMADMeals_r >= 2 MMF = 1. -if PCMADBreastfeed_yn = 1 & (PCMADChildAge_months >= 9 & PCMADChildAge_months <= 23) & PCMADMeals_r >= 3 MMF = 1. -if PCMADBreastfeed_yn = 0 & PCMADMeals_r >= 1 & (PCMADMeals_r + PCMADInfFormulaNum_r + PCMADMilkNum_r + PCMADYogurtDrinkNum_r >= 4) MMF = 1. +RECODE PCMADMeals (1 THRU 7=Copy) (ELSE=0) INTO PCMADMeals_r. +RECODE PCMADInfFormulaNum (1 THRU 7=Copy) (ELSE=0) INTO PCMADInfFormulaNum_r. +RECODE PCMADMilkNum (1 THRU 7=Copy) (ELSE=0) INTO PCMADMilkNum_r. +RECODE PCMADYogurtDrinkNum (1 THRU 7=Copy) (ELSE=0) INTO PCMADYogurtDrinkNum_r. -Variable labels MDD_wfp "Minimum Meal Frequency (MMF)". -Value labels MDD_wfp 1 'Meets MMF' 0 'Does not meet MMF'. +COMPUTE MMF = 0. +IF PCMADBreastfeed_yn = 1 AND (PCMADChildAge_months >= 6 AND PCMADChildAge_months <= 8) AND PCMADMeals_r >= 2 MMF = 1. +IF PCMADBreastfeed_yn = 1 AND (PCMADChildAge_months >= 9 AND PCMADChildAge_months <= 23) AND PCMADMeals_r >= 3 MMF = 1. +IF PCMADBreastfeed_yn = 0 AND PCMADMeals_r >= 1 AND (PCMADMeals_r + PCMADInfFormulaNum_r + PCMADMilkNum_r + PCMADYogurtDrinkNum_r >= 4) MMF = 1. -*Calculate Minimum Milk Feeding Frequency for non-breastfed children 6-23 months (MMFF) +VARIABLE LABELS MMF "Minimum Meal Frequency (MMF)". +VALUE LABELS MMF 1 'Meets MMF' 0 'Does not meet MMF'. +EXECUTE. -Compute MMFF = 0. - if PCMADBreastfeed_yn = 0 & (PCMADInfFormulaNum_r + PCMADMilkNum_r + PCMADYogurtDrinkNum_r >= 2) MMFF = 1. +*-------------------------------------------------------------------------------* +* 6. Calculate Minimum Milk Feeding Frequency for non-breastfed children 6-23 months (MMFF) +*-------------------------------------------------------------------------------* -Variable labels MMFF "Minimum Milk Feeding Frequency for non-breastfed children (MMFF)". -Value labels MMFF 1 'Meets MMFF' 0 'Does not meet MMFF'. +COMPUTE MMFF = 0. +IF PCMADBreastfeed_yn = 0 AND (PCMADInfFormulaNum_r + PCMADMilkNum_r + PCMADYogurtDrinkNum_r >= 2) MMFF = 1. +VARIABLE LABELS MMFF "Minimum Milk Feeding Frequency for non-breastfed children (MMFF)". +VALUE LABELS MMFF 1 'Meets MMFF' 0 'Does not meet MMFF'. +EXECUTE. -* Minimum Acceptable Diet (MAD) +*-------------------------------------------------------------------------------* +* 7. Calculate Minimum Acceptable Diet (MAD) +*-------------------------------------------------------------------------------* * For breastfed infants: if MDD and MMF are both achieved, then MAD is achieved -* For nonbreastfed infants: if MDD, MMF and MMFF are all achieved, then MAD is achieved - - -* using MDD for population assesments - -Compute MAD = 0. -if PCMADBreastfeed_yn = 1 & MDD = 1 & MMF = 1 MAD = 1. -if PCMADBreastfeed_yn = 0 & MDD = 1 & MMF = 1 & MMFF = 1 MAD = 1. - - -* using MDD for WFP program monitoring - -Compute MAD = 0. -Compute MAD = 0. -if PCMADBreastfeed_yn = 1 & MDD_wfp = 1 & MMF = 1 MAD = 1. -if PCMADBreastfeed_yn = 0 & MDD_wfp = 1 & MMF = 1 & MMFF = 1 MAD = 1. +* For non-breastfed infants: if MDD, MMF and MMFF are all achieved, then MAD is achieved +* Using MDD for population assessments +COMPUTE MAD = 0. +IF PCMADBreastfeed_yn = 1 AND MDD = 1 AND MMF = 1 MAD = 1. +IF PCMADBreastfeed_yn = 0 AND MDD = 1 AND MMF = 1 AND MMFF = 1 MAD = 1. -Variable labels MAD "Minimum Acceptable Diet (MAD)". -Value labels MAD 1 'Meets MAD' 0 'Does not meet MAD'. +* Using MDD for WFP program monitoring +COMPUTE MAD_wfp = 0. +IF PCMADBreastfeed_yn = 1 AND MDD_wfp = 1 AND MMF = 1 MAD_wfp = 1. +IF PCMADBreastfeed_yn = 0 AND MDD_wfp = 1 AND MMF = 1 AND MMFF = 1 MAD_wfp = 1. -freq MAD. +VARIABLE LABELS MAD "Minimum Acceptable Diet (MAD)". +VALUE LABELS MAD 1 'Meets MAD' 0 'Does not meet MAD'. +EXECUTE. +*-------------------------------------------------------------------------------* +* 8. Frequency of MAD +*-------------------------------------------------------------------------------* +FREQUENCIES VARIABLES=MAD. +FREQUENCIES VARIABLES=MAD_wfp. +* End of Scripts \ No newline at end of file diff --git a/Indicators/Nutrition-MAD/nutMAD_tidyverse.R b/Indicators/Nutrition-MAD/nutMAD_tidyverse.R index ef92ba5..7302aae 100644 --- a/Indicators/Nutrition-MAD/nutMAD_tidyverse.R +++ b/Indicators/Nutrition-MAD/nutMAD_tidyverse.R @@ -1,223 +1,215 @@ +#------------------------------------------------------------------------------ +# WFP Standardized Scripts +# Minimum Acceptable Diet (MAD) Calculation +#------------------------------------------------------------------------------ + +# Construction of the Minimum Acceptable Diet (MAD) is based on the +# codebook questions prepared for the MAD module. + +#-------------------------------------------------------------------------------* +# 1. Rename variables to remove group names +#-------------------------------------------------------------------------------* + library(tidyverse) library(labelled) library(expss) -#add sample data data <- read_csv("~/GitHub/RAMResourcesScripts/Static/Nut_MAD_Sample_Survey/MAD_submodule_RepeatMAD.csv") -#can only download repeat csv data as zip file from moda with group names - will update this code with more elegant solution to remove group names or if you download as SPSS you can skip this step -#rename to remove group names -data <- data %>% rename(PCMADChildAge_months = 'MAD_submodule/RepeatMAD/PCMADChildAge_months', - PCMADBreastfeed = 'MAD_submodule/RepeatMAD/PCMADBreastfeed', - PCMADInfFormula = 'MAD_submodule/RepeatMAD/PCMADInfFormula', - PCMADInfFormulaNum = 'MAD_submodule/RepeatMAD/PCMADInfFormulaNum', - PCMADMilk = 'MAD_submodule/RepeatMAD/PCMADMilk', - PCMADMilkNum = 'MAD_submodule/RepeatMAD/PCMADMilkNum', - PCMADYogurtDrink = 'MAD_submodule/RepeatMAD/PCMADYogurtDrink', - PCMADYogurtDrinkNum = 'MAD_submodule/RepeatMAD/PCMADYogurtDrinkNum', - PCMADYogurt = 'MAD_submodule/RepeatMAD/PCMADYogurt', - PCMADStapCer = 'MAD_submodule/RepeatMAD/PCMADStapCer', - PCMADVegOrg = 'MAD_submodule/RepeatMAD/PCMADVegOrg', - PCMADStapRoo = 'MAD_submodule/RepeatMAD/PCMADStapRoo', - PCMADVegGre = 'MAD_submodule/RepeatMAD/PCMADVegGre', - PCMADVegOth = 'MAD_submodule/RepeatMAD/PCMADVegOth', - PCMADFruitOrg = 'MAD_submodule/RepeatMAD/PCMADFruitOrg', - PCMADFruitOth = 'MAD_submodule/RepeatMAD/PCMADFruitOth', - PCMADPrMeatO = 'MAD_submodule/RepeatMAD/PCMADPrMeatO', - PCMADPrMeatPro = 'MAD_submodule/RepeatMAD/PCMADPrMeatPro', - PCMADPrMeatF = 'MAD_submodule/RepeatMAD/PCMADPrMeatF', - PCMADPrEgg = 'MAD_submodule/RepeatMAD/PCMADPrEgg', - PCMADPrFish = 'MAD_submodule/RepeatMAD/PCMADPrFish', - PCMADPulse = 'MAD_submodule/RepeatMAD/PCMADPulse', - PCMADCheese = 'MAD_submodule/RepeatMAD/PCMADCheese', - PCMADSnf = 'MAD_submodule/RepeatMAD/PCMADSnf', - PCMADMeals = 'MAD_submodule/RepeatMAD/PCMADMeals' - ) - -#assign variable and value labels -var_label(data$PCMADChildAge_months) <- 'What is the age in months of ${PCMADChildName} ?' -var_label(data$PCMADBreastfeed) <- 'Was ${PCMADChildName} breastfed yesterday during the day or at night?' -var_label(data$PCMADInfFormula) <- 'Infant formula, such as [insert local names of common formula]?' -var_label(data$PCMADInfFormulaNum) <- 'How many times did ${PCMADChildName} drink formula' -var_label(data$PCMADMilk) <- 'Milk from animals, such as fresh, tinned or powdered milk?' -var_label(data$PCMADMilkNum) <- 'How many times did ${PCMADChildName} drink milk from animals, such as fresh, tinned or powdered milk?' -var_label(data$PCMADYogurtDrink) <- 'Yogurt drinks such as [insert local names of common types of yogurt drinks]?' -var_label(data$PCMADYogurtDrinkNum) <- 'How many times did ${PCMADChildName} drink Yogurt drinks such as [insert local names of common types of yogurt drinks]?' -var_label(data$PCMADYogurt) <- 'Yogurt, other than yogurt drinks?' -var_label(data$PCMADStapCer) <- 'Porridge, bread, rice, noodles, pasta or [insert other commonly consumed grains, including foods made from grains like rice dishes, noodle dishes, etc.]?' -var_label(data$PCMADVegOrg) <- 'Pumpkin, carrots, sweet red peppers, squash or sweet potatoes that are yellow or orange inside? [any additions to this list should meet “Criteria for defining foods and liquids as ‘sources’ of vitamin A”]' -var_label(data$PCMADStapRoo) <- 'Plantains, white potatoes, white yams, manioc, cassava or [insert other commonly consumed starchy tubers or starchy tuberous roots that are white or pale inside]' -var_label(data$PCMADVegGre) <- 'Dark green leafy vegetables, such as [insert commonly consumed vitamin A-rich dark green leafy vegetables]?' -var_label(data$PCMADVegOth) <- 'Any other vegetables, such as [insert commonly consumed vegetables]?' -var_label(data$PCMADFruitOrg) <- 'Ripe mangoes or ripe papayas or [insert other commonly consumed vitamin A-rich fruits]?' -var_label(data$PCMADFruitOth) <- 'Any other fruits, such as [insert commonly consumed fruits]?' -var_label(data$PCMADPrMeatO) <- 'Liver, kidney, heart or [insert other commonly consumed organ meats]?' -var_label(data$PCMADPrMeatPro) <- 'Sausages, hot dogs/frankfurters, ham, bacon, salami, canned meat or [insert other commonly consumed processed meats]?' -var_label(data$PCMADPrMeatF) <- 'Any other meat, such as beef, pork, lamb, goat, chicken, duck or [insert other commonly consumed meat]?' -var_label(data$PCMADPrEgg) <- 'Eggs' -var_label(data$PCMADPrFish) <- 'Fresh or dried fish, shellfish or seafood' -var_label(data$PCMADPulse) <- 'Beans, peas, lentils, nuts , seeds or [insert commonly consumed foods made from beans, peas, lentils, nuts, or seeds]?' -var_label(data$PCMADCheese) <- 'Hard or soft cheese such as [insert commonly consumed types of cheese]?' -var_label(data$PCMADSnf) <- 'Specialized Nutritious Foods (SNF) such as [insert the SNFs distributed by WFP]?' -var_label(data$PCMADMeals) <- 'How many times did ${PCMADChildName} eat any solid, semi -solid or soft foods yesterday during the day or night?' +data <- data %>% rename( + PCMADChildAge_months = 'MAD_submodule/RepeatMAD/PCMADChildAge_months', + PCMADBreastfeed = 'MAD_submodule/RepeatMAD/PCMADBreastfeed', + PCMADInfFormula = 'MAD_submodule/RepeatMAD/PCMADInfFormula', + PCMADInfFormulaNum = 'MAD_submodule/RepeatMAD/PCMADInfFormulaNum', + PCMADMilk = 'MAD_submodule/RepeatMAD/PCMADMilk', + PCMADMilkNum = 'MAD_submodule/RepeatMAD/PCMADMilkNum', + PCMADYogurtDrink = 'MAD_submodule/RepeatMAD/PCMADYogurtDrink', + PCMADYogurtDrinkNum = 'MAD_submodule/RepeatMAD/PCMADYogurtDrinkNum', + PCMADYogurt = 'MAD_submodule/RepeatMAD/PCMADYogurt', + PCMADStapCer = 'MAD_submodule/RepeatMAD/PCMADStapCer', + PCMADVegOrg = 'MAD_submodule/RepeatMAD/PCMADVegOrg', + PCMADStapRoo = 'MAD_submodule/RepeatMAD/PCMADStapRoo', + PCMADVegGre = 'MAD_submodule/RepeatMAD/PCMADVegGre', + PCMADVegOth = 'MAD_submodule/RepeatMAD/PCMADVegOth', + PCMADFruitOrg = 'MAD_submodule/RepeatMAD/PCMADFruitOrg', + PCMADFruitOth = 'MAD_submodule/RepeatMAD/PCMADFruitOth', + PCMADPrMeatO = 'MAD_submodule/RepeatMAD/PCMADPrMeatO', + PCMADPrMeatPro = 'MAD_submodule/RepeatMAD/PCMADPrMeatPro', + PCMADPrMeatF = 'MAD_submodule/RepeatMAD/PCMADPrMeatF', + PCMADPrEgg = 'MAD_submodule/RepeatMAD/PCMADPrEgg', + PCMADPrFish = 'MAD_submodule/RepeatMAD/PCMADPrFish', + PCMADPulse = 'MAD_submodule/RepeatMAD/PCMADPulse', + PCMADCheese = 'MAD_submodule/RepeatMAD/PCMADCheese', + PCMADSnf = 'MAD_submodule/RepeatMAD/PCMADSnf', + PCMADMeals = 'MAD_submodule/RepeatMAD/PCMADMeals' +) + +#-------------------------------------------------------------------------------* +# 2. Define variable and value labels +#-------------------------------------------------------------------------------* + +var_label(data$PCMADChildAge_months) <- 'What is the age in months of ${PCMADChildName}?' +var_label(data$PCMADBreastfeed) <- 'Was ${PCMADChildName} breastfed yesterday during the day or at night?' +var_label(data$PCMADInfFormula) <- 'Infant formula, such as [insert local names of common formula]?' +var_label(data$PCMADInfFormulaNum) <- 'How many times did ${PCMADChildName} drink formula?' +var_label(data$PCMADMilk) <- 'Milk from animals, such as fresh, tinned or powdered milk?' +var_label(data$PCMADMilkNum) <- 'How many times did ${PCMADChildName} drink milk from animals, such as fresh, tinned or powdered milk?' +var_label(data$PCMADYogurtDrink) <- 'Yogurt drinks such as [insert local names of common types of yogurt drinks]?' +var_label(data$PCMADYogurtDrinkNum) <- 'How many times did ${PCMADChildName} drink Yogurt drinks such as [insert local names of common types of yogurt drinks]?' +var_label(data$PCMADYogurt) <- 'Yogurt, other than yogurt drinks?' +var_label(data$PCMADStapCer) <- 'Porridge, bread, rice, noodles, pasta or [insert other commonly consumed grains, including foods made from grains like rice dishes, noodle dishes, etc.]?' +var_label(data$PCMADVegOrg) <- 'Pumpkin, carrots, sweet red peppers, squash or sweet potatoes that are yellow or orange inside?' +var_label(data$PCMADStapRoo) <- 'Plantains, white potatoes, white yams, manioc, cassava or [insert other commonly consumed starchy tubers or starchy tuberous roots that are white or pale inside]?' +var_label(data$PCMADVegGre) <- 'Dark green leafy vegetables, such as [insert commonly consumed vitamin A-rich dark green leafy vegetables]?' +var_label(data$PCMADVegOth) <- 'Any other vegetables, such as [insert commonly consumed vegetables]?' +var_label(data$PCMADFruitOrg) <- 'Ripe mangoes or ripe papayas or [insert other commonly consumed vitamin A-rich fruits]?' +var_label(data$PCMADFruitOth) <- 'Any other fruits, such as [insert commonly consumed fruits]?' +var_label(data$PCMADPrMeatO) <- 'Liver, kidney, heart or [insert other commonly consumed organ meats]?' +var_label(data$PCMADPrMeatPro) <- 'Sausages, hot dogs/frankfurters, ham, bacon, salami, canned meat or [insert other commonly consumed processed meats]?' +var_label(data$PCMADPrMeatF) <- 'Any other meat, such as beef, pork, lamb, goat, chicken, duck or [insert other commonly consumed meat]?' +var_label(data$PCMADPrEgg) <- 'Eggs' +var_label(data$PCMADPrFish) <- 'Fresh or dried fish, shellfish or seafood' +var_label(data$PCMADPulse) <- 'Beans, peas, lentils, nuts, seeds or [insert commonly consumed foods made from beans, peas, lentils, nuts, or seeds]?' +var_label(data$PCMADCheese) <- 'Hard or soft cheese such as [insert commonly consumed types of cheese]?' +var_label(data$PCMADSnf) <- 'Specialized Nutritious Foods (SNF) such as [insert the SNFs distributed by WFP]?' +var_label(data$PCMADMeals) <- 'How many times did ${PCMADChildName} eat any solid, semi-solid or soft foods yesterday during the day or night?' data <- data %>% - mutate(across(c(PCMADBreastfeed,PCMADInfFormula,PCMADMilk,PCMADYogurtDrink, PCMADYogurt,PCMADStapCer,PCMADVegOrg,PCMADStapRoo,PCMADVegGre,PCMADVegOth,PCMADFruitOrg, - PCMADFruitOth,PCMADPrMeatO,PCMADPrMeatPro,PCMADPrMeatF,PCMADPrEgg,PCMADPrFish,PCMADPulse,PCMADCheese,PCMADSnf), ~labelled(., labels = c( - "No" = 0, - "Yes" = 1, - "Don't know" = 888 - )))) + mutate(across(c(PCMADBreastfeed, PCMADInfFormula, PCMADMilk, PCMADYogurtDrink, PCMADYogurt, PCMADStapCer, PCMADVegOrg, PCMADStapRoo, PCMADVegGre, PCMADVegOth, PCMADFruitOrg, + PCMADFruitOth, PCMADPrMeatO, PCMADPrMeatPro, PCMADPrMeatF, PCMADPrEgg, PCMADPrFish, PCMADPulse, PCMADCheese, PCMADSnf), + ~labelled(., labels = c( + "No" = 0, + "Yes" = 1, + "Don't know" = 888 + )))) + +#-------------------------------------------------------------------------------* +# 3. Create Minimum Dietary Diversity 6-23 months (MDD) for population assessments +#-------------------------------------------------------------------------------* +data <- data %>% mutate( + MAD_BreastMilk = if_else(PCMADBreastfeed == 1, 1, 0), + MAD_PWMDDWStapCer = if_else(PCMADStapCer == 1 | PCMADStapRoo == 1 | PCMADSnf == 1, 1, 0), + MAD_PulsesNutsSeeds = if_else(PCMADPulse == 1, 1, 0), + MAD_Dairy = if_else(PCMADInfFormula == 1 | PCMADMilk == 1 | PCMADYogurtDrink == 1 | PCMADYogurt == 1 | PCMADCheese == 1, 1, 0), + MAD_MeatFish = if_else(PCMADPrMeatO == 1 | PCMADPrMeatPro == 1 | PCMADPrMeatF == 1 | PCMADPrFish == 1, 1, 0), + MAD_Eggs = if_else(PCMADPrEgg == 1, 1, 0), + MAD_VitA = if_else(PCMADVegOrg == 1 | PCMADVegGre == 1 | PCMADFruitOrg == 1, 1, 0), + MAD_OtherVegFruits = if_else(PCMADFruitOth == 1 | PCMADVegOth == 1, 1, 0) +) -#Creat Minimum Dietary Diversity 6-23 months (MDD) -# for population assesments - SNF is counted in cereals group (MDD) -# for WFP programme monitoring - SNF is counted in meats group (MDD_wfp) +# Add together food groups to see how many food groups consumed +data <- data %>% mutate(MDD_score = MAD_BreastMilk + MAD_PWMDDWStapCer + MAD_PulsesNutsSeeds + MAD_Dairy + MAD_MeatFish + MAD_Eggs + MAD_VitA + MAD_OtherVegFruits) -#this version is for population assessments - SNF is counted in cereals group -data <- data %>% mutate( - MAD_BreastMilk = case_when( - PCMADBreastfeed == 1 ~ 1, TRUE ~ 0), - MAD_PWMDDWStapCer = case_when( - PCMADStapCer == 1 | PCMADStapRoo == 1 | PCMADSnf == 1 ~ 1, TRUE ~ 0), - MAD_PulsesNutsSeeds = case_when( - PCMADPulse == 1 ~ 1, TRUE ~ 0), - MAD_Dairy = case_when( - PCMADInfFormula == 1 | PCMADMilk == 1 | PCMADYogurtDrink == 1 | PCMADYogurt == 1 | PCMADCheese == 1 ~ 1, TRUE ~ 0), - MAD_MeatFish = case_when( - PCMADPrMeatO == 1 | PCMADPrMeatPro == 1 | PCMADPrMeatF == 1 | PCMADPrFish == 1 ~ 1, TRUE ~ 0), - MAD_Eggs = case_when( - PCMADPrEgg == 1 ~ 1, TRUE ~ 0), - MAD_VitA = case_when( - PCMADVegOrg == 1 | PCMADVegGre == 1 | PCMADFruitOrg == 1 ~ 1, TRUE ~ 0), - MAD_OtherVegFruits = case_when( - PCMADFruitOth == 1 | PCMADVegOth == 1 ~ 1, TRUE ~ 0) - ) -#add together food groups to see how many food groups consumed -data <- data %>% mutate(MDD_score = MAD_BreastMilk +MAD_PWMDDWStapCer +MAD_PulsesNutsSeeds +MAD_Dairy +MAD_MeatFish +MAD_Eggs +MAD_VitA +MAD_OtherVegFruits) -#create MDD variable which records whether child consumed five or more food groups -data <- data %>% mutate(MDD = case_when( - MDD_score >= 5 ~ 1, TRUE ~ 0)) +# Create MDD variable which records whether child consumed five or more food groups +data <- data %>% mutate(MDD = if_else(MDD_score >= 5, 1, 0)) var_label(data$MDD) <- 'Minimum Dietary Diversity (MDD)' val_lab(data$MDD) = num_lab(" - 0 Does not meet MDD - 1 Meets MDD + 0 'Does not meet MDD' + 1 'Meets MDD' ") -##this version for WFP programme monitoring - SNF is counted in meats group +#-------------------------------------------------------------------------------* +# 4. Create Minimum Dietary Diversity 6-23 months (MDD) for WFP programme monitoring +#-------------------------------------------------------------------------------* + data <- data %>% mutate( - MAD_BreastMilk_wfp = case_when( - PCMADBreastfeed == 1 ~ 1, TRUE ~ 0), - MAD_PWMDDWStapCer_wfp = case_when( - PCMADStapCer == 1 | PCMADStapRoo == 1 ~ 1, TRUE ~ 0), - MAD_PulsesNutsSeeds_wfp = case_when( - PCMADPulse == 1 ~ 1, TRUE ~ 0), - MAD_Dairy_wfp = case_when( - PCMADInfFormula == 1 | PCMADMilk == 1 | PCMADYogurtDrink == 1 | PCMADYogurt == 1 | PCMADCheese == 1 ~ 1, TRUE ~ 0), - MAD_MeatFish_wfp = case_when( - PCMADPrMeatO == 1 | PCMADPrMeatPro == 1 | PCMADPrMeatF == 1 | PCMADPrFish == 1 | PCMADSnf == 1 ~ 1, TRUE ~ 0), - MAD_Eggs_wfp = case_when( - PCMADPrEgg == 1 ~ 1, TRUE ~ 0), - MAD_VitA_wfp = case_when( - PCMADVegOrg == 1 | PCMADVegGre == 1 | PCMADFruitOrg == 1 ~ 1, TRUE ~ 0), - MAD_OtherVegFruits_wfp = case_when( - PCMADFruitOth == 1 | PCMADVegOth == 1 ~ 1, TRUE ~ 0) + MAD_BreastMilk_wfp = if_else(PCMADBreastfeed == 1, 1, 0), + MAD_PWMDDWStapCer_wfp = if_else(PCMADStapCer == 1 | PCMADStapRoo == 1, 1, 0), + MAD_PulsesNutsSeeds_wfp = if_else(PCMADPulse == 1, 1, 0), + MAD_Dairy_wfp = if_else(PCMADInfFormula == 1 | PCMADMilk == 1 | PCMADYogurtDrink == 1 | PCMADYogurt == 1 | PCMADCheese == 1, 1, 0), + MAD_MeatFish_wfp = if_else(PCMADPrMeatO == 1 | PCMADPrMeatPro == 1 | PCMADPrMeatF == 1 | PCMADPrFish == 1 | PCMADSnf == 1, 1, 0), + MAD_Eggs_wfp = if_else(PCMADPrEgg == 1, 1, 0), + MAD_VitA_wfp = if_else(PCMADVegOrg == 1 | PCMADVegGre == 1 | PCMADFruitOrg == 1, 1, 0), + MAD_OtherVegFruits_wfp = if_else(PCMADFruitOth == 1 | PCMADVegOth == 1, 1, 0) ) -#add together food groups to see how many food groups consumed -data <- data %>% mutate(MDD_score_wfp = MAD_BreastMilk_wfp +MAD_PWMDDWStapCer_wfp +MAD_PulsesNutsSeeds_wfp +MAD_Dairy_wfp +MAD_MeatFish_wfp +MAD_Eggs_wfp +MAD_VitA_wfp +MAD_OtherVegFruits_wfp) -#create MDD variable which records whether child consumed five or more food groups -data <- data %>% mutate(MDD_wfp = case_when( - MDD_score_wfp >= 5 ~ 1, TRUE ~ 0)) + +# Add together food groups to see how many food groups consumed +data <- data %>% mutate(MDD_score_wfp = MAD_BreastMilk_wfp + MAD_PWMDDWStapCer_wfp + MAD_PulsesNutsSeeds_wfp + MAD_Dairy_wfp + MAD_MeatFish_wfp + MAD_Eggs_wfp + MAD_VitA_wfp + MAD_OtherVegFruits_wfp) + +# Create MDD variable which records whether child consumed five or more food groups +data <- data %>% mutate(MDD_wfp = if_else(MDD_score_wfp >= 5, 1, 0)) var_label(data$MDD_wfp) <- 'Minimum Dietary Diversity for WFP program monitoring (MDD)' val_lab(data$MDD_wfp) = num_lab(" - 0 Does not meet MDD - 1 Meets MDD + 0 'Does not meet MDD' + 1 'Meets MDD' ") +#-------------------------------------------------------------------------------* +# 5. Calculate Minimum Meal Frequency 6-23 months (MMF) +#-------------------------------------------------------------------------------* -table(data$MDD) -table(data$MDD_wfp) - -#Calculate Minimum Meal Frequency 6-23 months (MMF) - -#Recode into new variables turning dont know and missing valules into 0 - this makes syntax for calculation simpler - -data <- data %>% mutate(PCMADBreastfeed_yn = case_when( - PCMADBreastfeed == 1 ~ 1, TRUE ~ 0), - PCMADMeals_r = case_when( - between(PCMADMeals,1,7) == 1 ~ PCMADMeals, TRUE ~ 0), - PCMADInfFormulaNum_r = case_when( - between(PCMADInfFormulaNum,1,7) == 1 ~ PCMADInfFormulaNum, TRUE ~ 0), - PCMADMilkNum_r = case_when( - between(PCMADMilkNum,1,7) == 1 ~ PCMADMilkNum, TRUE ~ 0), - PCMADYogurtDrinkNum_r = case_when( - between(PCMADYogurtDrinkNum,1,7) == 1 ~ PCMADYogurtDrinkNum, TRUE ~ 0) - ) +# Recode into new variables turning don't know and missing values into 0 - this makes syntax for calculation simpler +data <- data %>% mutate( + PCMADBreastfeed_yn = if_else(PCMADBreastfeed == 1, 1, 0), + PCMADMeals_r = if_else(between(PCMADMeals, 1, 7), PCMADMeals, 0), + PCMADInfFormulaNum_r = if_else(between(PCMADInfFormulaNum, 1, 7), PCMADInfFormulaNum, 0), + PCMADMilkNum_r = if_else(between(PCMADMilkNum, 1, 7), PCMADMilkNum, 0), + PCMADYogurtDrinkNum_r = if_else(between(PCMADYogurtDrinkNum, 1, 7), PCMADYogurtDrinkNum, 0) +) data <- data %>% mutate(MMF = case_when( - PCMADBreastfeed_yn == 1 & between(PCMADChildAge_months,6,8) & (PCMADMeals_r >= 2) ~ 1, #for child breast fed yesterday - between 6 - 8 months minimum number of meals is 2 - PCMADBreastfeed_yn == 1 & between(PCMADChildAge_months,9,23) & (PCMADMeals_r >= 3) ~ 1, #for child breast fed yesterday - for children above 8 months minimum number of meals is 3 - #for child non breast fed regardless of age , child must have had 1 or more meal of solid/semisolid/soft food and child had 4 or more liquid + solid/semisolid/soft meals - PCMADBreastfeed_yn == 0 & (PCMADMeals_r >= 1) & (PCMADMeals_r + PCMADInfFormulaNum_r + PCMADMilkNum_r + PCMADYogurtDrinkNum_r >= 4) ~ 1, - TRUE ~ 0) -) + PCMADBreastfeed_yn == 1 & between(PCMADChildAge_months, 6, 8) & PCMADMeals_r >= 2 ~ 1, + PCMADBreastfeed_yn == 1 & between(PCMADChildAge_months, 9, 23) & PCMADMeals_r >= 3 ~ 1, + PCMADBreastfeed_yn == 0 & PCMADMeals_r >= 1 & (PCMADMeals_r + PCMADInfFormulaNum_r + PCMADMilkNum_r + PCMADYogurtDrinkNum_r >= 4) ~ 1, + TRUE ~ 0 +)) var_label(data$MMF) <- 'Minimum Meal Frequency (MMF)' val_lab(data$MMF) = num_lab(" - 0 Does not meet MMF - 1 Meets MMF + 0 'Does not meet MMF' + 1 'Meets MMF' ") -#Calculate Minimum Milk Feeding Frequency for non-breastfed children 6-23 months (MMFF) +#-------------------------------------------------------------------------------* +# 6. Calculate Minimum Milk Feeding Frequency for non-breastfed children 6-23 months (MMFF) +#-------------------------------------------------------------------------------* data <- data %>% mutate(MMFF = case_when( - PCMADBreastfeed_yn == 0 & (PCMADInfFormulaNum_r + PCMADMilkNum_r + PCMADYogurtDrinkNum_r >= 2) ~ 1, - TRUE ~ 0) -) - + PCMADBreastfeed_yn == 0 & (PCMADInfFormulaNum_r + PCMADMilkNum_r + PCMADYogurtDrinkNum_r >= 2) ~ 1, + TRUE ~ 0 +)) + var_label(data$MMFF) <- 'Minimum Milk Feeding Frequency for non-breastfed children (MMFF)' val_lab(data$MMFF) = num_lab(" - 0 Does not meet MMFF - 1 Meets MMFF + 0 'Does not meet MMFF' + 1 'Meets MMFF' ") +#-------------------------------------------------------------------------------* +# 7. Calculate Minimum Acceptable Diet (MAD) +#-------------------------------------------------------------------------------* -# Minimum Acceptable Diet (MAD) - -#For breastfed infants: if MDD and MMF are both achieved, then MAD is achieved -#For nonbreastfed infants: if MDD, MMF and MMFF are all achieved, then MAD is achieved +# For breastfed infants: if MDD and MMF are both achieved, then MAD is achieved +# For non-breastfed infants: if MDD, MMF and MMFF are all achieved, then MAD is achieved - -#using MDD for population assesments +# Using MDD for population assessments data <- data %>% mutate(MAD = case_when( - PCMADBreastfeed_yn == 1 & MDD == 1 & MMF == 1 ~ 1, - PCMADBreastfeed_yn == 0 & MDD == 1 & MMF == 1 & MMFF == 1 ~ 1, - TRUE ~ 0)) + PCMADBreastfeed_yn == 1 & MDD == 1 & MMF == 1 ~ 1, + PCMADBreastfeed_yn == 0 & MDD == 1 & MMF == 1 & MMFF == 1 ~ 1, + TRUE ~ 0 +)) -#using MDD for WFP program monitoring -data <- data %>% mutate(MAD = case_when( +# Using MDD for WFP program monitoring +data <- data %>% mutate(MAD_wfp = case_when( PCMADBreastfeed_yn == 1 & MDD_wfp == 1 & MMF == 1 ~ 1, PCMADBreastfeed_yn == 0 & MDD_wfp == 1 & MMF == 1 & MMFF == 1 ~ 1, - TRUE ~ 0)) + TRUE ~ 0 +)) var_label(data$MAD) <- 'Minimum Acceptable Diet (MAD)' val_lab(data$MAD) = num_lab(" - 0 Does not meet MAD - 1 Meets MAD + 0 'Does not meet MAD' + 1 'Meets MAD' ") +#-------------------------------------------------------------------------------* +# 8. Frequency of MAD +#-------------------------------------------------------------------------------* -#creates a table of the weighted percentage of MAD -#and providing the option to use weights if needed +table(data$MAD) +table(data$MAD_wfp) -MAD_table_wide <- data %>% - drop_na(MAD) %>% - count(MAD) %>% # if weights are needed use instead the row below - #count(MAD, wt = nameofweightvariable) - mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = MAD, - values_from = Percentage, - values_fill = 0) +# End of Scripts \ No newline at end of file diff --git a/Indicators/Nutrition-MDDW/nutMDDW_tidyverse.R b/Indicators/Nutrition-MDDW/nutMDDW-calculation-tidyverse.R similarity index 98% rename from Indicators/Nutrition-MDDW/nutMDDW_tidyverse.R rename to Indicators/Nutrition-MDDW/nutMDDW-calculation-tidyverse.R index 3197dce..e11d614 100644 --- a/Indicators/Nutrition-MDDW/nutMDDW_tidyverse.R +++ b/Indicators/Nutrition-MDDW/nutMDDW-calculation-tidyverse.R @@ -15,7 +15,7 @@ library(expss) # Load Sample Data ------------------------------------------------------------# -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/Nut_MDDW/Nutrition_module_MDD_W_submodule_RepeatMDDW.csv") +#data <- read_csv("~/GitHub/RAMResourcesScripts/Static/Nut_MDDW/Nutrition_module_MDD_W_submodule_RepeatMDDW.csv") # Rename MDDW relevant variables ----------------------------------------------# diff --git a/Indicators/Nutrition-MDDW/nutMDDW.do b/Indicators/Nutrition-MDDW/nutMDDW-calculation.do similarity index 94% rename from Indicators/Nutrition-MDDW/nutMDDW.do rename to Indicators/Nutrition-MDDW/nutMDDW-calculation.do index ace5c0b..8d90e3f 100644 --- a/Indicators/Nutrition-MDDW/nutMDDW.do +++ b/Indicators/Nutrition-MDDW/nutMDDW-calculation.do @@ -1,14 +1,15 @@ ******************************************************************************** -* Minimum Dietary Diversity for Women (MDDW) +* WFP Standardized Scripts +* . Calculating Minimum Dietary Diversity for Women (MDDW) *******************************************************************************/ ** Load data * --------- - import delim using "../Nutrition_module_MDD_W_submodule_RepeatMDDW.csv", /// - clear case(preserve) +* import delim using "../Nutrition_module_MDD_W_submodule_RepeatMDDW.csv", /// +* clear case(preserve) ** rename varuavke to remove group names - ren Nutrition_moduleMDD_W_submoduleRepeatMDDW* * + cap ren Nutrition_moduleMDD_W_submoduleRepeatMDDW* * ** check and recode missing values as 0 sum PWMDDW* @@ -112,4 +113,4 @@ tab MDDW_5_wfp, d -* End of dofile +* End of Scripts \ No newline at end of file diff --git a/Indicators/Nutrition-MDDW/nutMDDW-calculation.py b/Indicators/Nutrition-MDDW/nutMDDW-calculation.py new file mode 100644 index 0000000..e295951 --- /dev/null +++ b/Indicators/Nutrition-MDDW/nutMDDW-calculation.py @@ -0,0 +1,164 @@ +#------------------------------------------------------------------------------# +# WFP RAM Standardized Scripts +# Calculating and Summarising MDDW +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# + +import pandas as pd +import numpy as np + +# Load Sample Data ------------------------------------------------------------# + +# Replace with the path to your CSV file +#df = pd.read_csv("Nutrition_module_MDD_W_submodule_RepeatMDDW.csv") + +# Rename MDDW relevant variables ----------------------------------------------# + +df = df.rename(columns={ + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWStapCer': 'PWMDDWStapCer', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWStapRoo': 'PWMDDWStapRoo', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPulse': 'PWMDDWPulse', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWNuts': 'PWMDDWNuts', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWMilk': 'PWMDDWMilk', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWDairy': 'PWMDDWDairy', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrMeatO': 'PWMDDWPrMeatO', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrMeatF': 'PWMDDWPrMeatF', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrMeatPro': 'PWMDDWPrMeatPro', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrMeatWhite': 'PWMDDWPrMeatWhite', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrFish': 'PWMDDWPrFish', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrEgg': 'PWMDDWPrEgg', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWVegGre': 'PWMDDWVegGre', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWVegOrg': 'PWMDDWVegOrg', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFruitOrg': 'PWMDDWFruitOrg', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWVegOth': 'PWMDDWVegOth', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFruitOth': 'PWMDDWFruitOth', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWSnf': 'PWMDDWSnf', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodoil': 'PWMDDWFortFoodoil', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodwflour': 'PWMDDWFortFoodwflour', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodmflour': 'PWMDDWFortFoodmflour', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodrice': 'PWMDDWFortFoodrice', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFooddrink': 'PWMDDWFortFooddrink', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodother': 'PWMDDWFortFoodother', + 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodother_oth': 'PWMDDWFortFoodother_oth' +}) + +# Label MDDW relevant variables -----------------------------------------------# + +labels = { + 'PWMDDWStapCer': "Foods made from grains", + 'PWMDDWStapRoo': "White roots and tubers or plantains", + 'PWMDDWPulse': "Pulses (beans, peas and lentils)", + 'PWMDDWNuts': "Nuts and seeds", + 'PWMDDWMilk': "Milk", + 'PWMDDWDairy': "Milk products", + 'PWMDDWPrMeatO': "Organ meats", + 'PWMDDWPrMeatF': "Red flesh meat from mammals", + 'PWMDDWPrMeatPro': "Processed meat", + 'PWMDDWPrMeatWhite': "Poultry and other white meats", + 'PWMDDWPrFish': "Fish and Seafood", + 'PWMDDWPrEgg': "Eggs from poultry or any other bird", + 'PWMDDWVegGre': "Dark green leafy vegetable", + 'PWMDDWVegOrg': "Vitamin A-rich vegetables, roots and tubers", + 'PWMDDWFruitOrg': "Vitamin A-rich fruits", + 'PWMDDWVegOth': "Other vegetables", + 'PWMDDWFruitOth': "Other fruits", + 'PWMDDWSnf': "Specialized Nutritious Foods (SNF) for women", + 'PWMDDWFortFoodoil': "Fortified oil", + 'PWMDDWFortFoodwflour': "Fortified wheat flour", + 'PWMDDWFortFoodmflour': "Fortified maize flour", + 'PWMDDWFortFoodrice': "Fortified Rice", + 'PWMDDWFortFooddrink': "Fortified drink", + 'PWMDDWFortFoodother': "Other:", + 'PWMDDWFortFoodother_oth': "Other: please specify: ____________" +} + +# Convert to binary (0/1) based on "Yes"/"No" responses +binary_columns = [ + 'PWMDDWStapCer', 'PWMDDWStapRoo', 'PWMDDWPulse', 'PWMDDWNuts', + 'PWMDDWMilk', 'PWMDDWDairy', 'PWMDDWPrMeatO', 'PWMDDWPrMeatF', + 'PWMDDWPrMeatPro', 'PWMDDWPrMeatWhite', 'PWMDDWPrFish', 'PWMDDWPrEgg', + 'PWMDDWVegGre', 'PWMDDWVegOrg', 'PWMDDWFruitOrg', 'PWMDDWVegOth', + 'PWMDDWFruitOth', 'PWMDDWSnf', 'PWMDDWFortFoodoil', 'PWMDDWFortFoodwflour', + 'PWMDDWFortFoodmflour', 'PWMDDWFortFoodrice', 'PWMDDWFortFooddrink', + 'PWMDDWFortFoodother' +] + +df[binary_columns] = df[binary_columns].apply(lambda x: pd.to_numeric(x.replace({"No": 0, "Yes": 1}))) + +# Calculate MDDW indicators -------------------------------------------------# + +# Standard MDDW method - SNF in grains +df['MDDW_Staples'] = ((df['PWMDDWStapCer'] == 1) | (df['PWMDDWStapRoo'] == 1) | + (df['PWMDDWSnf'] == 1) | (df['PWMDDWFortFoodwflour'] == 1) | + (df['PWMDDWFortFoodmflour'] == 1) | (df['PWMDDWFortFoodrice'] == 1) | + (df['PWMDDWFortFooddrink'] == 1)).astype(int) + +df['MDDW_Pulses'] = (df['PWMDDWPulse'] == 1).astype(int) +df['MDDW_NutsSeeds'] = (df['PWMDDWNuts'] == 1).astype(int) +df['MDDW_Dairy'] = ((df['PWMDDWDairy'] == 1) | (df['PWMDDWMilk'] == 1)).astype(int) +df['MDDW_MeatFish'] = ((df['PWMDDWPrMeatO'] == 1) | (df['PWMDDWPrMeatF'] == 1) | + (df['PWMDDWPrMeatPro'] == 1) | (df['PWMDDWPrMeatWhite'] == 1) | + (df['PWMDDWPrFish'] == 1)).astype(int) +df['MDDW_Eggs'] = (df['PWMDDWPrEgg'] == 1).astype(int) +df['MDDW_LeafGreenVeg'] = (df['PWMDDWVegGre'] == 1).astype(int) +df['MDDW_VitA'] = ((df['PWMDDWVegOrg'] == 1) | (df['PWMDDWFruitOrg'] == 1)).astype(int) +df['MDDW_OtherVeg'] = (df['PWMDDWVegOth'] == 1).astype(int) +df['MDDW_OtherFruits'] = (df['PWMDDWFruitOth'] == 1).astype(int) + +# WFP MDDW method - SNF in meats group +df['MDDW_Pulses_wfp'] = (df['PWMDDWPulse'] == 1).astype(int) +df['MDDW_NutsSeeds_wfp'] = (df['PWMDDWNuts'] == 1).astype(int) +df['MDDW_Dairy_wfp'] = ((df['PWMDDWDairy'] == 1) | (df['PWMDDWMilk'] == 1)).astype(int) +df['MDDW_MeatFish_wfp'] = ((df['PWMDDWPrMeatO'] == 1) | (df['PWMDDWPrMeatF'] == 1) | + (df['PWMDDWPrMeatPro'] == 1) | (df['PWMDDWPrMeatWhite'] == 1) | + (df['PWMDDWPrFish'] == 1) | (df['PWMDDWSnf'] == 1)).astype(int) +df['MDDW_Eggs_wfp'] = (df['PWMDDWPrEgg'] == 1).astype(int) +df['MDDW_LeafGreenVeg_wfp'] = (df['PWMDDWVegGre'] == 1).astype(int) +df['MDDW_VitA_wfp'] = ((df['PWMDDWVegOrg'] == 1) | (df['PWMDDWFruitOrg'] == 1)).astype(int) +df['MDDW_OtherVeg_wfp'] = (df['PWMDDWVegOth'] == 1).astype(int) +df['MDDW_OtherFruits_wfp'] = (df['PWMDDWFruitOth'] == 1).astype(int) + +# Calculate MDDW Index ------------------------------------------------------# + +df['MDDW'] = (df['MDDW_Staples'] + df['MDDW_Pulses'] + df['MDDW_NutsSeeds'] + + df['MDDW_Dairy'] + df['MDDW_MeatFish'] + df['MDDW_Eggs'] + + df['MDDW_LeafGreenVeg'] + df['MDDW_VitA'] + df['MDDW_OtherVeg'] + + df['MDDW_OtherFruits']) + +df['MDDW_5'] = np.where(df['MDDW'] >= 5, '>=5', '<5') + +df['MDDW_wfp'] = (df['MDDW_Staples_wfp'] + df['MDDW_Pulses_wfp'] + + df['MDDW_NutsSeeds_wfp'] + df['MDDW_Dairy_wfp'] + + df['MDDW_MeatFish_wfp'] + df['MDDW_Eggs_wfp'] + + df['MDDW_LeafGreenVeg_wfp'] + df['MDDW_VitA_wfp'] + + df['MDDW_OtherVeg_wfp'] + df['MDDW_OtherFruits_wfp']) + +df['MDDW_5_wfp'] = np.where(df['MDDW_wfp'] >= 5, '>=5', '<5') + +# Summarize 2 MDDW Index -----------------------------------------------------# + +# Standard MDDW Method - MDDW_5 +MDDW_5_table_wide = (df.dropna(subset=['MDDW_5']) + .groupby('MDDW_5').size() + .reset_index(name='n') + .assign(Percentage=lambda x: 100 * x['n'] / x['n'].sum()) + .pivot(index=None, columns='MDDW_5', values='Percentage') + .fillna(0)) + +# WFP MDDW Method - MDDW_5_wfp +MDDW_5_wfp_table_wide = (df.dropna(subset=['MDDW_5_wfp']) + .groupby('MDDW_5_wfp').size() + .reset_index(name='n') + .assign(Percentage=lambda x: 100 * x['n'] / x['n'].sum()) + .pivot(index=None, columns='MDDW_5_wfp', values='Percentage') + .fillna(0)) + +# Print tables for review +print("Standard MDDW Method Summary:") +print(MDDW_5_table_wide) + +print("\nWFP MDDW Method Summary:") +print(MDDW_5_wfp_table_wide) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Nutrition-MDDW/nutMDDW.sps b/Indicators/Nutrition-MDDW/nutMDDW-calculation.sps similarity index 96% rename from Indicators/Nutrition-MDDW/nutMDDW.sps rename to Indicators/Nutrition-MDDW/nutMDDW-calculation.sps index 77d6721..7d9ec10 100644 --- a/Indicators/Nutrition-MDDW/nutMDDW.sps +++ b/Indicators/Nutrition-MDDW/nutMDDW-calculation.sps @@ -1,4 +1,9 @@ -* Encoding: UTF-8. +*** -------------------------------------------------------------------------- +*** WFP Standardized Scripts +*** Calculating Minimum Dietary Diversity for Women (MDDW) +*** -------------------------------------------------------------------------- + +* Encoding: UTF-8. *can only download repeat csv data as zip file from moda with group names - will update this code to remove group names *rename to remove group names - because of the variable length SPSS changes name slightly @@ -87,7 +92,6 @@ if (PWMDDWVegOth = 1) MDDW_OtherVeg = 1. Compute MDDW_OtherFruits = 0. if (PWMDDWFruitOth = 1) MDDW_OtherFruits = 1. - *WFP MDDW method for program monitoring - SNF will count in the meats group *in this example all - PWMDDWFortFoodwflour,PWMDDWFortFoodmflour,PWMDDWFortFoodrice,PWMDDWFortFooddrink will also count in grains *classifying PWMDDWFortFoodother_oth will likely involve classifying line by line @@ -113,9 +117,6 @@ if (PWMDDWVegOth = 1) MDDW_OtherVeg_wfp = 1. Compute MDDW_OtherFruits_wfp = 0. if (PWMDDWFruitOth = 1) MDDW_OtherFruits_wfp = 1. - - - *calculate MDDW variable for both methods by adding together food groups and classifying whether the woman consumed 5 or more food groups *Standard MDDW method where SNF is counted in grains @@ -130,29 +131,24 @@ Value labels MDDW_5 1 '>=5' 0 '<5 '. Value labels MDDW_5 1 '>=5' 0 '<5 '. - - *WFP MDDW method for program monitoring - SNF will count in the meats group compute MDDW_wfp = sum(MDDW_Staples_wfp,MDDW_Pulses_wfp ,MDDW_NutsSeeds_wfp ,MDDW_Dairy_wfp ,MDDW_MeatFish_wfp ,MDDW_Eggs_wfp ,MDDW_LeafGreenVeg_wfp ,MDDW_VitA_wfp ,MDDW_OtherVeg_wfp ,MDDW_OtherFruits_wfp). *count how many women consumed 5 or more groups - Compute MDDW_5_wfp = 0. if (MDDW_wfp >= 5) MDDW_5_wfp = 1. Value labels MDDW_5_wfp 1 '>=5' 0 '<5 '. Value labels MDDW_5_wfp 1 '>=5' 0 '<5 '. - *Frequency of Standard MDDW Method - MDDW_5 freq MDDW_5. - *Frequency of WFP MDDW method for program monitoring - MDDW_5_wfp freq MDDW_5_wfp. - +*** End of scripts \ No newline at end of file diff --git a/Indicators/Perceived-needs/Perceived-needs-indicator-tidyverse.R b/Indicators/Perceived-needs/Perceived-needs-indicator-tidyverse.R new file mode 100644 index 0000000..1563502 --- /dev/null +++ b/Indicators/Perceived-needs/Perceived-needs-indicator-tidyverse.R @@ -0,0 +1,172 @@ +# ------------------------------------------------------------------------------ +# WFP Standardized Scripts +# Perceived Needs Indicators Calculation +# ------------------------------------------------------------------------------ + +# NOTE: This syntax file assumes the use of all the questions included in the standard module. +# If any question is dropped, the corresponding variable names should be deleted from the syntax file. + +# Import sample dataset +# The sample data on which this syntax file is based can be found here: +# https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Static + +# For more information on the Perceived Needs Indicators (including module), +# see the VAM Resource Center: https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/perceived-needs-indicators + +# ------------------------------------------------------------------------------# +# Open dataset +# ------------------------------------------------------------------------------# + +library(tidyverse) +library(labelled) +library(janitor) + +# Import dataset +data <- read_csv("path/to/Perceived_Needs.csv") + +# ------------------------------------------------------------------------------# +# Labels +# ------------------------------------------------------------------------------# + +# Assign variable and value labels +var_label(data$HHPercNeedWater) <- "Not enough water that is safe for drinking or cooking" +var_label(data$HHPercNeedFood) <- "Not enough food, or good enough food, or not able to cook food" +var_label(data$HHPercNeedHousing) <- "No suitable place to live in" +var_label(data$HHPercNeedToilet) <- "No easy and safe access to a clean toilet" +var_label(data$HHPercNeedHygiene) <- "Not enough soap, sanitary materials, water or a suitable place to wash" +var_label(data$HHPercNeedClothTex) <- "Not enough or good enough, clothes, shoes, bedding or blankets" +var_label(data$HHPercNeedLivelihood) <- "Not enough income, money or resources to live" +var_label(data$HHPercNeedDisabIll) <- "Serious problem with physical health" +var_label(data$HHPercNeedHealth) <- "Not able to get adequate health care (including during pregnancy or childbirth - for women)" +var_label(data$HHPercNeedSafety) <- "Not safe or protected where you live now" +var_label(data$HHPercNeedEducation) <- "Children not in school, or not getting a good enough education" +var_label(data$HHPercNeedCaregive) <- "Difficult to care for family members who live with you" +var_label(data$HHPercNeedInfo) <- "Not have enough information (including on situation at home - for displaced)" +var_label(data$HHPercNeedAsstInfo) <- "Inadequate aid" +var_label(data$CMPercNeedJustice) <- "Inadequate system for law and justice in community" +var_label(data$CMPercNeedGBViolence) <- "Physical or sexual violence towards women in community" +var_label(data$CMPercNeedSubstAbuse) <- "People drink a lot of alcohol or use harmful drugs in community" +var_label(data$CMPercNeedMentalCare) <- "Mental illness in community" +var_label(data$CMPercNeedCaregiving) <- "Not enough care for people who are on their own in community" + +val_labels_list <- c( + "No serious problem" = 0, + "Serious problem" = 1, + "Don't know, not applicable, declines to answer" = 8888 +) + +val_labels(data$HHPercNeedWater) <- val_labels_list +val_labels(data$HHPercNeedFood) <- val_labels_list +val_labels(data$HHPercNeedHousing) <- val_labels_list +val_labels(data$HHPercNeedToilet) <- val_labels_list +val_labels(data$HHPercNeedHygiene) <- val_labels_list +val_labels(data$HHPercNeedClothTex) <- val_labels_list +val_labels(data$HHPercNeedLivelihood) <- val_labels_list +val_labels(data$HHPercNeedDisabIll) <- val_labels_list +val_labels(data$HHPercNeedHealth) <- val_labels_list +val_labels(data$HHPercNeedSafety) <- val_labels_list +val_labels(data$HHPercNeedEducation) <- val_labels_list +val_labels(data$HHPercNeedCaregive) <- val_labels_list +val_labels(data$HHPercNeedInfo) <- val_labels_list +val_labels(data$HHPercNeedAsstInfo) <- val_labels_list +val_labels(data$CMPercNeedJustice) <- val_labels_list +val_labels(data$CMPercNeedGBViolence) <- val_labels_list +val_labels(data$CMPercNeedSubstAbuse) <- val_labels_list +val_labels(data$CMPercNeedMentalCare) <- val_labels_list +val_labels(data$CMPercNeedCaregiving) <- val_labels_list + +val_labels_problem <- c( + "Drinking water" = 1, "Food" = 2, "Place to live in" = 3, "Toilets" = 4, "Keeping clean" = 5, + "Clothes, shoes, bedding or blankets" = 6, "Income or livelihood" = 7, "Physical health" = 8, + "Health care" = 9, "Safety" = 10, "Education for your children" = 11, "Care for family members" = 12, + "Information" = 13, "The way aid is provided" = 14, "Law and injustice in your community" = 15, + "Safety or protection from violence for women in your community" = 16, "Alcohol or drug use in your community" = 17, + "Mental illness in your community" = 18, "Care for people in your community who are on their own" = 19, + "Other problem" = 20 +) + +val_labels(data$CMPercNeedRFirst) <- val_labels_problem +val_labels(data$CMPercNeedRSec) <- val_labels_problem +val_labels(data$CMPercNeedRThird) <- val_labels_problem + +# ------------------------------------------------------------------------------# +# For each aspect/question, report the share of households who indicated it as a "serious problem" +# ------------------------------------------------------------------------------# + +# Frequencies +perc_need_summary <- data %>% + select(HHPercNeedWater:HHPercNeedCaregiving) %>% + summarise(across(everything(), ~ mean(. == 1, na.rm = TRUE) * 100)) + +print(perc_need_summary) + +# Show only the share of households that reported an aspect as a serious problem out of the total population (including those that did not answer) +data <- data %>% + mutate(across(starts_with("HHPercNeed"), ~ replace_na(. == 1, 0))) + +perc_need_summary <- data %>% + select(HHPercNeedWater:HHPercNeedCaregiving) %>% + summarise(across(everything(), ~ mean(. == 1, na.rm = TRUE) * 100)) + +print(perc_need_summary) + +# ------------------------------------------------------------------------------# +# For each aspect/question, report the share of households who indicated it among their top three problems +# ------------------------------------------------------------------------------# + +# Generate variables indicating if the respondent mentioned it among their top three problems +data <- data %>% + mutate( + Top3_Water = (CMPercNeedRFirst == 1 | CMPercNeedRSec == 1 | CMPercNeedRThird == 1), + Top3_Food = (CMPercNeedRFirst == 2 | CMPercNeedRSec == 2 | CMPercNeedRThird == 2), + Top3_Housing = (CMPercNeedRFirst == 3 | CMPercNeedRSec == 3 | CMPercNeedRThird == 3), + Top3_Toilet = (CMPercNeedRFirst == 4 | CMPercNeedRSec == 4 | CMPercNeedRThird == 4), + Top3_Hygiene = (CMPercNeedRFirst == 5 | CMPercNeedRSec == 5 | CMPercNeedRThird == 5), + Top3_ClothTex = (CMPercNeedRFirst == 6 | CMPercNeedRSec == 6 | CMPercNeedRThird == 6), + Top3_Livelihood = (CMPercNeedRFirst == 7 | CMPercNeedRSec == 7 | CMPercNeedRThird == 7), + Top3_Disabil = (CMPercNeedRFirst == 8 | CMPercNeedRSec == 8 | CMPercNeedRThird == 8), + Top3_Health = (CMPercNeedRFirst == 9 | CMPercNeedRSec == 9 | CMPercNeedRThird == 9), + Top3_Safety = (CMPercNeedRFirst == 10 | CMPercNeedRSec == 10 | CMPercNeedRThird == 10), + Top3_Education = (CMPercNeedRFirst == 11 | CMPercNeedRSec == 11 | CMPercNeedRThird == 11), + Top3_Caregive = (CMPercNeedRFirst == 12 | CMPercNeedRSec == 12 | CMPercNeedRThird == 12), + Top3_Info = (CMPercNeedRFirst == 13 | CMPercNeedRSec == 13 | CMPercNeedRThird == 13), + Top3_AsstInfo = (CMPercNeedRFirst == 14 | CMPercNeedRSec == 14 | CMPercNeedRThird == 14), + Top3_Justice = (CMPercNeedRFirst == 15 | CMPercNeedRSec == 15 | CMPercNeedRThird == 15), + Top3_GBViolence = (CMPercNeedRFirst == 16 | CMPercNeedRSec == 16 | CMPercNeedRThird == 16), + Top3_SubstAbuse = (CMPercNeedRFirst == 17 | CMPercNeedRSec == 17 | CMPercNeedRThird == 17), + Top3_MentalCare = (CMPercNeedRFirst == 18 | CMPercNeedRSec == 18 | CMPercNeedRThird == 18), + Top3_Caregiving = (CMPercNeedRFirst == 19 | CMPercNeedRSec == 19 | CMPercNeedRThird == 19), + Top3_Other = (CMPercNeedRFirst == 20 | CMPercNeedRSec == 20 | CMPercNeedRThird == 20) + ) + +# Recode missings to zero +data <- data %>% + mutate(across(starts_with("Top3_"), ~ replace_na(., 0))) + +# Report share of households who indicated an area among their top three problems +top3_summary <- data %>% + select(starts_with("Top3_")) %>% + summarise(across(everything(), ~ mean(. == 1, na.rm = TRUE) * 100)) + +print(top3_summary) + +# ------------------------------------------------------------------------------# +# Mean/median number of aspects indicated as "serious problems" +# ------------------------------------------------------------------------------# + +# Create a variable that counts the number of aspects perceived as serious problems +data <- data %>% + mutate(Perceived_total = rowSums(select(., starts_with("HHPercNeed")) == 1, na.rm = TRUE)) + +var_label(data$Perceived_total) <- "Total number of problems identified" + +# Report mean and median number of aspects indicated as "serious problems" +summary_perceived_total <- data %>% + summarise( + mean_perceived_total = mean(Perceived_total, na.rm = TRUE), + median_perceived_total = median(Perceived_total, na.rm = TRUE) + ) + +print(summary_perceived_total) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Perceived-needs/Perceived-needs-indicator.do b/Indicators/Perceived-needs/Perceived-needs-indicator.do index 0bf3d9c..03f3d18 100644 --- a/Indicators/Perceived-needs/Perceived-needs-indicator.do +++ b/Indicators/Perceived-needs/Perceived-needs-indicator.do @@ -1,109 +1,174 @@ ******************************************************************************** - * STATA Syntax for the Perceived Needs Indicators - ******************************************************************************* - -* NOTE: this syntax file assumes the use of all the questions included in the standard module. If any question is dropped, the corresponding variable names should be deleted from the syntax file. - -* The sample data on which this syntax file is based can be found here: https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Static - -* For more information on the Perceived Needs Indicators (including module), see the VAM Resource Center: https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/perceived-needs-indicators +* WFP Standardized Scripts * +* Perceived Needs Indicators Calculation * +******************************************************************************** +* NOTE: this syntax file assumes the use of all the questions included in the standard module. +* If any question is dropped, the corresponding variable names should be deleted from the syntax file. +* The sample data on which this syntax file is based can be found here: +* https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Static +* For more information on the Perceived Needs Indicators (including module), see the VAM Resource Center: +* https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/perceived-needs-indicators *-------------------------------------------------------------------------------* * Open dataset *-------------------------------------------------------------------------------* -import delimited "XXX\Perceived_Needs.csv", bindquote(strict) case(preserve) numericcols(22 23 24) // change path to reflect where you save the sample dataset +import delimited ".../Perceived_Needs.csv", bindquote(strict) case(preserve) /// + numericcols(22 23 24) + +// change path to reflect where you save the sample dataset *-------------------------------------------------------------------------------* * Labels *-------------------------------------------------------------------------------* -*Variable labels for all indicators -lab var HHPercNeedWater "Not enough water that is safe for drinking or cooking" -lab var HHPercNeedFood "Not enough food, or good enough food, or not able to cook food" -lab var HHPercNeedHousing "No suitable place to live in" -lab var HHPercNeedToilet "No easy and safe access to a clean toilet" -lab var HHPercNeedHygiene "Not enough soap, sanitary materials, water or a suitable place to wash" -lab var HHPercNeedClothTex "Not enough or good enough, clothes, shoes, bedding or blankets" -lab var HHPercNeedLivelihood "Not enough income, money or resources to live" -lab var HHPercNeedDisabIll "Serious problem with physical health" -lab var HHPercNeedHealth "Not able to get adequate health care (including during pregnancy or childbirth - for women)" -lab var HHPercNeedSafety "Not safe or protected where you live now" -lab var HHPercNeedEducation "Children not in school, or not getting a good enough education" -lab var HHPercNeedCaregive "Difficult to care for family members who live with you" -lab var HHPercNeedInfo "Not have enough information (including on situation at home - for displaced)" -lab var HHPercNeedAsstInfo "Inadequate aid" -lab var CMPercNeedJustice "Inadequate system for law and justice in community" -lab var CMPercNeedGBViolence "Physical or sexual violence towards women in community" -lab var CMPercNeedSubstAbuse "People drink a lot of alcohol or use harmful drugs in community" -lab var CMPercNeedMentalCare "Mental illness in community" -lab var CMPercNeedCaregiving "Not enough care for people who are on their own in community" - - -*Value labels for indicators -lab def HHPercNeed_label 0"No serious problem" 1"Serious problem" 8888"Don't know, not applicable, declines to answer" - -foreach var of varlist HHPercNeedWater HHPercNeedFood HHPercNeedHousing HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice CMPercNeedGBViolence CMPercNeedSubstAbuse CMPercNeedMentalCare CMPercNeedCaregiving { - lab val `var' HHPercNeed_label +* Variable labels for all indicators +label var HHPercNeedWater "Not enough water that is safe for drinking or cooking" +label var HHPercNeedFood "Not enough food, or good enough food, or not able to cook food" +label var HHPercNeedHousing "No suitable place to live in" +label var HHPercNeedToilet "No easy and safe access to a clean toilet" +label var HHPercNeedHygiene "Not enough soap, sanitary materials, water or a suitable place to wash" +label var HHPercNeedClothTex "Not enough or good enough, clothes, shoes, bedding or blankets" +label var HHPercNeedLivelihood "Not enough income, money or resources to live" +label var HHPercNeedDisabIll "Serious problem with physical health" +label var HHPercNeedHealth "Not able to get adequate health care (including during pregnancy or childbirth - for women)" +label var HHPercNeedSafety "Not safe or protected where you live now" +label var HHPercNeedEducation "Children not in school, or not getting a good enough education" +label var HHPercNeedCaregive "Difficult to care for family members who live with you" +label var HHPercNeedInfo "Not have enough information (including on situation at home - for displaced)" +label var HHPercNeedAsstInfo "Inadequate aid" +label var CMPercNeedJustice "Inadequate system for law and justice in community" +label var CMPercNeedGBViolence "Physical or sexual violence towards women in community" +label var CMPercNeedSubstAbuse "People drink a lot of alcohol or use harmful drugs in community" +label var CMPercNeedMentalCare "Mental illness in community" +label var CMPercNeedCaregiving "Not enough care for people who are on their own in community" + +* Value labels for indicators +label def HHPercNeed_label 0 "No serious problem" 1 "Serious problem" /// + 8888 "Don't know, not applicable, declines to answer" + +foreach var of varlist HHPercNeedWater HHPercNeedFood HHPercNeedHousing /// + HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex /// + HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth /// + HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive /// + HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice /// + CMPercNeedGBViolence CMPercNeedSubstAbuse /// + CMPercNeedMentalCare CMPercNeedCaregiving { + label val `var' HHPercNeed_label } - -*Add value labels for the problems - make sure that all variables are nominal -lab def CMPercNeedR_label 1"Drinking water" 2"Food" 3"Place to live in" 4"Toilets" 5"Keeping clean" 6"Clothes, shoes, bedding or blankets" 7"Income or livelihood" 8"Physical health" 9"Health care" 10"Safety" 11 "Education for your children" 12 "Care for family members" 13"Information" 14"The way aid is provided" 15"Law and injustice in your community" 16"Safety or protection from violence for women in your community" 17 "Alcohol or drug use in your community" 18"Mental illness in your community" 19 "Care for people in your community who are on their own" 20 "Other problem" - -foreach var of varlist CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird { - lab val `var' CMPercNeedR_label +* Add value labels for the problems - make sure that all variables are nominal +label def CMPercNeedR_label 1 "Drinking water" 2 "Food" 3 "Place to live in" /// + 4 "Toilets" 5 "Keeping clean" /// + 6 "Clothes, shoes, bedding or blankets" /// + 7 "Income or livelihood" 8 "Physical health" /// + 9 "Health care" 10 "Safety" /// + 11 "Education for your children" /// + 12 "Care for family members" 13 "Information" /// + 14 "The way aid is provided" /// + 15 "Law and injustice in your community" /// + 16 "Safety or protection from violence for women in your community" /// + 17 "Alcohol or drug use in your community" /// + 18 "Mental illness in your community" /// + 19 "Care for people in your community who are on their own" /// + 20 "Other problem" + +foreach var of varlist CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird { + label val `var' CMPercNeedR_label } -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* * For each aspect/question, report the share of households who indicated it as a "serious problem" -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - -*Frequencies -table (var) (result) , statistic(fvpercent HHPercNeedWater HHPercNeedFood HHPercNeedHousing HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice CMPercNeedGBViolence CMPercNeedSubstAbuse CMPercNeedMentalCare CMPercNeedCaregiving ) statistic(fvfrequency HHPercNeedWater HHPercNeedFood HHPercNeedHousing HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice CMPercNeedGBViolence CMPercNeedSubstAbuse CMPercNeedMentalCare CMPercNeedCaregiving) - -* show only the share of households that reported an aspect as serious problem out of the total populations (including those that did not answer) +*------------------------------------------------------------------------------* + +* Frequencies +table (var) (result), /// + statistic(fvpercent HHPercNeedWater HHPercNeedFood HHPercNeedHousing /// + HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex /// + HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth /// + HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive /// + HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice /// + CMPercNeedGBViolence CMPercNeedSubstAbuse CMPercNeedMentalCare /// + CMPercNeedCaregiving) /// + statistic(fvfrequency HHPercNeedWater HHPercNeedFood HHPercNeedHousing /// + HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex /// + HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth /// + HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive /// + HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice /// + CMPercNeedGBViolence CMPercNeedSubstAbuse CMPercNeedMentalCare /// + CMPercNeedCaregiving) + +* Show only the share of households that reported an aspect as serious problem out of the total populations (including those that did not answer) preserve -recode HHPercNeedWater HHPercNeedFood HHPercNeedHousing HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice CMPercNeedGBViolence CMPercNeedSubstAbuse CMPercNeedMentalCare CMPercNeedCaregiving (8888=0) - -tabstat HHPercNeedWater HHPercNeedFood HHPercNeedHousing HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice CMPercNeedGBViolence CMPercNeedSubstAbuse CMPercNeedMentalCare CMPercNeedCaregiving, stats(mean) columns(statistics) varwidth(30) +recode HHPercNeedWater HHPercNeedFood HHPercNeedHousing HHPercNeedToilet /// + HHPercNeedHygiene HHPercNeedClothTex HHPercNeedLivelihood HHPercNeedDisabIll /// + HHPercNeedHealth HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive /// + HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice CMPercNeedGBViolence /// + CMPercNeedSubstAbuse CMPercNeedMentalCare CMPercNeedCaregiving (8888=0) + +tabstat HHPercNeedWater HHPercNeedFood HHPercNeedHousing HHPercNeedToilet /// + HHPercNeedHygiene HHPercNeedClothTex HHPercNeedLivelihood HHPercNeedDisabIll /// + HHPercNeedHealth HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive /// + HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice CMPercNeedGBViolence /// + CMPercNeedSubstAbuse CMPercNeedMentalCare CMPercNeedCaregiving, /// + stats(mean) columns(statistics) varwidth(30) restore -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +*-------------------------------------------------------------------------------------------------* * For each aspect/question, report the share of households who indicated it among their top three problems -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* - - -* for each problem generate a variable indicating if the respondent mentioned it among their top three problems -egen Top3_Water=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(1) -egen Top3_Food=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(2) -egen Top3_Housing=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(3) -egen Top3_Toilet=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(4) -egen Top3_Hygiene=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(5) -egen Top3_ClothTex=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(6) -egen Top3_Livelihood=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(7) -egen Top3_Disabil=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(8) -egen Top3_Health=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(9) -egen Top3_Safety=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(10) -egen Top3_Education=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(11) -egen Top3_Caregive=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(12) -egen Top3_Info=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(13) -egen Top3_AsstInfo=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(14) -egen Top3_Justice=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(15) -egen Top3_GBViolence=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(16) -egen Top3_SubstAbuse=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(17) -egen Top3_MentalCare=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(18) -egen Top3_Caregiving=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(19) -egen Top3_Other=anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird),v(20) - -* report share of households who indicated an area among their top three problems +*-------------------------------------------------------------------------------------------------* + +/* Tokenize and loop potential variables - Feel free to explore + + tokenize `""Water" "Food" "Housing" "Toilet" "Hygiene" "ClothTex" "Livelihood" "Disabil" "Health" "Safety" "Education" "Caregive" "Info" "AsstInfo" "Justice" "GBViolence" "SubstAbuse" "MentalCare" "Caregiving" "Other""' + + local i = 0 + while `"`*'"' ~= `""' { + egen Top3_`1' = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(`++i') + macro shift + } +*/ + +* For each problem generate a variable indicating if the respondent mentioned it among their top three problems +egen Top3_Water = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(1) +egen Top3_Food = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(2) +egen Top3_Housing = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(3) +egen Top3_Toilet = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(4) +egen Top3_Hygiene = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(5) +egen Top3_ClothTex = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(6) +egen Top3_Livelihood = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(7) +egen Top3_Disabil = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(8) +egen Top3_Health = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(9) +egen Top3_Safety = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(10) +egen Top3_Education = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(11) +egen Top3_Caregive = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(12) +egen Top3_Info = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(13) +egen Top3_AsstInfo = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(14) +egen Top3_Justice = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(15) +egen Top3_GBViolence = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(16) +egen Top3_SubstAbuse = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(17) +egen Top3_MentalCare = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(18) +egen Top3_Caregiving = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(19) +egen Top3_Other = anymatch(CMPercNeedRFirst CMPercNeedRSec CMPercNeedRThird), v(20) + +* Report share of households who indicated an area among their top three problems tabstat Top3_*, stats(mean) columns(statistics) varwidth(30) -*----------------------------------------------------------------------------------------------------------------------------------------------------------------* +*------------------------------------------------------------------------------* * Mean/median number of aspects indicated as "serious problems" -*--------------------------------------------------------------------------------------------------------------------------------------------------------------- -egen Perceived_total=anycount(HHPercNeedWater HHPercNeedFood HHPercNeedHousing HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice CMPercNeedGBViolence CMPercNeedSubstAbuse CMPercNeedMentalCare CMPercNeedCaregiving), v(1) // the variable counts the number of aspects perceived as serious problems -lab var Perceived_total "Total number of problems identified" +*------------------------------------------------------------------------------* + +egen Perceived_total = anycount(HHPercNeedWater HHPercNeedFood HHPercNeedHousing /// + HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex /// + HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth /// + HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive /// + HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice /// + CMPercNeedGBViolence CMPercNeedSubstAbuse /// + CMPercNeedMentalCare CMPercNeedCaregiving), v(1) +* The variable counts the number of aspects perceived as serious problems +label var Perceived_total "Total number of problems identified" tabstat Perceived_total, stats(mean median) columns(statistics) + +* End of Scripts \ No newline at end of file diff --git a/Indicators/Perceived-needs/Perceived-needs-indicator.py b/Indicators/Perceived-needs/Perceived-needs-indicator.py new file mode 100644 index 0000000..3144e68 --- /dev/null +++ b/Indicators/Perceived-needs/Perceived-needs-indicator.py @@ -0,0 +1,142 @@ +# ------------------------------------------------------------------------------ +# WFP Standardized Scripts +# Perceived Needs Indicators Calculation +# ------------------------------------------------------------------------------ + +# NOTE: This script assumes the use of all the questions included in the standard module. +# If any question is dropped, the corresponding variable names should be deleted from the script. + +# Import sample dataset +# The sample data on which this script is based can be found here: +# https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Static + +# For more information on the Perceived Needs Indicators (including module), +# see the VAM Resource Center: https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/perceived-needs-indicators + +# ------------------------------------------------------------------------------# +# Open dataset +# ------------------------------------------------------------------------------# + +import pandas as pd +import numpy as np + +# Import dataset +data = pd.read_csv("path/to/Perceived_Needs.csv") + +# ------------------------------------------------------------------------------# +# Labels +# ------------------------------------------------------------------------------# + +# Assign variable labels +variable_labels = { + 'HHPercNeedWater': "Not enough water that is safe for drinking or cooking", + 'HHPercNeedFood': "Not enough food, or good enough food, or not able to cook food", + 'HHPercNeedHousing': "No suitable place to live in", + 'HHPercNeedToilet': "No easy and safe access to a clean toilet", + 'HHPercNeedHygiene': "Not enough soap, sanitary materials, water or a suitable place to wash", + 'HHPercNeedClothTex': "Not enough or good enough, clothes, shoes, bedding or blankets", + 'HHPercNeedLivelihood': "Not enough income, money or resources to live", + 'HHPercNeedDisabIll': "Serious problem with physical health", + 'HHPercNeedHealth': "Not able to get adequate health care (including during pregnancy or childbirth - for women)", + 'HHPercNeedSafety': "Not safe or protected where you live now", + 'HHPercNeedEducation': "Children not in school, or not getting a good enough education", + 'HHPercNeedCaregive': "Difficult to care for family members who live with you", + 'HHPercNeedInfo': "Not have enough information (including on situation at home - for displaced)", + 'HHPercNeedAsstInfo': "Inadequate aid", + 'CMPercNeedJustice': "Inadequate system for law and justice in community", + 'CMPercNeedGBViolence': "Physical or sexual violence towards women in community", + 'CMPercNeedSubstAbuse': "People drink a lot of alcohol or use harmful drugs in community", + 'CMPercNeedMentalCare': "Mental illness in community", + 'CMPercNeedCaregiving': "Not enough care for people who are on their own in community" +} + +data = data.rename(columns=variable_labels) + +# Assign value labels +value_labels_list = { + 0: "No serious problem", + 1: "Serious problem", + 8888: "Don't know, not applicable, declines to answer" +} + +for column in data.columns: + if 'HHPercNeed' in column or 'CMPercNeed' in column: + data[column] = data[column].map(value_labels_list).fillna(data[column]) + +problem_labels = { + 1: "Drinking water", 2: "Food", 3: "Place to live in", 4: "Toilets", 5: "Keeping clean", + 6: "Clothes, shoes, bedding or blankets", 7: "Income or livelihood", 8: "Physical health", + 9: "Health care", 10: "Safety", 11: "Education for your children", 12: "Care for family members", + 13: "Information", 14: "The way aid is provided", 15: "Law and injustice in your community", + 16: "Safety or protection from violence for women in your community", 17: "Alcohol or drug use in your community", + 18: "Mental illness in your community", 19: "Care for people in your community who are on their own", + 20: "Other problem" +} + +data['CMPercNeedRFirst'] = data['CMPercNeedRFirst'].map(problem_labels).fillna(data['CMPercNeedRFirst']) +data['CMPercNeedRSec'] = data['CMPercNeedRSec'].map(problem_labels).fillna(data['CMPercNeedRSec']) +data['CMPercNeedRThird'] = data['CMPercNeedRThird'].map(problem_labels).fillna(data['CMPercNeedRThird']) + +# ------------------------------------------------------------------------------# +# For each aspect/question, report the share of households who indicated it as a "serious problem" +# ------------------------------------------------------------------------------# + +# Frequencies +perc_need_summary = data.filter(like='HHPercNeed').apply(lambda x: np.mean(x == "Serious problem") * 100) +print(perc_need_summary) + +# Show only the share of households that reported an aspect as serious problem out of the total population (including those that did not answer) +data = data.apply(lambda x: x.replace("Don't know, not applicable, declines to answer", "No serious problem")) +perc_need_summary = data.filter(like='HHPercNeed').apply(lambda x: np.mean(x == "Serious problem") * 100) +print(perc_need_summary) + +# ------------------------------------------------------------------------------# +# For each aspect/question, report the share of households who indicated it among their top three problems +# ------------------------------------------------------------------------------# + +# Generate variables indicating if the respondent mentioned it among their top three problems +data['Top3_Water'] = (data['CMPercNeedRFirst'] == "Drinking water") | (data['CMPercNeedRSec'] == "Drinking water") | (data['CMPercNeedRThird'] == "Drinking water") +data['Top3_Food'] = (data['CMPercNeedRFirst'] == "Food") | (data['CMPercNeedRSec'] == "Food") | (data['CMPercNeedRThird'] == "Food") +data['Top3_Housing'] = (data['CMPercNeedRFirst'] == "Place to live in") | (data['CMPercNeedRSec'] == "Place to live in") | (data['CMPercNeedRThird'] == "Place to live in") +data['Top3_Toilet'] = (data['CMPercNeedRFirst'] == "Toilets") | (data['CMPercNeedRSec'] == "Toilets") | (data['CMPercNeedRThird'] == "Toilets") +data['Top3_Hygiene'] = (data['CMPercNeedRFirst'] == "Keeping clean") | (data['CMPercNeedRSec'] == "Keeping clean") | (data['CMPercNeedRThird'] == "Keeping clean") +data['Top3_ClothTex'] = (data['CMPercNeedRFirst'] == "Clothes, shoes, bedding or blankets") | (data['CMPercNeedRSec'] == "Clothes, shoes, bedding or blankets") | (data['CMPercNeedRThird'] == "Clothes, shoes, bedding or blankets") +data['Top3_Livelihood'] = (data['CMPercNeedRFirst'] == "Income or livelihood") | (data['CMPercNeedRSec'] == "Income or livelihood") | (data['CMPercNeedRThird'] == "Income or livelihood") +data['Top3_Disabil'] = (data['CMPercNeedRFirst'] == "Physical health") | (data['CMPercNeedRSec'] == "Physical health") | (data['CMPercNeedRThird'] == "Physical health") +data['Top3_Health'] = (data['CMPercNeedRFirst'] == "Health care") | (data['CMPercNeedRSec'] == "Health care") | (data['CMPercNeedRThird'] == "Health care") +data['Top3_Safety'] = (data['CMPercNeedRFirst'] == "Safety") | (data['CMPercNeedRSec'] == "Safety") | (data['CMPercNeedRThird'] == "Safety") +data['Top3_Education'] = (data['CMPercNeedRFirst'] == "Education for your children") | (data['CMPercNeedRSec'] == "Education for your children") | (data['CMPercNeedRThird'] == "Education for your children") +data['Top3_Caregive'] = (data['CMPercNeedRFirst'] == "Care for family members") | (data['CMPercNeedRSec'] == "Care for family members") | (data['CMPercNeedRThird'] == "Care for family members") +data['Top3_Info'] = (data['CMPercNeedRFirst'] == "Information") | (data['CMPercNeedRSec'] == "Information") | (data['CMPercNeedRThird'] == "Information") +data['Top3_AsstInfo'] = (data['CMPercNeedRFirst'] == "The way aid is provided") | (data['CMPercNeedRSec'] == "The way aid is provided") | (data['CMPercNeedRThird'] == "The way aid is provided") +data['Top3_Justice'] = (data['CMPercNeedRFirst'] == "Law and injustice in your community") | (data['CMPercNeedRSec'] == "Law and injustice in your community") | (data['CMPercNeedRThird'] == "Law and injustice in your community") +data['Top3_GBViolence'] = (data['CMPercNeedRFirst'] == "Safety or protection from violence for women in your community") | (data['CMPercNeedRSec'] == "Safety or protection from violence for women in your community") | (data['CMPercNeedRThird'] == "Safety or protection from violence for women in your community") +data['Top3_SubstAbuse'] = (data['CMPercNeedRFirst'] == "Alcohol or drug use in your community") | (data['CMPercNeedRSec'] == "Alcohol or drug use in your community") | (data['CMPercNeedRThird'] == "Alcohol or drug use in your community") +data['Top3_MentalCare'] = (data['CMPercNeedRFirst'] == "Mental illness in your community") | (data['CMPercNeedRSec'] == "Mental illness in your community") | (data['CMPercNeedRThird'] == "Mental illness in your community") +data['Top3_Caregiving'] = (data['CMPercNeedRFirst'] == "Care for people in your community who are on their own") | (data['CMPercNeedRSec'] == "Care for people in your community who are on their own") | (data['CMPercNeedRThird'] == "Care for people in your community who are on their own") +data['Top3_Other'] = (data['CMPercNeedRFirst'] == "Other problem") | (data['CMPercNeedRSec'] == "Other problem") | (data['CMPercNeedRThird'] == "Other problem") + +# Recode missings to zero +top3_columns = [col for col in data.columns if col.startswith('Top3_')] +data[top3_columns] = data[top3_columns].fillna(0).astype(int) + +# Report share of households who indicated an area among their top three problems +top3_summary = data[top3_columns].mean() * 100 +print(top3_summary) + +# ------------------------------------------------------------------------------# +# Mean/median number of aspects indicated as "serious problems" +# ------------------------------------------------------------------------------# + +# Create a variable that counts the number of aspects perceived as serious problems +perc_need_columns = [col for col in data.columns if col.startswith('HHPercNeed') or col.startswith('CMPercNeed')] +data['Perceived_total'] = (data[perc_need_columns] == "Serious problem").sum(axis=1) + +# Report mean and median number of aspects indicated as "serious problems" +mean_perceived_total = data['Perceived_total'].mean() +median_perceived_total = data['Perceived_total'].median() + +print(f"Mean number of perceived serious problems: {mean_perceived_total}") +print(f"Median number of perceived serious problems: {median_perceived_total}") + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Perceived-needs/Perceived-needs-indicator.sps b/Indicators/Perceived-needs/Perceived-needs-indicator.sps index d3bc65e..f0e78b0 100644 --- a/Indicators/Perceived-needs/Perceived-needs-indicator.sps +++ b/Indicators/Perceived-needs/Perceived-needs-indicator.sps @@ -1,14 +1,14 @@ -* Encoding: UTF-8. +******************************************************************************** +* WFP Standardized Scripts * +* Perceived Needs Indicators Calculation * ******************************************************************************** - * SPSS Syntax for the Perceived Needs Indicators - ******************************************************************************* - -* NOTE: this syntax file assumes the use of all the questions included in the standard module. If any question is dropped, the corresponding variable names should be deleted from the syntax file. - -* The sample data on which this syntax file is based can be found here: https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Static - -* For more information on the Perceived Needs Indicators (including module), see the VAM Resource Center: https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/perceived-needs-indicators +* NOTE: this syntax file assumes the use of all the questions included in the standard module. +* If any question is dropped, the corresponding variable names should be deleted from the syntax file. +* The sample data on which this syntax file is based can be found here: +* https://github.com/WFP-VAM/RAMResourcesScripts/tree/main/Static +* For more information on the Perceived Needs Indicators (including module), see the VAM Resource Center: +* https://resources.vam.wfp.org/data-analysis/quantitative/essential-needs/perceived-needs-indicators *-------------------------------------------------------------------------------* * Open dataset @@ -20,89 +20,87 @@ * Labels *-------------------------------------------------------------------------------* -* variable labels. +* Variable labels. VARIABLE LABELS - HHPercNeedWater 'Not enough water that is safe for drinking or cooking' - HHPercNeedFood 'Not enough food, or good enough food, or not able to cook food' - HHPercNeedHousing 'No suitable place to live in' - HHPercNeedToilet 'No easy and safe access to a clean toilet' - HHPercNeedHygiene 'Not enough soap, sanitary materials, water or a suitable place to wash' - HHPercNeedClothTex 'Not enough or good enough, clothes, shoes, bedding or blankets' - HHPercNeedLivelihood 'Not enough income, money or resources to live' - HHPercNeedDisabIll 'Serious problem with physical health' - HHPercNeedHealth 'Not able to get adequate health care (including during pregnancy or childbirth - for women)' - HHPercNeedSafety 'Not safe or protected where you live now' - HHPercNeedEducation 'Children not in school, or not getting a good enough education' - HHPercNeedCaregive 'Difficult to care for family members who live with you' - HHPercNeedInfo 'Not have enough information (including on situation at home - for displaced)' - HHPercNeedAsstInfo 'Inadequate aid' - CMPercNeedJustice 'Inadequate system for law and justice in community' - CMPercNeedGBViolence 'Physical or sexual violence towards women in community' - CMPercNeedSubstAbuse 'People drink a lot of alcohol or use harmful drugs in community' - CMPercNeedMentalCare 'Mental illness in community' - CMPercNeedCaregiving 'Not enough care for people who are on their own in community'. + HHPercNeedWater 'Not enough water that is safe for drinking or cooking' + HHPercNeedFood 'Not enough food, or good enough food, or not able to cook food' + HHPercNeedHousing 'No suitable place to live in' + HHPercNeedToilet 'No easy and safe access to a clean toilet' + HHPercNeedHygiene 'Not enough soap, sanitary materials, water or a suitable place to wash' + HHPercNeedClothTex 'Not enough or good enough, clothes, shoes, bedding or blankets' + HHPercNeedLivelihood 'Not enough income, money or resources to live' + HHPercNeedDisabIll 'Serious problem with physical health' + HHPercNeedHealth 'Not able to get adequate health care (including during pregnancy or childbirth - for women)' + HHPercNeedSafety 'Not safe or protected where you live now' + HHPercNeedEducation 'Children not in school, or not getting a good enough education' + HHPercNeedCaregive 'Difficult to care for family members who live with you' + HHPercNeedInfo 'Not have enough information (including on situation at home - for displaced)' + HHPercNeedAsstInfo 'Inadequate aid' + CMPercNeedJustice 'Inadequate system for law and justice in community' + CMPercNeedGBViolence 'Physical or sexual violence towards women in community' + CMPercNeedSubstAbuse 'People drink a lot of alcohol or use harmful drugs in community' + CMPercNeedMentalCare 'Mental illness in community' + CMPercNeedCaregiving 'Not enough care for people who are on their own in community'. EXECUTE. - -*Value labels for indicators . +* Value labels for indicators. VALUE LABELS - HHPercNeedWater - HHPercNeedFood - HHPercNeedHousing - HHPercNeedToilet - HHPercNeedHygiene - HHPercNeedClothTex - HHPercNeedLivelihood - HHPercNeedDisabIll + HHPercNeedWater + HHPercNeedFood + HHPercNeedHousing + HHPercNeedToilet + HHPercNeedHygiene + HHPercNeedClothTex + HHPercNeedLivelihood + HHPercNeedDisabIll HHPercNeedHealth - HHPercNeedSafety - HHPercNeedEducation - HHPercNeedCaregive - HHPercNeedInfo - HHPercNeedAsstInfo - CMPercNeedJustice - CMPercNeedGBViolence - CMPercNeedSubstAbuse - CMPercNeedMentalCare - CMPercNeedCaregiving - 0 'No serious problem' -1 'Serious problem' -8888 "Don't know, not applicable, declines to answer". -execute. - -*Add value labels for the problems - make sure that all variables are nominal. + HHPercNeedSafety + HHPercNeedEducation + HHPercNeedCaregive + HHPercNeedInfo + HHPercNeedAsstInfo + CMPercNeedJustice + CMPercNeedGBViolence + CMPercNeedSubstAbuse + CMPercNeedMentalCare + CMPercNeedCaregiving + 0 'No serious problem' + 1 'Serious problem' + 8888 "Don't know, not applicable, declines to answer". +EXECUTE. + +* Add value labels for the problems - make sure that all variables are nominal. VALUE LABELS - CMPercNeedRFirst - CMPercNeedRSec - CMPercNeedRThird - 1'Drinking water' - 2'Food' - 3'Place to live in' - 4'Toilets' - 5'Keeping clean' - 6'Clothes, shoes, bedding or blankets' - 7'Income or livelihood' - 8'Physical health' - 9'Health care' - 10'Safety' + CMPercNeedRFirst + CMPercNeedRSec + CMPercNeedRThird + 1 'Drinking water' + 2 'Food' + 3 'Place to live in' + 4 'Toilets' + 5 'Keeping clean' + 6 'Clothes, shoes, bedding or blankets' + 7 'Income or livelihood' + 8 'Physical health' + 9 'Health care' + 10 'Safety' 11 'Education for your children' - 12'Care for family members' - 13'Information' - 14'The way aid is provided' - 15'Law and injustice in your community' - 16'Safety or protection from violence for women in your community' - 17'Alcohol or drug use in your community' - 18'Mental illness in your community' - 19'Care for people in your community who are on their own' - 20'Other problem'. + 12 'Care for family members' + 13 'Information' + 14 'The way aid is provided' + 15 'Law and injustice in your community' + 16 'Safety or protection from violence for women in your community' + 17 'Alcohol or drug use in your community' + 18 'Mental illness in your community' + 19 'Care for people in your community who are on their own' + 20 'Other problem'. EXECUTE. - *----------------------------------------------------------------------------------------------------------------------------------------------------------------* * For each aspect/question, report the share of households who indicated it as a "serious problem" *----------------------------------------------------------------------------------------------------------------------------------------------------------------* -*Frequencies. +* Frequencies. CTABLES /VLABELS VARIABLES=HHPercNeedWater HHPercNeedFood HHPercNeedHousing HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth @@ -130,51 +128,50 @@ CTABLES CMPercNeedCaregiving CMPercNeedOther ORDER=A KEY=VALUE EMPTY=EXCLUDE /CRITERIA CILEVEL=95. +* show only the share of households that reported an aspect as serious problem out of the total populations (including those that did not answer). +PRESERVE. -* show only the share of households that reported an aspect as serious problem out of the total populations (including those that did not answer) -preserve. - - * first recode into 8888 to 0 into new variables. +* First recode into 8888 to 0 into new variables. RECODE - HHPercNeedWater - HHPercNeedFood - HHPercNeedHousing - HHPercNeedToilet - HHPercNeedHygiene - HHPercNeedClothTex - HHPercNeedLivelihood - HHPercNeedDisabIll + HHPercNeedWater + HHPercNeedFood + HHPercNeedHousing + HHPercNeedToilet + HHPercNeedHygiene + HHPercNeedClothTex + HHPercNeedLivelihood + HHPercNeedDisabIll HHPercNeedHealth - HHPercNeedSafety - HHPercNeedEducation - HHPercNeedCaregive - HHPercNeedInfo - HHPercNeedAsstInfo - CMPercNeedJustice - CMPercNeedGBViolence - CMPercNeedSubstAbuse - CMPercNeedMentalCare - CMPercNeedCaregiving - (8888=0) (else=copy) into - rec_HHPercNeedWater - rec_HHPercNeedFood - rec_HHPercNeedHousing - rec_HHPercNeedToilet - rec_HHPercNeedHygiene - rec_HHPercNeedClothTex - rec_HHPercNeedLivelihood - rec_HHPercNeedDisabIll -rec_HHPercNeedHealth -rec_HHPercNeedSafety - rec_HHPercNeedEducation - rec_HHPercNeedCaregive - rec_HHPercNeedInfo - rec_HHPercNeedAsstInfo - rec_CMPercNeedJustice - rec_CMPercNeedGBViolence - rec_CMPercNeedSubstAbuse - rec_CMPercNeedMentalCare - rec_CMPercNeedCaregiving. + HHPercNeedSafety + HHPercNeedEducation + HHPercNeedCaregive + HHPercNeedInfo + HHPercNeedAsstInfo + CMPercNeedJustice + CMPercNeedGBViolence + CMPercNeedSubstAbuse + CMPercNeedMentalCare + CMPercNeedCaregiving + (8888=0) (else=copy) INTO + rec_HHPercNeedWater + rec_HHPercNeedFood + rec_HHPercNeedHousing + rec_HHPercNeedToilet + rec_HHPercNeedHygiene + rec_HHPercNeedClothTex + rec_HHPercNeedLivelihood + rec_HHPercNeedDisabIll + rec_HHPercNeedHealth + rec_HHPercNeedSafety + rec_HHPercNeedEducation + rec_HHPercNeedCaregive + rec_HHPercNeedInfo + rec_HHPercNeedAsstInfo + rec_CMPercNeedJustice + rec_CMPercNeedGBViolence + rec_CMPercNeedSubstAbuse + rec_CMPercNeedMentalCare + rec_CMPercNeedCaregiving. EXECUTE. DESCRIPTIVES VARIABLES=rec_HHPercNeedWater rec_HHPercNeedFood rec_HHPercNeedHousing @@ -191,43 +188,42 @@ DELETE VARIABLES rec_HHPercNeedWater rec_HHPercNeedFood rec_HHPercNeedHousing rec_HHPercNeedCaregive rec_HHPercNeedInfo rec_HHPercNeedAsstInfo rec_CMPercNeedJustice rec_CMPercNeedGBViolence rec_CMPercNeedSubstAbuse rec_CMPercNeedMentalCare rec_CMPercNeedCaregiving. EXECUTE. - + *----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* For each aspect/question, report the share of households who indicated it among their top three problems (amo +* For each aspect/question, report the share of households who indicated it among their top three problems (among their first, second, and third ranked problems). *----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* for each problem generate a variable indicating if the respondent mentioned it among their top three problems. -COMPUTE Top3_Water=(CMPercNeedRFirst=1 OR CMPercNeedRSec=1 OR CMPercNeedRThird=1). -COMPUTE Top3_Food=(CMPercNeedRFirst=2 OR CMPercNeedRSec=2 OR CMPercNeedRThird=2). -COMPUTE Top3_Housing=(CMPercNeedRFirst=3 OR CMPercNeedRSec=3 OR CMPercNeedRThird=3). -COMPUTE Top3_Toilet=(CMPercNeedRFirst=4 OR CMPercNeedRSec=4 OR CMPercNeedRThird=4). -COMPUTE Top3_Hygiene=(CMPercNeedRFirst=5 OR CMPercNeedRSec=5 OR CMPercNeedRThird=5). -COMPUTE Top3_ClothTex=(CMPercNeedRFirst=6 OR CMPercNeedRSec=6 OR CMPercNeedRThird=6). -COMPUTE Top3_Livelihood=(CMPercNeedRFirst=7 OR CMPercNeedRSec=7 OR CMPercNeedRThird=7). -COMPUTE Top3_Disabil=(CMPercNeedRFirst=8 OR CMPercNeedRSec=8 OR CMPercNeedRThird=8). -COMPUTE Top3_Health=(CMPercNeedRFirst=9 OR CMPercNeedRSec=9 OR CMPercNeedRThird=9). -COMPUTE Top3_Safety=(CMPercNeedRFirst=10 OR CMPercNeedRSec=10 OR CMPercNeedRThird=10). -COMPUTE Top3_Education=(CMPercNeedRFirst=11 OR CMPercNeedRSec=11 OR CMPercNeedRThird=11). -COMPUTE Top3_Caregive=(CMPercNeedRFirst=12 OR CMPercNeedRSec=12 OR CMPercNeedRThird=12). -COMPUTE Top3_Info=(CMPercNeedRFirst=13 OR CMPercNeedRSec=13 OR CMPercNeedRThird=13). -COMPUTE Top3_AsstInfo=(CMPercNeedRFirst=14 OR CMPercNeedRSec=14 OR CMPercNeedRThird=14). -COMPUTE Top3_Justice=(CMPercNeedRFirst=15 OR CMPercNeedRSec=15 OR CMPercNeedRThird=15). -COMPUTE Top3_GBViolence=(CMPercNeedRFirst=16 OR CMPercNeedRSec=16 OR CMPercNeedRThird=16). -COMPUTE Top3_SubstAbuse=(CMPercNeedRFirst=17 OR CMPercNeedRSec=17 OR CMPercNeedRThird=17). -COMPUTE Top3_MentalCare=(CMPercNeedRFirst=18 OR CMPercNeedRSec=18 OR CMPercNeedRThird=18). -COMPUTE Top3_Caregiving=(CMPercNeedRFirst=19 OR CMPercNeedRSec=19 OR CMPercNeedRThird=19). -COMPUTE Top3_Other=(CMPercNeedRFirst=20 OR CMPercNeedRSec=20 OR CMPercNeedRThird=20). +* For each problem generate a variable indicating if the respondent mentioned it among their top three problems. +COMPUTE Top3_Water =(CMPercNeedRFirst=1 OR CMPercNeedRSec=1 OR CMPercNeedRThird=1). +COMPUTE Top3_Food =(CMPercNeedRFirst=2 OR CMPercNeedRSec=2 OR CMPercNeedRThird=2). +COMPUTE Top3_Housing =(CMPercNeedRFirst=3 OR CMPercNeedRSec=3 OR CMPercNeedRThird=3). +COMPUTE Top3_Toilet =(CMPercNeedRFirst=4 OR CMPercNeedRSec=4 OR CMPercNeedRThird=4). +COMPUTE Top3_Hygiene =(CMPercNeedRFirst=5 OR CMPercNeedRSec=5 OR CMPercNeedRThird=5). +COMPUTE Top3_ClothTex =(CMPercNeedRFirst=6 OR CMPercNeedRSec=6 OR CMPercNeedRThird=6). +COMPUTE Top3_Livelihood =(CMPercNeedRFirst=7 OR CMPercNeedRSec=7 OR CMPercNeedRThird=7). +COMPUTE Top3_Disabil =(CMPercNeedRFirst=8 OR CMPercNeedRSec=8 OR CMPercNeedRThird=8). +COMPUTE Top3_Health =(CMPercNeedRFirst=9 OR CMPercNeedRSec=9 OR CMPercNeedRThird=9). +COMPUTE Top3_Safety =(CMPercNeedRFirst=10 OR CMPercNeedRSec=10 OR CMPercNeedRThird=10). +COMPUTE Top3_Education =(CMPercNeedRFirst=11 OR CMPercNeedRSec=11 OR CMPercNeedRThird=11). +COMPUTE Top3_Caregive =(CMPercNeedRFirst=12 OR CMPercNeedRSec=12 OR CMPercNeedRThird=12). +COMPUTE Top3_Info =(CMPercNeedRFirst=13 OR CMPercNeedRSec=13 OR CMPercNeedRThird=13). +COMPUTE Top3_AsstInfo =(CMPercNeedRFirst=14 OR CMPercNeedRSec=14 OR CMPercNeedRThird=14). +COMPUTE Top3_Justice =(CMPercNeedRFirst=15 OR CMPercNeedRSec=15 OR CMPercNeedRThird=15). +COMPUTE Top3_GBViolence =(CMPercNeedRFirst=16 OR CMPercNeedRSec=16 OR CMPercNeedRThird=16). +COMPUTE Top3_SubstAbuse =(CMPercNeedRFirst=17 OR CMPercNeedRSec=17 OR CMPercNeedRThird=17). +COMPUTE Top3_MentalCare =(CMPercNeedRFirst=18 OR CMPercNeedRSec=18 OR CMPercNeedRThird=18). +COMPUTE Top3_Caregiving =(CMPercNeedRFirst=19 OR CMPercNeedRSec=19 OR CMPercNeedRThird=19). +COMPUTE Top3_Other =(CMPercNeedRFirst=20 OR CMPercNeedRSec=20 OR CMPercNeedRThird=20). EXECUTE. -* recode missings to zero. +* Recode missings to zero. RECODE Top3_Water Top3_Food Top3_Housing Top3_Toilet Top3_Hygiene Top3_ClothTex Top3_Livelihood Top3_Disabil Top3_Health Top3_Safety Top3_Education Top3_Caregive Top3_Info Top3_AsstInfo Top3_Justice Top3_GBViolence Top3_SubstAbuse Top3_MentalCare Top3_Caregiving Top3_Other (sysmis=0). -EXE. - +EXECUTE. -* report share of households who indicated an area among their top three problems. +* Report share of households who indicated an area among their top three problems. DESCRIPTIVES VARIABLES=Top3_Water Top3_Food Top3_Housing Top3_Toilet Top3_Hygiene Top3_ClothTex Top3_Livelihood Top3_Disabil Top3_Health Top3_Safety Top3_Education Top3_Caregive Top3_Info Top3_AsstInfo Top3_Justice Top3_GBViolence Top3_SubstAbuse Top3_MentalCare Top3_Caregiving @@ -236,19 +232,18 @@ DESCRIPTIVES VARIABLES=Top3_Water Top3_Food Top3_Housing Top3_Toilet Top3_Hygien *----------------------------------------------------------------------------------------------------------------------------------------------------------------* * Mean/median number of aspects indicated as "serious problems" -*--------------------------------------------------------------------------------------------------------------------------------------------------------------- +*----------------------------------------------------------------------------------------------------------------------------------------------------------------* -* create a variable that counts the number of aspects perceived as serious problems. +* Create a variable that counts the number of aspects perceived as serious problems. COUNT Perceived_total=HHPercNeedWater HHPercNeedFood HHPercNeedHousing HHPercNeedToilet HHPercNeedHygiene HHPercNeedClothTex HHPercNeedLivelihood HHPercNeedDisabIll HHPercNeedHealth HHPercNeedSafety HHPercNeedEducation HHPercNeedCaregive HHPercNeedInfo HHPercNeedAsstInfo CMPercNeedJustice CMPercNeedGBViolence CMPercNeedSubstAbuse CMPercNeedMentalCare - CMPercNeedCaregiving CMPercNeedOther(1). -VARIABLE LABELS Perceived_total 'Total number of problems identified'. + CMPercNeedCaregiving CMPercNeedOther (1). +VARIABLE LABELS Perceived_total 'Total number of problems identified'. EXECUTE. FREQUENCIES VARIABLES=Perceived_total /STATISTICS=MEAN MEDIAN. - - +* End of Scripts \ No newline at end of file diff --git a/Indicators/Reduced-coping-strategy-index/rCSI_tidyverse.R b/Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation-tidyverse.R similarity index 88% rename from Indicators/Reduced-coping-strategy-index/rCSI_tidyverse.R rename to Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation-tidyverse.R index 664efad..91ba144 100644 --- a/Indicators/Reduced-coping-strategy-index/rCSI_tidyverse.R +++ b/Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation-tidyverse.R @@ -1,8 +1,6 @@ #------------------------------------------------------------------------------# - -# WFP RAM Standardized Scripts -# Calculating and Summarising rCSI - +# WFP Standardized Scripts +# Calculating Reduced Coping Strategy Index (rCSI) #------------------------------------------------------------------------------# rm(list = ls()) @@ -15,7 +13,7 @@ library(labelled) # Load Sample Data ------------------------------------------------------------# -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/rCSI_Sample_Survey.csv") +#data <- read_csv("~/GitHub/RAMResourcesScripts/Static/rCSI_Sample_Survey.csv") # Label rCSI relevant variables -----------------------------------------------# @@ -48,3 +46,4 @@ rCSI_table_mean <- data %>% summarise(meanrCSI = weighted.mean(rCSI,nameofweightvariable)) #insert name of weight variable +# End of Scripts \ No newline at end of file diff --git a/Indicators/Reduced-coping-strategy-index/rCSI-indicator.do b/Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation.do similarity index 72% rename from Indicators/Reduced-coping-strategy-index/rCSI-indicator.do rename to Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation.do index 9e80a3c..95eca16 100644 --- a/Indicators/Reduced-coping-strategy-index/rCSI-indicator.do +++ b/Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation.do @@ -1,13 +1,14 @@ ******************************************************************************** -* reduced Coping Strategy Index (rCSI) +* WFP Standardized Scripts +* . Calculating Reduced Coping Strategy Index (rCSI) *******************************************************************************/ ** Load data * --------- -import delim using "../GitHub/RAMResourcesScripts/Static/rCSI_Sample_Survey.csv", /// - clear case(preserve) +*import delim using "../GitHub/RAMResourcesScripts/Static/rCSI_Sample_Survey.csv", /// +* clear case(preserve) -** Check and recode missing values as 0 +** Check missing values and hanle if necessary sum rCSI* ** Label rCSI relevant variables @@ -22,4 +23,4 @@ import delim using "../GitHub/RAMResourcesScripts/Static/rCSI_Sample_Survey.csv" (rCSIMealSize * 1) + (rCSIMealAdult * 3) lab var rCSI "Reduced Consumption Strategies Index" -** End of Scripts +** End of Scripts \ No newline at end of file diff --git a/Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation.py b/Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation.py new file mode 100644 index 0000000..c5a1058 --- /dev/null +++ b/Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation.py @@ -0,0 +1,29 @@ +#------------------------------------------------------------------------------# +# WFP Standardized Scripts +# Calculating Reduced Coping Strategy Index (rCSI) +#------------------------------------------------------------------------------# + +# Load Packages --------------------------------------------------------------# + +import pandas as pd +import numpy as np + +# Load Sample Data ------------------------------------------------------------# + +#df = pd.read_csv("RCSI_Sample_Survey.csv") + +# Calculate rCSI --------------------------------------------------------------# + +df['rCSI'] = (df['rCSILessQlty'] + + (df['rCSIBorrow'] * 2) + + df['rCSIMealNb'] + + df['rCSIMealSize'] + + (df['rCSIMealAdult'] * 3)) + +# Creating unweighted summary of rCSI ----------------------------# + +# Unweighted mean +mean_rCSI_unweighted = df['rCSI'].dropna().mean() +print("Unweighted mean rCSI:", mean_rCSI_unweighted) + +# End of Scripts \ No newline at end of file diff --git a/Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation.sps b/Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation.sps new file mode 100644 index 0000000..ec95e81 --- /dev/null +++ b/Indicators/Reduced-coping-strategy-index/rCSI-indicator-calculation.sps @@ -0,0 +1,23 @@ +*** -------------------------------------------------------------------------- +*** WFP Standardized Scripts +*** Calculating Food Consumption Score (FCS) +*** -------------------------------------------------------------------------- + +* Encoding: UTF-8. + +*** Define labels + +Variable labels +rCSILessQlty 'Rely on less preferred and less expensive food in the past 7 days' +rCSIBorrow 'Borrow food or rely on help from a relative or friend in the past 7 days' +rCSIMealNb 'Reduce number of meals eaten in a day in the past 7 days' +rCSIMealSize 'Limit portion size of meals at meal times in the past 7 days' +rCSIMealAdult 'Restrict consumption by adults in order for small children to eat in the past 7 days'. + +*** Calculate rCSI + +Compute rCSI = sum(rCSILessQlty*1,rCSIBorrow*2,rCSIMealNb*1,rCSIMealSize*1,rCSIMealAdult*3). +Variable labels rCSI 'Reduced coping strategies index (rCSI)'. +EXECUTE. + +*** End of scripts \ No newline at end of file diff --git a/Indicators/Reduced-coping-strategy-index/rCSI-indicator.sps b/Indicators/Reduced-coping-strategy-index/rCSI-indicator.sps deleted file mode 100644 index fc85b7d..0000000 --- a/Indicators/Reduced-coping-strategy-index/rCSI-indicator.sps +++ /dev/null @@ -1,16 +0,0 @@ -* Encoding: UTF-8. -***Reduced Coping Strategy Index*** -***define variables - -Variable labels -rCSILessQlty Rely on less preferred and less expensive food in the past 7 days -rCSIBorrow Borrow food or rely on help from a relative or friend in the past 7 days -rCSIMealNb Reduce number of meals eaten in a day in the past 7 days -rCSIMealSize Limit portion size of meals at meal times in the past 7 days -rCSIMealAdult Restrict consumption by adults in order for small children to eat in the past 7 days. - -Compute rCSI = sum(rCSILessQlty*1,rCSIBorrow*2,rCSIMealNb*1,rCSIMealSize*1,rCSIMealAdult*3). -Variable labels rCSI 'Reduced coping strategies index (rCSI)'. -EXECUTE. - -