Shihan Mahfuz

Applied econometrics, R

Sanitation Gradient

How far household wealth buys access to improved sanitation in India. Seven nested logit models on 635,718 households: one standard deviation of wealth multiplies the odds nearly fivefold, and the gradient is weaker where the household is rural.

Read the paper PDF, 344 KB R Markdown source Rmd, 39 KB

  • 635,718households in the estimation sample
  • ×4.79odds of improved sanitation per standard deviation of wealth
  • 7nested logit specifications
  • 0.276McFadden pseudo-R², full model

The gradient, before any model.

Improved sanitation is close to universal in the richest fifth of households and reaches under half of the poorest. The urban to rural gap is nineteen points.

  1. 48%Poorest
  2. 72%Poorer
  3. 88%Middle
  4. 97%Richer
  5. 100%Richest
  6. 93%Urban
  7. 74%Rural
Share of households with improved sanitation, by wealth quintile and by residence. National Family Health Survey. Values read from the paper’s figures to the nearest point.

Seven specifications, one coefficient that holds.

The outcome is binary, so the model is a logit estimated by maximum likelihood, built up one block of controls at a time. Wealth enters as the standardised DHS wealth-index factor score. The odds ratio on wealth moves between 4.6 and 4.9 across six specifications; nothing added to the model absorbs it.

  1. SpecificationWealth, OR (SE)Rural, ORMcFadden R²
  2. M1Wealth4.792 (0.023)·0.253
  3. M2+ rural4.697 (0.024)0.8630.253
  4. M3+ female head4.697 (0.024)0.8630.253
  5. M4+ household size4.760 (0.024)0.8820.254
  6. M5+ education4.617 (0.025)0.884·
  7. M6+ religion4.868 (0.027)0.9050.275
  8. M7+ wealth × rural7.767 (0.122)0.8430.276

Odds ratios with delta-method standard errors. N = 635,718 in every column. All wealth and rural coefficients are significant at the 1% level. In M7 the wealth coefficient is the urban gradient.

Where the household is rural, wealth buys less.

Letting the wealth coefficient differ by residence splits the gradient in two. In urban areas one standard deviation of wealth multiplies the odds by 7.77. The interaction term is 0.585, so the rural gradient is about 41% weaker.

OR(wealth | rural) ≈ 7.767 × 0.585 ≈ 4.54

At mean wealth a rural household still has 0.843 times the odds of an urban one. The pattern fits a supply constraint: where sewerage and water service are thin, a household’s own resources convert into sanitation less efficiently.

Construction.

  • Data

    India’s National Family Health Survey household file, collapsed to one record per household across 36 states and union territories.

  • Outcome

    Improved sanitation, coded from toilet-facility type under the WHO classification. Households with unclassifiable facilities are excluded.

  • Regressor

    The DHS wealth-index factor score, standardised, so every coefficient reads per standard deviation.

  • Controls

    Residence, sex of the household head, household size, education in six bands, religion of the head.

  • Estimator

    Logit by maximum likelihood. Coefficients reported in log-odds and as odds ratios, with McFadden’s pseudo-R² for fit.

From the source.

The paper is a single R Markdown document: data handling, estimation and tables in one reproducible file. Three excerpts.

01Outcome

Coding improved sanitation.

Show the code: outcome
analysis.Rmd, outcomeRaw
clean_rdataset_5 <- clean_rdataset_5 %>%
  mutate(
    improved_sanitation = case_when(
      toilet_type %in% c(10,11,12,13,14,15,20,21,22,41) ~ 1,
      toilet_type %in% c(23,30,31,42,43,44,96) ~ 0,
      TRUE ~ NA_real_
    )
  ) %>%
  drop_na(improved_sanitation)

clean_rdataset_5$wealth_index_std <- scale(clean_rdataset_5$wealth_index_factor)

02Estimation

The nested sequence, M1 to M7.

Show the code: models
analysis.Rmd, modelsRaw
logit_m1 <- glm(improved_sanitation ~ wealth_index_std,
                data = clean_rdataset_5,
                family = binomial("logit"))

logit_m2 <- glm(improved_sanitation ~ wealth_index_std + place_of_residence,
                data = clean_rdataset_5,
                family = binomial("logit"))

logit_m3 <- glm(improved_sanitation ~ wealth_index_std + place_of_residence + sex_head,
                data = clean_rdataset_5,
                family = binomial("logit"))

logit_m4 <- glm(improved_sanitation ~ wealth_index_std + place_of_residence + sex_head + household_size,
                data = clean_rdataset_5,
                family = binomial("logit"))

logit_m5 <- glm(improved_sanitation ~ wealth_index_std + place_of_residence + sex_head + household_size + education_cat,
                data = clean_rdataset_5,
                family = binomial("logit"))

logit_m6 <- glm(improved_sanitation ~ wealth_index_std + place_of_residence + sex_head + household_size + education_cat + religion_head,
                data = clean_rdataset_5,
                family = binomial("logit"))

logit_m7 <- glm(improved_sanitation ~ wealth_index_std * place_of_residence +
                  sex_head + household_size + education_cat + religion_head,
                data = clean_rdataset_5,
                family = binomial("logit"))

03Inference

Odds ratios with delta-method standard errors.

Show the code: odds ratios
analysis.Rmd, odds ratiosRaw
# Odds ratios + (delta-method style) SEs on the OR scale
or_table <- function(model) {
  coef_df <- broom::tidy(model)
  coef_df$OR  <- exp(coef_df$estimate)
  coef_df$SE_OR <- coef_df$std.error * exp(coef_df$estimate)
  return(coef_df)
}

What this does not identify.

  • Causality

    One cross-section. Sanitation can raise health and earnings, so wealth and the outcome may move each other.

  • Omitted place

    No district or state fixed effects. Local infrastructure and programme roll-out are correlated with both wealth and sanitation.

  • Survey design

    Sampling weights and cluster-robust errors are not applied, which bears on inference more than on the point estimates.

  • Measurement

    The outcome records the type of facility, not whether it works or is used.

  • Next

    Weights and clustered errors, state fixed effects, and average marginal effects alongside the odds ratios.

  • Authors

    Written with Umesh, Faris and Mickey, a team of four. R, November 2025.

Read the paper PDF, 344 KB R Markdown source Rmd, 39 KB