They did. One of the variables they statistically controlled for in the study is the “neighbourhood deprivation index”, which represents socio-economic living factors.
Adolescent Cannabis Use and Risk of Psychotic, Bipolar, Depressive, and Anxiety Disorders
This cohort study assesses the association of past-year cannabis use by adolescents with the risk of incident psychiatric, bipolar, depressive, and anxiety disorders by age 26 years.