Causal Inference ยท Data Analysis

Loneliness & Mental Health: Multivalued DML

A causal inference analysis of the relationship between loneliness and depression/anxiety outcomes using multivalued Double Machine Learning (DML).

Python Jupyter Double Machine Learning Random Forest XGBoost Lasso Causal Forest NLSAA

Research Question

The project estimates the causal relationship/effect of loneliness (lonely) on psych_85, adjusting for observed confounders.


Analysis Overview

The analysis uses the National Longitudinal Study of Adolescent to Adult Health (NLSAA) dataset, which includes 1,152 observations of individuals aged 50 and above. The outcome variable is a binary indicator of depression and/or anxiety, while the treatment variable is an ordinal measure of loneliness with four levels.

Outcome Definition

The outcome variable psych_85 indicates whether an observation reports depression and/or anxiety. Observations with psych_85 = 1 are classified as positive, indicating depression and/or anxiety, while observations with psych_85 = 0 are classified as negative, indicating no depression or anxiety.

Treatment Design

The loneliness score is treated as an ordinal, multi-valued discrete treatment. There is only one observation with lonely = 0, so this observation is removed before estimation.

Estimated treatment levels: 1, 2, 3, and 4
Reference level: loneliness level 1
Sample used for analysis: 1,151 observations

Scale Directionality:

0 = Always (Highest loneliness exposure)
1 = Most of the time
2 = Often
3 = Sometimes
4 = Never / Rarely (Lowest loneliness exposure)

The DML models use discrete_treatment=True, so the treatment is treated categorically rather than assuming that the change from one loneliness level to the next is constant.

Confounders

The analysis adjusts for observed demographic, socioeconomic, health, medication, mobility, and lifestyle-related variables, including age, sex, marital status, socioeconomic status, health indicators, smoking, medication, job status, walking and shopping minutes, mobility, and weight category.


Methodology

The notebook compares several causal machine-learning approaches while using the same observed confounders:

  • OLS as a linear benchmark
  • Random Forest DML
  • XGBoost DML
  • Lasso DML
  • Causal Forest as a sensitivity analysis for heterogeneous treatment effects

The main DML comparisons are 2 vs 1, 3 vs 1, and 4 vs 1, with 95% confidence intervals.

DML

Double Machine Learning (DML) estimates the causal effect of loneliness while controlling for observed confounders. It first uses machine-learning models to predict the treatment and the outcome from the confounders, removes these predicted components, and then estimates the remaining relationship between loneliness and the outcome.

Random Forest, XGBoost, and Lasso are integrated as alternative machine-learning methods for these prediction steps. Random Forest and XGBoost can capture nonlinear relationships, while Lasso provides a regularized linear benchmark. The estimated effects are compared with OLS, Causal Forest DML, and the stratified ATE with matching as complementary approaches and robustness checks.


Key Findings

Extreme loneliness significantly increases the likelihood of depression and anxiety by 35% to 50%. Because the baseline is extreme loneliness, the analysis does not focus on changes between the other loneliness levels (e.g., 2 vs. 3 or 3 vs. 4) using Random Forest DML, XGBoost DML, or Lasso DML.

The OLS benchmark indicates that a one-level increase in loneliness significantly increases the likelihood of depression and anxiety by approximately 4.68%.


Estimated Average Treatment Effects

The table below reports the estimated average treatment effects (ATE) relative to loneliness level 1. The estimates are shown for Random Forest DML, XGBoost DML, Lasso DML, Causal Forest DML, and the stratified ATE with Matching.

ComparisonRF ATEXGB ATELasso ATECausal Forest DML ATEStratified ATE
2 vs 1-0.416942-0.378268-0.411136-0.335887-0.405208
3 vs 1-0.490936-0.485662-0.488229-0.371851-0.455086
4 vs 1-0.352334-0.345495-0.345586-0.261117-0.343475

Limitations

Because there is only one observation at loneliness level 0, it is excluded to avoid estimating a treatment category from a single observation. The relatively small analysis sample of 1,151 observations may also limit the generalizability of the findings.

Future analyses could additionally consider factors such as social interaction, time spent alone, physical activity, sleep quality, workload, living situation, and financial stress.


Project File

๐Ÿ““
NLSAA_loneliness_DML_multivalued_notebook.ipynb
Full multivalued DML analysis notebook
Download
๐Ÿ“„
Data of Depression and Anxiety in the Elderly-NLSAAderived.csv
Dataset
Download