---
title: "Research Project Report"
author: "Mahfuz"
date: "2025-11-17"
output:
  pdf_document:
    toc: true
    number_sections: true
    fig_caption: true
geometry: margin=1in
header-includes:
  - \usepackage{float}
  - \usepackage{setspace}
  - \usepackage{amsmath}
  - \usepackage{booktabs}
  - \usepackage{graphicx}
  - \usepackage{caption}
  - \usepackage{array}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE, eval = TRUE)

# Make sure the working directory is the folder containing this Rmd
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))

library(tidyverse)
library(haven)
library(janitor)
library(labelled)
library(stringr)
library(stargazer)
library(knitr)
library(kableExtra)
library(RColorBrewer)
library(broom)
library(DescTools)
```

# Abstract

This project examines **how far household wealth shapes access to improved sanitation in India**. We treat improved sanitation as the main outcome and use place of residence (urban/rural), access to electricity, and improved drinking water as supporting indicators of basic household services.  Using NFHS household data collapsed to one observation per household, we first document descriptive patterns by wealth and residence, then estimate a sequence of logistic regression models linking improved sanitation to standardized wealth and household characteristics (residence, sex of household head, household size, education, and religion).   The descriptive results show a steep wealth gradient and a persistent rural disadvantage.  Regression results reinforce this: wealth is strongly associated with higher odds of improved sanitation across all specifications, and rural households remain less likely to have improved sanitation even after controls. Finally, an interaction model indicates that the wealth gradient is weaker in rural areas than in urban areas, consistent with the idea that infrastructure and service constraints can limit how effectively household resources translate into improved sanitation. 

# Introduction

Our research question is **how far household wealth shapes access to improved sanitation in India**. We focus on sanitation as the main outcome and use place of residence, access to electricity, and safe drinking water as supporting indicators for basic services in the household. Household wealth and residence are strong markers of living conditions. Richer and urban households are more likely to have toilets that count as improved, while poorer and rural households often rely on unsafe or incomplete sanitation options. These gaps affect health and labour outcomes and make it harder for households to move out of poverty. Our aim is to document the sanitation gap across the wealth distribution and between urban and rural areas using household survey data, and to provide evidence that can inform infrastructure and welfare policies in India.

# Literature and Contribution

Global work on WASH shows persistent gaps in safely managed drinking water and sanitation, with rural and poorer households most likely to be excluded (Biswas et al. 2024; Srivastava et al. 2022).  In India, recent studies find that basic drinking water coverage is high, but safely managed water and sanitation lag behind, with spatial clustering and disadvantages for marginalized communities (Biswas et al. 2024; Ghosh, Hossain, and Sarkar 2023).  Micro-level evidence using IHDS-II shows wealth, urban residence, education of the household head, and region are key predictors of improved water and sanitation access (Gurung et al. 2023).  Case-based work highlights why sanitation improvements can be uneven: toilets may not be used when water supply is unreliable, women may have limited influence in sanitation decisions, and low literacy can reduce uptake (Dadhich, Dadhich, and Goyal 2022).  WASH deficits—especially poor sanitation, are linked to worse nutritional outcomes for adolescent girls and higher diarrhoea risk among older adults (Chattopadhyay et al. 2019; Srivastava et al. 2022). 
Most studies do not place the wealth gradient at the center using recent NFHS household data, and IHDS-based work predates large national programmes such as Swachh Bharat and Jal Jeevan Mission (Gurung et al. 2023).  District-level indices describe where deficits concentrate but do not show household-level variation (Biswas et al. 2024).  Our project puts wealth at the core: improved sanitation is the dependent variable, wealth is the main explanatory variable, and we examine how the sanitation gradient changes after controlling for residence and household characteristics, while also documenting how electricity and improved drinking water correlate with wealth and residence. 


# Data and Methods

## Data source and unit of analysis

We use India’s NFHS household data. Because the raw file contains multiple observations per household, we collapse the data to one row per household by grouping on the household identifier and taking the first observation for household-level variables (which are constant within households). We also explored the full dataset and made a new datasetonly with our interest variables.

```{r}
# Read dataset
clean_rdataset00 <- read_csv("selected_data_1.csv")

# choosing the first entry in each household
clean_rdataset00 <- clean_rdataset00 %>%
  group_by(hhid) %>%
  summarise(
    hv002 = first(hv002),      # household number
    hv009 = first(hv009),      # number of household members
    hv024 = first(hv024),      # state
    hv025 = first(hv025),      # type of place of residence (urban/rural)
    hv201 = first(hv201),      # source of drinking water
    hv205 = first(hv205),      # type of toilet facility
    hv206 = first(hv206),      # has electricity
    hv219 = first(hv219),      # sex of household head
    hv270 = first(hv270),      # wealth index quintile
    hv271 = first(hv271),      # wealth index factor
    hv108 = first(hv108),      # years of education
    hv101 = first(hv101),      # relationship to head
    sh47  = first(sh47)        # religion of the head
  )
```

## Exploration

After collapsing the dataset to one row per household, we perform an exploratory check of the numeric variables to understand the distribution of the data and identify any unusual values before recoding. We compute standard descriptive statistics (minimum, quartiles, median, mean, maximum). This step functions as a data-quality “sanity check” and provides baseline context for the later analysis.

```{r}
# creating a vector of all variables
vars <- c("hv201","hv205","hv270","hv025","hv219",
          "hv002","hhid","hv024","hv206","hv009","hv271","hv101","hv108","sh47")

# Subset numeric variables from vars
numeric_vars <- vars[sapply(clean_rdataset00[vars], is.numeric)]

# creating a summary of statistics of all the numeric variables
summary_df <- clean_rdataset00 %>%
  select(all_of(numeric_vars)) %>%
  summarise(across(everything(), list(
    Min = ~min(., na.rm=TRUE),
    Q1  = ~quantile(., 0.25, na.rm=TRUE),
    Median = ~median(., na.rm=TRUE),
    Mean = ~round(mean(., na.rm=TRUE), 2),
    Q3  = ~quantile(., 0.75, na.rm=TRUE),
    Max = ~max(., na.rm=TRUE)
  ), .names="{.col}_{.fn}")) %>%
  tidyr::pivot_longer(everything(), names_to=c("Variable","Stat"), names_sep="_", values_to="Value") %>%
  tidyr::pivot_wider(names_from=Stat, values_from=Value)

kable(summary_df, "latex", booktabs=TRUE, caption="Summary of Numeric Variables") %>%
  kable_styling(latex_options=c("striped","hold_position"), full_width=FALSE)
```

## Recoding Variables

NFHS variables are stored using numeric codes with short names (e.g., hv205, hv271). To make the analysis readable and to reduce the chance of coding errors later, we rename the variables into descriptive names. This step does not change the data itself, only the variable labels, so it improves interpretability while preserving the original information.

```{r,echo=TRUE, results='asis'}
# Renaming all variables with descriptive names
clean_rdataset_5 <- clean_rdataset00 %>%
  rename(
    household_id           = hhid,
    household_number       = hv002,
    household_size         = hv009,
    state                  = hv024,
    place_of_residence     = hv025,
    drinking_water_source  = hv201,
    toilet_type            = hv205,
    has_electricity        = hv206,
    sex_head               = hv219,
    wealth_index           = hv270,
    wealth_index_factor    = hv271,
    religion_head          = sh47,
    years_of_Educ          = hv108,
    rel_to_head            = hv101
  )
```

## Factors Variables

Many NFHS variables are categorical but recorded as numeric codes. We convert them to factors with meaningful labels so that tables, figures, and regression outputs are interpretable. Specifically, we label urban/rural residence, sex of household head, electricity access, wealth quintiles, and religion of the household head. After labeling, we create a frequency table for religion to describe the sample composition. We also calculate the number of missing observations in key categorical variables to make missingness transparent before finalizing the analytic sample.

```{r}
clean_rdataset_5 <- clean_rdataset_5 %>%
  mutate(
    place_of_residence = factor(place_of_residence, levels = c(1,2), labels = c("Urban","Rural")),
    sex_head = factor(sex_head, levels = c(1,2), labels = c("Male","Female")),
    has_electricity = factor(has_electricity, levels = c(0,1), labels = c("No","Yes")),
    wealth_index = factor(wealth_index, labels = c("Poorest","Poorer","Middle","Richer","Richest")),
    religion_head = factor(religion_head,
                           levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 96),
                           labels = c("Hindu", "Muslim", "Christian", "Sikh",
                                      "Buddhist/Neo-Buddhist", "Jain", "Jewish",
                                      "Parsi/Zoroastrian", "No religion", "Other"))
  )

religion_table <- table(clean_rdataset_5$religion_head)
religion_df <- as.data.frame(religion_table)
colnames(religion_df) <- c("Religion", "Count")
kable(religion_df, caption = "Distribution of Household Religion")
```

```{r}
categorical_vars <- c("place_of_residence", "sex_head", "has_electricity", "wealth_index")

na_counts <- clean_rdataset_5 %>%
  select(all_of(categorical_vars)) %>%
  summarise(across(everything(), ~sum(is.na(.)))) %>%
  tidyr::pivot_longer(cols = everything(), names_to = "Variable", values_to = "NA_Count")

kable(na_counts, "latex", booktabs = TRUE, caption = "Missing Values in Categorical Variables") %>%
  kable_styling(latex_options = c("striped","hold_position"), full_width = FALSE)
```

We apply two sample restrictions to ensure consistency in the regression sample. First, we drop observations with missing household-head sex (these are typically rare categories that cannot be mapped cleanly into Male/Female in this project design). Second, we remove households coded as “No religion” so that the religion variable captures identifiable religious categories used in the analysis.

```{r, echo=TRUE}
# dropping NA in sex_head and removing "No religion"
clean_rdataset_5 <- clean_rdataset_5 %>%
  drop_na(sex_head) %>%
  filter(religion_head != "No religion")
```

## Sanitation and Water Indicators

**Improved sanitation: ** We construct a binary indicator `improved_sanitation` based on toilet-type codes. Toilet types classified as improved are coded as 1, unimproved as 0, and any observations not falling into either category are treated as missing. We then drop missing values so every household in the final regression sample has a well-defined sanitation outcome. Standard WHO specifications for improved/unimproved sanitation were followed here.

**Improved water: ** We similarly construct `improved_water`, which classifies drinking water sources into improved vs unimproved categories. This is used to describe basic service access and can serve as an additional covariate in extensions if needed. Standard WHO specifications maintained here.

```{r, echo=TRUE}
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)
```

```{r, echo=TRUE}
clean_rdataset_5 <- clean_rdataset_5 %>%
  mutate(improved_water = case_when(
    drinking_water_source %in% c(11,12,13,14,21,31,41,51,71,92) ~ 1,
    drinking_water_source %in% c(32,42,43,61,62,96) ~ 0,
    TRUE ~ NA_real_
  ))
```

## Educational Attainment

Education is recorded as years of schooling but includes special codes for missing/unknown values. We first recode those special values (97–99) to missing. We then convert years of schooling into ordered education categories ranging from No education to University. This allows us to model education flexibly and interpret results as differences across education levels rather than assuming a constant linear effect for each additional year. Observations with missing education category are dropped to keep the regression sample consistent once education is included.


```{r, echo=TRUE}
clean_rdataset_5 <- clean_rdataset_5 %>%
  mutate(years_of_Educ = ifelse(years_of_Educ %in% c(97,98,99), NA, years_of_Educ)) %>%
  mutate(
    education_cat = case_when(
      years_of_Educ == 0                         ~ "No education",
      years_of_Educ >= 1 & years_of_Educ <= 5    ~ "Primary school",
      years_of_Educ >= 6 & years_of_Educ <= 8    ~ "Upper primary",
      years_of_Educ >= 9 & years_of_Educ <= 10   ~ "Secondary school",
      years_of_Educ >= 11 & years_of_Educ <= 12  ~ "Higher secondary",
      years_of_Educ > 12                         ~ "University",
      TRUE                                       ~ NA_character_
    )
  )

clean_rdataset_5$education_cat <- factor(
  clean_rdataset_5$education_cat,
  levels = c("No education",
             "Primary school",
             "Upper primary",
             "Secondary school",
             "Higher secondary",
             "University")
)

# Check table including NA
sum(is.na(clean_rdataset_5$education_cat))
clean_rdataset_5 <- clean_rdataset_5 %>%
  drop_na(education_cat)
```

## Standardizing Wealth Index Factor

Our main independent variable is household wealth, measured using the NFHS wealth index factor. Because the raw scale of the factor is not directly interpretable, we standardize it to a `wealth_index_std` variable. This allows interpretation in terms of a one–standard deviation increase in wealth, and it makes the wealth coefficient comparable across all model specifications.

```{r, echo=TRUE}
clean_rdataset_5$wealth_index_std <- scale(clean_rdataset_5$wealth_index_factor)
```
## Empirical strategy

Our dependent variable \(Y_i\) (improved sanitation) is binary (0/1), so we model the conditional probability
\[
p(X_i)=P(Y_i=1\mid X_i).
\]
A Linear Probability Model (LPM) can predict probabilities outside \([0,1]\) and is heteroskedastic by construction. We therefore use the NLBM(Non-Linear Binary Response Model)-**logit** model:
\[
P(Y_i=1\mid X_i)=\Gamma\!\left(\alpha+\sum_k \beta_k X_{ik}\right),
\]
where \(\Gamma(\cdot)\) is the logistic CDF,
\[
\Gamma(z)=\frac{\exp(z)}{1+\exp(z)}.
\]

For interpretation, the odds are
\[
\text{Odds}(x)=\frac{p(x)}{1-p(x)},
\]
and a one-unit increase in \(X_k\) multiplies the odds by the **odds ratio** \(\exp(\beta_k)\).
We build models sequentially (wealth only → add residence → add household structure → add education and religion → include a wealth×rural interaction) to show how robust the wealth gradient is and whether it differs between urban and rural households.

## Descriptive Statistics

After constructing the analysis variables and cleaning the sample, we summarize the geographic coverage of the dataset by reporting the distribution of households across Indian states. This table helps confirm that the analytic sample is nationally broad and not concentrated in only a few regions. In our cleaned household sample, the largest shares come from Uttar Pradesh (11.1%), Madhya Pradesh (6.8%), Bihar (5.6%), Rajasthan (5.0%), and Maharashtra (5.0%). 

```{r}
state_data <- data.frame(
  State = c(
    "Uttar Pradesh","Madhya Pradesh","Bihar","Rajasthan","Maharashtra",
    "Assam","Gujarat","Tamil Nadu","Telangana","Karnataka",
    "Odisha","Chhattisgarh","Jharkhand","Punjab","Haryana",
    "West Bengal","Jammu & Kashmir","Arunachal Pradesh","Kerala","Uttarakhand",
    "Andhra Pradesh","Himachal Pradesh","Meghalaya","Nagaland",
    "NCT of Delhi","Manipur","Mizoram","Tripura","Puducherry",
    "Sikkim","Dadra & Nagar Haveli and Daman & Diu","Andaman & Nicobar Islands",
    "Goa","Ladakh","Lakshadweep","Chandigarh"
  ),
  n = c(
    70628,43472,35788,31798,31605,
    30111,29345,27899,27341,26558,
    26416,24533,22823,18798,18212,
    18165,18086,17988,12310,12155,
    11331,10687,10129,10108,
    9469,7877,7229,7195,3515,
    3513,2666,2615,
    1853,1818,921,761
  ),
  percent = c(
    11.1,6.8,5.6,5.0,5.0,
    4.7,4.6,4.4,4.3,4.2,
    4.2,3.9,3.6,3.0,2.9,
    2.9,2.8,2.8,1.9,1.9,
    1.8,1.7,1.6,1.6,
    1.5,1.2,1.1,1.1,0.6,
    0.6,0.4,0.4,
    0.3,0.3,0.1,0.1
  )
)

kable(state_data, format = "latex", booktabs = TRUE, longtable = TRUE,
      caption = "Distribution of Households by State") %>%
  kable_styling(latex_options = c("repeat_header"))
```

### Graphs

1.**Sanitation by wealth quintile:** We compute the share of households with improved sanitation within each wealth quintile and plot it. The figure shows a steep wealth gradient: sanitation access rises systematically from the poorest to the richest quintile. 

```{r}
sanitation_by_wealth <- clean_rdataset_5 %>%
  group_by(wealth_index) %>%
  summarise(
    total = n(),
    improved = sum(improved_sanitation == 1, na.rm = TRUE),
    share_improved = improved / total
  )

quartile_colors <- brewer.pal(n = 5, name = "Set2")

ggplot(sanitation_by_wealth, aes(x = wealth_index, y = share_improved, fill = wealth_index)) +
  geom_col() +
  scale_fill_manual(values = quartile_colors) +
  scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
  labs(
    title = "Share of Households with Improved Sanitation by Wealth Quintile",
    x = "Wealth Quintile",
    y = "Share with Improved Sanitation"
  ) +
  theme_minimal(base_size = 14) +
  theme(
    plot.title = element_text(size = 12, face = "bold", hjust = 0.5),
    axis.title = element_text(face = "bold"),
    legend.title = element_blank()
  )
```

\newpage

2.**Sanitation by urban–rural residence.** We plot mean improved sanitation separately for urban and rural households. The figure shows a clear rural disadvantage. 

```{r}
sanitation_ur <- clean_rdataset_5 %>%
  group_by(place_of_residence) %>%
  summarise(share_improved = mean(improved_sanitation))

ggplot(sanitation_ur, aes(place_of_residence, share_improved, fill = place_of_residence)) +
  geom_col() +
  scale_y_continuous(labels = scales::percent) +
  labs(
    title = "Improved Sanitation by Urban–Rural Residence",
    x = "",
    y = "Share with Improved Sanitation"
  ) +
  theme_minimal() +
  theme(legend.position = "none")
```

\newpage

3.**Sanitation by education category.** We plot sanitation shares by education category to document a human-capital gradient: higher education is associated with higher sanitation access.
```{r}
education_san <- clean_rdataset_5 %>%
  group_by(education_cat) %>%
  summarise(share_improved = mean(improved_sanitation))

ggplot(education_san, aes(education_cat, share_improved)) +
  geom_col(fill = "#69b3a2") +
  scale_y_continuous(labels = scales::percent) +
  labs(
    title = "Improved Sanitation by Education Level",
    x = "Education Level",
    y = "Share with Improved Sanitation"
  ) +
  theme_minimal()
```

\newpage

4. **Sanitation by religion.** We plot sanitation shares by religion of household head to document compositional differences across social groups (interpreted cautiously as associations). 

```{r}
sanitation_religion <- clean_rdataset_5 %>%
  group_by(religion_head) %>%
  summarise(share_improved = mean(improved_sanitation))

ggplot(sanitation_religion, aes(religion_head, share_improved, fill = religion_head)) +
  geom_col() +
  scale_y_continuous(labels = scales::percent) +
  labs(
    title = "Improved Sanitation by Religion of Household Head",
    x = "Religion",
    y = "Share with Improved Sanitation"
  ) +
  theme_minimal() +
  theme(
    legend.position = "none",
    axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)
  )
```

# Regression

In this section, we estimate a sequence of logistic regression (logit) models to examine how household characteristics, especially standardized wealth, are associated with the probability of having improved sanitation. Logistic regression is appropriate because the dependent variable (\(Y_i\)) is binary (0/1), and the logit model directly estimates a probability while ensuring predicted values remain within \([0,1]\).

We fit the models stepwise to show how the estimated association between wealth and sanitation changes as additional covariates are added. Model 1 includes  standardized wealth only. Models 2–4 add **residence (urban/rural)** and household structure controls (sex of head, household size). Models 5–6 add **education** and **religion** of the household head. Model 7 includes a **wealth × rural** interaction to test whether the wealth gradient differs across urban and rural households. We report coefficients in **log-odds** and then present **odds ratios** by exponentiating coefficients for interpretation.

## Model formulas

* **Logit 1:**
\[
P(Y_i=1 \mid Wealth_i)=\Gamma(\alpha+\beta_1 Wealth_i)
\]

* **Logit 2:**
\[
P(Y_i=1 \mid Wealth_i, Rural_i)=\Gamma(\alpha+\beta_1 Wealth_i+\beta_2 Rural_i)
\]

* **Logit 3:**
\[
P(Y_i=1 \mid Wealth_i, Rural_i, Female_i)=\Gamma(\alpha+\beta_1 Wealth_i+\beta_2 Rural_i+\beta_3 Female_i)
\]

* **Logit 4:**
\[
P(Y_i=1 \mid Wealth_i, Rural_i, Female_i, HHsize_i)=\Gamma(\alpha+\beta_1 Wealth_i+\beta_2 Rural_i+\beta_3 Female_i+\beta_4 HHsize_i)
\]

* **Logit 5:**
\[
P(Y_i=1 \mid \cdot)=\Gamma\!\left(\alpha+\beta_1 Wealth_i+\beta_2 Rural_i+\beta_3 Female_i+\beta_4 HHsize_i+\sum_j \delta_j Edu_{ij}\right)
\]

* **Logit 6:**
\[
P(Y_i=1 \mid \cdot)=\Gamma\!\left(\alpha+\beta_1 Wealth_i+\beta_2 Rural_i+\beta_3 Female_i+\beta_4 HHsize_i+\sum_j \delta_j Edu_{ij}+\sum_r \theta_r Rel_{ir}\right)
\]

* **Logit 7 (interaction):**
\begin{equation}
\begin{aligned}
P(Y_i=1 \mid \cdot)
&=\Gamma\Big(\alpha+\beta_1 Wealth_i+\beta_2 Rural_i+\beta_3 (Wealth_i \times Rural_i) \\
&\quad+\beta_4 Female_i+\beta_5 HHsize_i+\sum_j \delta_j Edu_{ij}+\sum_r \theta_r Rel_{ir}\Big).
\end{aligned}
\end{equation}

Here \(Wealth_i=\) `wealth_index_std`, \(Rural_i=1\) if rural, \(Female_i=1\) if female head, and the education and religion terms are sets of dummy variables with a reference category.


```{r}
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"))
```


```{r,results='asis'}
stargazer(
  logit_m1, logit_m2, logit_m3, logit_m4,
  type = "latex",
  header = FALSE,
  title = "Logit Models 1–4: Wealth, Residence, Sex of Head, Household Size",
  dep.var.labels = "Improved Sanitation",
  covariate.labels = c("Wealth index std","Rural","Female Head","Household size"),
  single.row = TRUE
)

stargazer(
  logit_m5, logit_m6,
  type = "latex",
  header = FALSE,
  title = "Logit Models 5–6: Adding Education and Religion",
  dep.var.labels = "Improved Sanitation",
  covariate.labels = c(
    "Wealth index std","Rural","Female Head","Household size",
    "Primary school","Upper primary","Secondary school","Higher secondary","University",
    "Muslim","Christian","Sikh","Buddhist/Neo-Buddhist","Jain","Jewish","Parsi/Zoroastrian","Other"
  ),
  single.row = TRUE
)

stargazer(
  logit_m7,
  type = "latex",
  header = FALSE,
  title = "Logit Model 7: Interaction (Wealth × Rural)",
  dep.var.labels = "Improved Sanitation",
  covariate.labels = c(
    "Wealth index std","Rural","Female Head","Household size",
    "Primary school","Upper primary","Secondary school","Higher secondary","University",
    "Muslim","Christian","Sikh","Buddhist/Neo-Buddhist","Jain","Jewish","Parsi/Zoroastrian","Other",
    "Wealth index std × Rural"
  ),
  single.row = TRUE
)
```

```{r,results='hide'}
library(DescTools)
PseudoR2(logit_m1)
PseudoR2(logit_m2)
PseudoR2(logit_m3)
PseudoR2(logit_m4)
PseudoR2(logit_m5)
PseudoR2(logit_m6)
PseudoR2(logit_m7)
```

```{r}
mcfadden_values <- c(
  m1 = 0.2527462,
  m2 = 0.2529710,
  m3 = 0.2529711,
  m4 = 0.2543721,
  m6 = 0.2746583,
  m7 = 0.2764454
)


mcfadden_table <- tibble(
  Model = names(mcfadden_values),
  McFadden_R2 = as.numeric(mcfadden_values)
)

mcfadden_table

```

```{r}
# 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)
}

or_m1 <- or_table(logit_m1)
or_m2 <- or_table(logit_m2)
or_m3 <- or_table(logit_m3)
or_m4 <- or_table(logit_m4)
or_m5 <- or_table(logit_m5)
or_m6 <- or_table(logit_m6)
or_m7 <- or_table(logit_m7)
```

```{r,results='asis'}
stargazer(
  logit_m1, logit_m2, logit_m3, logit_m4,
  type = "latex",
  header = FALSE,
  title = "Odds Ratios from Logit Models 1–4",
  dep.var.labels = "Improved Sanitation",
  covariate.labels = c("Wealth index std","Rural","Female Head","Household size"),
  coef = list(or_m1$OR, or_m2$OR, or_m3$OR, or_m4$OR),
  se = list(or_m1$SE_OR, or_m2$SE_OR, or_m3$SE_OR, or_m4$SE_OR),
  single.row = TRUE,
  keep.stat = c("n", "ll", "aic")
)

stargazer(
  logit_m5, logit_m6,
  type = "latex",
  header = FALSE,
  title = "Odds Ratios from Logit Models 5–6",
  dep.var.labels = "Improved Sanitation",
  covariate.labels = c(
    "Wealth index std","Rural","Female Head","Household size",
    "Primary school","Upper primary","Secondary school","Higher secondary","University",
    "Muslim","Christian","Sikh","Buddhist/Neo-Buddhist","Jain","Jewish","Parsi/Zoroastrian","Other"
  ),
  coef = list(or_m5$OR, or_m6$OR),
  se = list(or_m5$SE_OR, or_m6$SE_OR),
  single.row = TRUE,
  keep.stat = c("n", "ll", "aic")
)

stargazer(
  logit_m7,
  type = "latex",
  header = FALSE,
  title = "Odds Ratios from Logit Model 7 (Interaction: Wealth × Rural)",
  dep.var.labels = "Improved Sanitation",
  covariate.labels = c(
    "Wealth index std","Rural","Female Head","Household size",
    "Primary school","Upper primary","Secondary school","Higher secondary","University",
    "Muslim","Christian","Sikh","Buddhist/Neo-Buddhist","Jain","Jewish","Parsi/Zoroastrian","Other",
    "Wealth index std × Rural"
  ),
  coef = list(or_m7$OR),
  se = list(or_m7$SE_OR),
  single.row = TRUE,
  keep.stat = c("n", "ll", "aic")
)
```

\newpage 

# Interpretation and Discussion

## Models 1–4: Wealth, residence, and household structure

We begin with baseline specifications that focus on household wealth and then progressively add core household characteristics. In Model 1, a one–standard-deviation increase in standardized wealth is associated with an odds ratio (OR) of 4.792, meaning that a one–SD increase in wealth multiplies the odds of having improved sanitation by 4.792×. This large and precisely estimated association establishes wealth as the central correlate of sanitation access. 

When residence is added in Model 2, the wealth effect remains virtually unchanged (OR = 4.702), indicating that the wealth gradient is not driven by urban–rural composition. Rural households face a substantial disadvantage: rural residence has OR = 0.863, meaning rural households have 0.863× the odds of improved sanitation relative to urban households, conditional on wealth. 

Model 3 introduces sex of the household head. The wealth OR remains 4.702, confirming the robustness of the wealth gradient. Female headship has OR = 1.003, close to 1 and not meaningful at this stage, suggesting little independent association once wealth and residence are controlled for. 

In Model 4, we add household size, which is negatively associated with sanitation outcomes. Household size has OR = 0.950, so each additional household member multiplies the odds of improved sanitation by 0.950× (about 5.0% lower odds). Once household size is included, female headship becomes negative (OR = 0.949, about 5.1% lower odds). Importantly, the wealth effect remains large (OR = 4.756), showing that wealth continues to dominate basic household characteristics in explaining sanitation access. 

Model fit (Models 1–4). McFadden’s pseudo-\(R^2\) is already high in the baseline model (about 0.253 in M1) and changes only slightly after adding residence and household structure (about 0.254 by M4), implying that wealth alone captures a large share of the explainable variation in sanitation access in this specification. 

## Models 5–6: Adding education and religion

Models 5 and 6 extend the analysis by incorporating education and religion of the household head. In Model 5, education displays a clear gradient. Relative to households with no education, primary education has OR = 1.191 and university education has OR = 1.380, meaning these categories multiply the odds of improved sanitation by 1.191× and 1.380×, respectively, net of wealth and household controls. Including education modestly reduces the wealth OR from 4.756 (M4) to 4.617 (M5), suggesting that some of the wealth gradient covaries with educational attainment, but the remaining wealth effect is still very large. Rural residence remains disadvantaged (OR = 0.884), implying that education alone does not remove the spatial gap. 
Model 6 adds religion, revealing heterogeneity across groups relative to the omitted reference category. For example, Muslim households have OR = 1.438, Sikh households OR = 1.495, and Christian households OR = 5.039. These are conditional associations and may reflect correlated geographic, socioeconomic, and infrastructure differences rather than causal “religion effects,” but they show that sanitation access is patterned along social lines even after controlling for wealth and education. Wealth remains strongly predictive (OR = 4.868) and the rural penalty persists (OR = 0.905). 

Model fit (Models 5–6). Adding education and religion improves overall fit: pseudo-\(R^2\) rises to roughly 0.275 by Model 6, indicating these covariates explain additional variation beyond wealth and residence. 


## Model 7: Wealth × rural interaction

Model 7 allows the effect of wealth to differ between urban and rural areas by introducing a wealth × rural interaction. The main wealth effect now captures the wealth gradient among urban households (the residence reference group): OR = 7.767, meaning a one–SD increase in wealth multiplies the odds of improved sanitation by 7.767× in urban areas. 
The interaction term has OR = 0.585, meaning the wealth effect in rural areas is multiplied by 0.585× relative to urban areas (i.e., attenuated by about 41.5%). Combining the two implies that in rural areas the wealth effect is approximately:
\[
OR_{\text{wealth|rural}} \approx 7.767 \times 0.585 \approx 4.54,
\]
so wealth remains strongly associated with improved sanitation in rural settings, but the magnitude is meaningfully smaller than in urban settings. 
The rural main effect in this interaction model is OR = 0.843, which should be interpreted as the rural–urban difference at average wealth (since wealth is standardized and equals zero at its mean). This implies rural households have 0.843× the odds (about 15.7% lower odds) of improved sanitation at mean wealth, holding the other controls constant. 
Model fit (Model 7). Fit increases slightly further in the interaction model, with pseudo-\(R^2\) around 0.276, suggesting that allowing the wealth gradient to differ by residence captures additional structure in the data. 

## Summary and discussion

Taken together, the stepwise models highlight three consistent patterns. First, wealth is the strongest predictor of improved sanitation across all specifications, with odds ratios remaining very large even after adding multiple controls. Second, education and religion explain meaningful additional variation and improve model fit, but they do not remove the wealth gradient or rural disadvantage. Third, location conditions the wealth effect: rural households face both lower baseline odds and a weaker wealth-to-sanitation translation, consistent with the idea that rural infrastructure and service constraints can limit how effectively household resources convert into improved sanitation.
These findings suggest sanitation inequality in India reflects both household-level resource constraints and broader structural barriers, especially in rural areas—implying that demand-side gains alone are unlikely to fully close sanitation gaps without complementary improvements in rural service delivery and infrastructure.


## Limitations

* **Cross-sectional design:** The NFHS snapshot limits causal interpretation. We cannot track changes over time, and **reverse causality** is possible (e.g., households with improved sanitation may experience better health and productivity, which can raise wealth).
* **Omitted variables / confounding:** Unobserved factors—especially local infrastructure, program implementation, and community environment, may be correlated with both wealth and sanitation. Without district or state fixed effects (or richer geographic controls), some estimated associations may partly reflect these omitted influences.
* **Survey design and sampling:** While NFHS is nationally representative, our regression setup does not fully implement sampling weights and clustering, which can affect inference.
* **Measurement:** “Improved sanitation” is code-based and may not capture functionality, quality, or consistent use; similarly, “improved water” reflects source type rather than reliability or safety at the point of use.

# Conclusion

This project examined how household wealth shapes access to improved sanitation in India using nationally representative NFHS household data. Across descriptive patterns and a sequence of logistic regression models, we consistently find a steep wealth gradient in sanitation access alongside a persistent rural disadvantage. In the baseline models, a one–standard-deviation increase in standardized wealth multiplies the odds of having improved sanitation by nearly five times, and this association remains large and stable after controlling for residence and household structure. Rural households face significantly lower odds of improved sanitation even when compared to urban households with similar wealth, highlighting spatial disparities that cannot be explained by income differences alone. Adding education and religion shows that human capital and social characteristics explain additional variation in sanitation access and improve overall model fit. Higher educational attainment is associated with systematically higher odds of improved sanitation, and sanitation outcomes differ across religious groups even after controlling for wealth and residence. However, these factors do not eliminate the wealth gradient or the rural penalty, indicating that economic resources remain central. The interaction model provides further insight by showing that the wealth gradient itself is weaker in rural areas. While wealth strongly increases the odds of improved sanitation in both settings, the same increase in wealth translates into substantially smaller gains in rural areas than in urban areas. This pattern is consistent with the presence of infrastructure and service constraints in rural areas that limit how effectively household resources can be converted into improved sanitation.

Overall, the findings suggest that sanitation inequality in India reflects both household-level resource constraints and broader structural barriers, particularly in rural areas. Policies aimed at reducing sanitation gaps are therefore likely to be most effective when they combine improvements in household economic conditions with targeted investments in rural sanitation infrastructure and service delivery, rather than relying on income growth or household-level demand alone.


# References

Biswas, Sourav, Mihir Adhikary, Asraful Alam, Nazrul Islam, and Ranjan Roy. 2024. “Disparities in Access to Water, Sanitation, and Hygiene (WASH) Services and the Status of SDG-6 Implementation across Districts and States in India.” *Heliyon* 10(18): e37646. https://doi.org/10.1016/j.heliyon.2024.e37646

Chattopadhyay, Aparajita, R. Roy, S. S. Pramanik, and K. A. Biswas. 2019. “WASH Practices and Its Association with Nutritional Status of Adolescent Girls in Poverty Pockets of Eastern India.” *BMC Women’s Health* 19(1): 89. https://doi.org/10.1186/s12905-019-0787-1

Dadhich, Ankita Pran, Pran N. Dadhich, and Rohit Goyal. 2022. “Synthesis of Water, Sanitation, and Hygiene (WaSH) Spatial Pattern in Rural India: An Integrated Interpretation of WaSH Practices.” *Environmental Science and Pollution Research* 29(57): 86873–86886. https://doi.org/10.1007/s11356-022-21918-z

Ghosh, Pritam, Moslem Hossain, and Sanjit Sarkar. 2023. “Inequality Among Social Groups in Accessing Improved Drinking Water and Sanitation in India: A District-Level Spatial Analysis.” *The Professional Geographer* 75(3): 361–382. https://doi.org/10.1080/00330124.2022.2124181

Gurung, Rajiv, Christopher Tirkey, Kishore Kumar Takri, Nimesh Diyali, Manesh Choubey, and Runa Rai. 2023. “Determinants of Access to Improved Drinking Water and Sanitation in India: Evidence from India Human Development Survey-II (IHDS).” *Water Policy* 25(10): 980–995. https://doi.org/10.2166/wp.2023.083

Srivastava, Shobhit, Snigdha Banerjee, Solomon Debbarma, Pradeep Kumar, and Debashree Sinha. 2022. “Rural–Urban Differentials in the Prevalence of Diarrhoea Among Older Adults in India: Evidence from Longitudinal Ageing Study in India, 2017–18.” *PLOS ONE* 17(3): e0265040. https://doi.org/10.1371/journal.pone.0265040
