Causal Inference ยท Data Analysis
A causal inference analysis of the relationship between loneliness and depression/anxiety outcomes using multivalued Double Machine Learning (DML).
The project estimates the causal relationship/effect of loneliness (lonely) on psych_85, adjusting for observed confounders.
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.
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.
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.
Scale Directionality:
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.
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.
The notebook compares several causal machine-learning approaches while using the same observed confounders:
The main DML comparisons are 2 vs 1, 3 vs 1, and 4 vs 1, with 95% confidence intervals.
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.
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%.
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.
| Comparison | RF ATE | XGB ATE | Lasso ATE | Causal Forest DML ATE | Stratified 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 |
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.