Resilience has been defined as the capacity of socioeconomic systems (e.g., households) to withstand shocks through absorption, adaptation and transformation.
One way to estimate resilience is through RIMA II method used by FAO that utilizes structural equation modeling (SEM): SEM combines Confirmatory Factor Analysis and Path Analysis: Generally, there are two steps followed:

  1. First, the resilience pillars are estimated from observed variables through Factor Analysis (FA).
  2. Second, the resilience index is estimated from the pillars, using path analysis (e.g. ordinary least square) with the outcome variable being a food security indicator(s) such as dietary diversity score.

FAO uses SEMs to measure Resilience Capacity Index (RCI) based on four pillars:
1. Access to basic services (ABS)
2. Assets (AST)
3. Social safety nets (SSN)
4. Adaptive capacity (AC)

For this data the food security indicator will be the proportion of income spent on food and will perform the role of an endogenous variable

The data that will be used will have pillars already identified through factor analysis.

library(lavaan)
library(knitr)
library(broom)
library(readxl)
library(haven)
library(knitr)
library(png)
library(dplyr)
library(kableExtra)
library(tidyverse)
library(ggthemes)

We now load the dataset whose labels are shown in the table below:

setwd("E:/Structural Equation Model")
resilience.d <- read_sav("data.sav")
head(resilience.d,10) %>%
  kable("html") %>%
  kable_styling(font_size=12) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
animal_asset sources income_sources coping_strategies no_groups food.e
16 2 1 1 1 0.20
16 3 1 1 0 0.67
8 1 1 1 1 1.00
3 1 1 2 1 1.00
42 1 1 0 1 0.50
32 1 1 0 1 0.70
6 1 1 0 1 0.50
55 1 1 1 1 0.42
10 1 1 1 2 0.14
6 2 1 1 1 0.10

Structural equation model

First, we will need to establish a measurement model for each pillar. Notably, each pillar is most oftenly a latent factor established from more than one indicator. The table below shows each pillar and variables (indicators) used in the analysis; in our case only one pillar (AC- Adaptive Capacity) is a latent variable.

rcimodel='
AST=~animal_asset
ABS=~sources
AC=~income_sources+coping_strategies
SSN=~no_groups
RCI_score=~food.e
# regression
RCI_score~AST+ABS+AC+SSN'

fit <- sem(rcimodel,data=resilience.d)
summary(fit, standardized=TRUE, fit.measures=TRUE)
## lavaan 0.6-9 ended normally after 75 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        18
##                                                       
##   Number of observations                           959
##                                                       
## Model Test User Model:
##                                                       
##   Test statistic                                93.383
##   Degrees of freedom                                 3
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               235.482
##   Degrees of freedom                                15
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.590
##   Tucker-Lewis Index (TLI)                      -1.050
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)             -10043.745
##   Loglikelihood unrestricted model (H1)      -9997.053
##                                                       
##   Akaike (AIC)                               20123.489
##   Bayesian (BIC)                             20211.075
##   Sample-size adjusted Bayesian (BIC)        20153.908
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.177
##   90 Percent confidence interval - lower         0.147
##   90 Percent confidence interval - upper         0.209
##   P-value RMSEA <= 0.05                          0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.070
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Latent Variables:
##                    Estimate   Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   AST =~                                                                 
##     animal_asset       1.000                             102.782    1.000
##   ABS =~                                                                 
##     sources            1.000                               0.861    1.000
##   AC =~                                                                  
##     income_sources     1.000                               3.633    5.860
##     coping_stratgs     0.002    0.134    0.015    0.988    0.007    0.011
##   SSN =~                                                                 
##     no_groups          1.000                               0.796    1.000
##   RCI_score =~                                                           
##     food.e             1.000                               0.261    1.000
## 
## Regressions:
##                    Estimate   Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   RCI_score ~                                                            
##     AST               -0.000    0.000   -4.817    0.000   -0.168   -0.168
##     ABS               -0.028    0.017   -1.649    0.099   -0.094   -0.094
##     AC                -0.001    0.096   -0.015    0.988   -0.021   -0.021
##     SSN                0.035    0.011    3.249    0.001    0.108    0.108
## 
## Covariances:
##                    Estimate   Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   AST ~~                                                                 
##     ABS               12.280    2.884    4.257    0.000    0.139    0.139
##     AC                 5.952    2.063    2.884    0.004    0.016    0.016
##     SSN                4.602    2.646    1.739    0.082    0.056    0.056
##   ABS ~~                                                                 
##     AC                 0.115    0.018    6.536    0.000    0.037    0.037
##     SSN                0.018    0.022    0.827    0.408    0.027    0.027
##   AC ~~                                                                  
##     SSN                0.028    0.016    1.728    0.084    0.010    0.010
## 
## Variances:
##                    Estimate   Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .animal_asset       0.000                               0.000    0.000
##    .sources            0.000                               0.000    0.000
##    .income_sources   -12.817  855.807   -0.015    0.988  -12.817  -33.338
##    .coping_stratgs     0.451    0.021   21.565    0.000    0.451    1.000
##    .no_groups          0.000                               0.000    0.000
##    .food.e             0.000                               0.000    0.000
##     AST            10564.237  482.441   21.897    0.000    1.000    1.000
##     ABS                0.741    0.034   21.897    0.000    1.000    1.000
##     AC                13.202  855.807    0.015    0.988    1.000    1.000
##     SSN                0.634    0.029   21.897    0.000    1.000    1.000
##    .RCI_score          0.065    0.003   18.442    0.000    0.949    0.949

Save the scores: we now save factor scores and the most important score is the resilience capacity index (RCI) factor score in the last column

fit2<- cfa(rcimodel, data=resilience.d)
fscores <- lavPredict(fit2)
newdata<-cbind(resilience.d,fscores)
head(newdata,10) %>%
  kable("html") %>%
  kable_styling(font_size=12) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
animal_asset sources income_sources coping_strategies no_groups food.e AST ABS AC SSN RCI_score
16 2 1 1 1 0.20 -57.2586 0.1386861 -32.37460 -0.5078206 -0.2531491
16 3 1 1 0 0.67 -57.2586 1.1386861 -30.57509 -1.5078206 0.2168509
8 1 1 1 1 1.00 -65.2586 -0.8613139 -18.56528 -0.5078206 0.5468509
3 1 1 2 1 1.00 -70.2586 -0.8613139 -20.68413 -0.5078206 0.5468509
42 1 1 0 1 0.50 -31.2586 -0.8613139 -22.15270 -0.5078206 0.0468509
32 1 1 0 1 0.70 -41.2586 -0.8613139 -19.88432 -0.5078206 0.2468509
6 1 1 0 1 0.50 -67.2586 -0.8613139 -21.83474 -0.5078206 0.0468509
55 1 1 1 1 0.42 -18.2586 -0.8613139 -25.30255 -0.5078206 -0.0331491
10 1 1 1 2 0.14 -63.2586 -0.8613139 -29.65201 0.4921794 -0.3131491
6 2 1 1 1 0.10 -67.2586 0.1386861 -33.37631 -0.5078206 -0.3531491

To get the Resilience Index, a min-max scaling is used to transform the RCI scores into a standardized index ranging between 0 and 100. The linear scaling is based on on formula below: The - Mean is the RCI

\[\begin{equation} RCI=\frac{RCI-RCI_{min}}{RCI_{max}-RCI_{min}} \end{equation}\]

rcidata<-newdata %>%
mutate(RCI=(RCI_score-min(RCI_score))/(max(RCI_score)-min(RCI_score)))

head(rcidata,10) %>%
  kable("html") %>%
  kable_styling(font_size=12) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
animal_asset sources income_sources coping_strategies no_groups food.e AST ABS AC SSN RCI_score RCI
16 2 1 1 1 0.20 -57.2586 0.1386861 -32.37460 -0.5078206 -0.2531491 0.1919192
16 3 1 1 0 0.67 -57.2586 1.1386861 -30.57509 -1.5078206 0.2168509 0.6666667
8 1 1 1 1 1.00 -65.2586 -0.8613139 -18.56528 -0.5078206 0.5468509 1.0000000
3 1 1 2 1 1.00 -70.2586 -0.8613139 -20.68413 -0.5078206 0.5468509 1.0000000
42 1 1 0 1 0.50 -31.2586 -0.8613139 -22.15270 -0.5078206 0.0468509 0.4949495
32 1 1 0 1 0.70 -41.2586 -0.8613139 -19.88432 -0.5078206 0.2468509 0.6969697
6 1 1 0 1 0.50 -67.2586 -0.8613139 -21.83474 -0.5078206 0.0468509 0.4949495
55 1 1 1 1 0.42 -18.2586 -0.8613139 -25.30255 -0.5078206 -0.0331491 0.4141414
10 1 1 1 2 0.14 -63.2586 -0.8613139 -29.65201 0.4921794 -0.3131491 0.1313131
6 2 1 1 1 0.10 -67.2586 0.1386861 -33.37631 -0.5078206 -0.3531491 0.0909091

In this the RCI=0.45

We now look at the strength of each pillar in explaining RCI. We will use sum of squares of regression from anova to determine the proportion of variance each pillar explains when regressed against resilience capacity of each household.

attach(rcidata)
fit1<-lm(RCI~ABS+AST+AC+SSN)
var.amt<-anova(fit1)
afss<-var.amt$"Sum Sq"[1:4]
Pct.var=round(afss/sum(afss)*100,0)
Pillars=c("ABS","AST","AC","SSN")
Proportion=Pct.var
pillar.data<-data.frame(Pillars,Proportion)
pillar.data<- pillar.data %>% 
  mutate(pillar.label = "Pillars")

Pillar contribution to resilience

From the chart below, assets (AST) are linked to high resilience capacity of a household followed by access to basic services (ABS) and social security network (SSN)

ggplot(pillar.data, aes(x =pillar.label, y = Proportion, fill = Pillars)) +
  geom_col(width = 0.3) +
  geom_text(aes(label = paste0(Proportion, "%")),
            position = position_stack(vjust = 0.5)) +
  theme_economist(base_size = 5) +
  scale_fill_economist() +
  theme(legend.position = "right", 
        legend.title = element_blank()) +
  theme(axis.title.y = element_text(margin = margin(r = 20))) +
  ylab("Percentage") +
  xlab(NULL)