The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Child Health » SII, RII, CI, and Gini (Calculation of relative index of inequality, slope index of inequality, Concentration Curve and Index, Lorenz Curve and Gini Coefficient)
SII, RII, CI, and Gini Sat, 04 February 2023 03:19
 Kazi_Salahin Messages: 9Registered: February 2023 Member
Dear Concern

I am using the Bangladesh data (BDHS-2017-2018) specifically the KR data file. I want to calculate the "Relative index of inequality." "Slope index of inequality," "Concentration index and concentration curve," and "Gini coefficient and Lorenze curve" in consideration of the wealth index (v190), maternal education (v149), and full vaccination coverage (ch_allvac_either). I'd like to compute each indicator by division (v101). I am using R. I want to make certain that I am on the correct truck. The following is my R code:

############################################################ ############################################################ ###############################
#Rcode
## Calculate ridit score
KRvac\$ridit_score_wealth <- rank(KRvac\$v190, ties.method = "average") / nrow(KRvac)

# Loop to create a data frame with division and its corresponding SII, RII, and CI
divisions <- unique(KRvac\$v101)
sii_wealth_vec <- numeric(length(divisions))
rii_wealth_vec <- numeric(length(divisions))
ci_wealth_vec <- numeric(length(divisions))
gini_vec <- numeric(length(divisions))

for (i in 1:length(divisions)) {
KRvac_subset <- KRvac %>% filter(v101 == divisions[i])

model_wealth <- glm(ch_allvac_either ~ ridit_score_wealth, family = binomial(link = "logit"), data = KRvac_subset)

pred_wealth_top <- predict(model_wealth, newdata = data.frame(ridit_score_wealth = max(KRvac_subset\$ridit_score_wealth)), se.fit = TRUE)
pred_wealth_bottom <- predict(model_wealth, newdata = data.frame(ridit_score_wealth = min(KRvac_subset\$ridit_score_wealth)), se.fit = TRUE)

pred_wealth_top<-as.numeric(pred_wealth_top)
pred_wealth_bottom<-as.numeric(pred_wealth_bottom)

sii_wealth_vec[i] <- pred_wealth_top - pred_wealth_bottom
rii_wealth_vec[i] <- pred_wealth_top / pred_wealth_bottom

ci_wealth_vec[i] <- sii_wealth_vec[i]/(2*sqrt(rii_wealth_vec[i]))

n <- nrow(KRvac_subset)
y_values <- sort(KRvac_subset\$ch_allvac_either)
x_values <- sort(KRvac_subset\$ridit_score_wealth)
numerator <- sum((2 * (1:n) - n - 1) * y_values * x_values)
denominator <- n * sum(y_values) * sum(x_values)
gini_vec[i] <- numerator / denominator
}

results_df <- data.frame(division = divisions, sii = sii_wealth_vec, rii = rii_wealth_vec, ci = ci_wealth_vec, gini = gini_vec)

############################################################ ############################################################ ###############################

Here the plot code (Concentration Curve and Lorenze Curve) is not included. It would be greatly appreciated if anyone could assist me in ensuring that I am doing the right thing; if not, please correct my code; and I also require assistance with the plot code. I am a little bit confused about that.

Your early response will be appreciated

Thank you
Re: SII, RII, CI, and Gini [message #26102 is a reply to message #26072] Wed, 08 February 2023 09:44
 Janet-DHS Messages: 773Registered: April 2022 Senior Member
Following is a response from DHS staff member, Tom Pullum:

We (DHS staff) cannot help with questions that are not specifically about DHS data and indicators. Perhaps other forum users can review your R code.
Re: SII, RII, CI, and Gini [message #28095 is a reply to message #26072] Sat, 11 November 2023 12:48
 Lincoln Messages: 31Registered: July 2022 Member
Kindly share the solution if you have got it.

Regards
Re: SII, RII, CI, and Gini [message #28224 is a reply to message #26072] Mon, 04 December 2023 08:38
 vadapaavoo Messages: 1Registered: December 2023 Member

indigocard activate
roblox exploit

[Updated on: Wed, 03 January 2024 07:57]

Report message to a moderator

 Previous Topic: Minimum Dietary Diversity Next Topic: Childhood obesity
Goto Forum:

Current Time: Sat Jul 20 15:46:05 Coordinated Universal Time 2024