Social and environmental determinants of mental health

Environmental factors refer to external conditions and stimuli in the physical surroundings - such as pollution, climate patterns, noise, and urban infrastructure - many of which can affect mental health. Social factors encompass the features of interpersonal relationships, community structures, social networks, and cultural norms that shape individual well-being and influence mental health outcomes. Both social and environmental factors play an essential role for the development and progression of mental disorders. Conditions such as affective disorders, psychotic disorders, anxiety disorders, personality disorders, dementia or substance use disorders have all been linked to socio-environmental influences1,2,3,4,5. For example, several key aspects of urban living - such as social deprivation, high population density, limited access to green spaces or environmental pollution - have been identified as significant risk factors for the development of conditions like psychotic disorders6,7,8,9 or depression and anxiety10. Beyond contributing to the development of mental disorders, social and environmental factors have significant impact on their trajectory once they manifest. For example, social contacts, employment, adverse life events, education and access to healthcare have been linked to favourable outcomes across different mental disorders11,12. Importantly, many of these socio-environmental risk factors are considered to be modifiable, offering significant opportunities for interventions to improve mental health outcomes13. Moreover, social and environmental factors often interact in complex ways, as illustrated by the concept of resilience. Resilience implies that the adverse effects of environmental factors can be partially mitigated by individual traits, such as optimism14, protective social influences, such as the support provided by family members or strong social networks15 or by environmental factors such as green space16. These interactions highlight the importance of considering both social and environmental dimensions together when assessing mental health risks and outcomes. As urban environments continue to expand and encompass the majority of the world’s population17, understanding the complex interplay of social and environmental factors and mental health becomes increasingly critical for public health strategies and interventions.

Challenges in research of social and environmental determinants of mental health

Current research on the social and environmental determinants of mental health predominantly relies on observational data. Several methodologies have been employed to infer causality in this context (e.g. structural equation modelling, propensity score matching, Mendelian randomization or Bayesian networks)18. However, these methods often rely on assumptions that may not hold in real-world settings or are difficult to verify, thereby limiting their effectiveness in identifying causal pathways. Moreover, most research focuses on individual social or environmental factors, or aggregates them into summary measures such as an exposome score19 or indices of social vulnerability 20, overlooking the complex and multifaceted interactions between these influences21. If such interactions are investigated systematically they can be found to be highly superadditive22.

A complementary approach to investigate socio-environmental influences involves using “agents”23. Agents are typically computational entities that interact autonomously within virtual environments. They are programmed to simulate human behaviour by interacting with the environment or other agents, or by making decisions based on past experiences, memory, and internal rules. One key advantage of agent-based approaches is that they are able to generate emergent phenomena which are not explained by a system’s individual parts23. Some early works have employed agent-based approaches to model health-related behaviours24,25,26,27,28,29,30,31. However, for studying mental health current agent-based approaches face significant limitations. First, these simulations are typically based on highly simplified environments, resulting in limited ecological validity. Furthermore, these simulations often prioritize observable agent behaviors as their primary outcomes. While behavior is an important aspect of mental health, this focus neglects the subjective experiences and internal states that are central to understanding mental health. To better capture the complexity of mental health outcomes, it is necessary to integrate detailed readouts related to psychopathological symptoms, such as mood, anxiety, or stress. Without this level of granularity, the simulations fail to reflect the nuanced and multifaceted nature of mental health and its determinants.

Given these challenges, there is an urgent need for advanced research methodologies that can robustly identify causal relationships among socio-environmental determinants and ultimately allow for more effective mental health interventions.

Large-language models and generative agents for modelling human behaviour

A recent line of research employed large-language models (LLMs) to create generative agents with the aim to simulate human behaviour32,33. Interestingly, this approach has the potential to overcome some of the aforementioned limitations of previous simulation endeavours including aspects of the limited ecological validity and the unspecific read-outs.

In general, LLMs are a subset of artificial intelligence models designed to process and generate data in textual formats, demonstrating remarkable performance across a wide range of tasks. Models like GPT-4, LLaMA, and Mistral are prominent examples, trained on vast corpora of text as well as image or video data that encapsulate diverse aspects of human experience and knowledge. Given that the training data used to develop these models is predominantly generated by humans, reflecting their thoughts, emotions, and behaviours, it is unsurprising that LLMs have shown a capacity to recreate plausible human behaviour in specific contexts34,35,36. For example, traumatic narratives make LLMs score higher on anxiety questionnaires37. Moreover, inducing “anxiety” in LLMs alters their responses in cognitive tasks38 indicating that LLMs can mimic human cognitive processes and thus offer a novel tool for investigating thought and behaviour39.

Recent studies have also explored the potential applications of LLMs in medicine, identifying several promising uses, particularly in psychiatry40. For instance, LLMs show good performance in medical question answering in medical exams and case reports41, can perform diagnostic interviews42 and contain information relevant to mental disorders43.

Recent work has explored the integration of LLMs into generative agents to simulate human behavior, with a notable study by Park et al. demonstrating significant progress in this domain32. In their work, generative agents were employed in a virtual village of houses and roads in which the agents could interact autonomously, generating behaviors and social interactions that resemble human dynamics. The key innovation in Park et al.’s approach lies in the incorporation of a cognitive architecture that allows for a much richer repertoire of behaviors and interactions, enabled by modern LLMs (Fig. 1). This architecture includes a long-term memory system that stores past experiences, which are then retrieved based on factors like recency, importance, and relevance to the current context. When confronted with a novel situation, the agents query an LLM while incorporating these relevant memories into the prompt, ensuring that their responses are contextually grounded. Additionally, these agents possess the ability to reflect - an iterative process where they review past experiences, draw insights, and adapt their behaviors accordingly. This reflective mechanism enhances the realism of their interactions and decision-making, enabling them to exhibit character-consistent behaviour. By combining these features, Park et al.’s generative agents go beyond the capabilities of traditional simulation approaches. They can generate nuanced social interactions, exhibit adaptive behaviors, and capture a broader spectrum of human experiences, making them a powerful tool for investigating the intricate interplay between social and environmental factors in mental health research.

Fig. 1: Generative agent framework for simulating human behavior.
figure 1

Generative agents utilise prompts to LLMs to integrate environmental cues with stored memories, enabling the generation of contextually appropriate actions32. A retrieval mechanism ranks memories based on criteria such as situational relevance, selecting those most pertinent for inclusion in the current prompt to the LLM. Personality traits and other individual characteristics can be incorporated into the prompt to ensure consistent, character-driven behaviour. The ability to reflect allows generative agents to generate new insights from past experiences and to store them as new memories.

Research applications of generative agents for investigating socio-environmental determinants of mental health

Generative agents could be embedded within virtual environments, enabling simulations of socio-environmental systems to study mental health. These environments could include data-driven replications of actual urban settings, allowing for the examination of specific geographic and structural factors (e.g., population density, proximity to green spaces, and access to mental health services) and their impacts on mental health outcomes. Within these simulations, agents could freely interact with each other and their surroundings, offering the opportunity to systematically manipulate social and environmental variables (Fig. 2). These virtual environments would allow for the alteration of agents’ biographical backgrounds, personality traits, or cognitive characteristics (e.g., long-term memory). Due to the dynamic nature of such simulations, continuous processes with relevance to mental health such as ageing or migration could be modelled efficiently. As the agents are based on LLMs, they could easily be prompted with established mental health questionnaires, enabling them to self-report symptoms (Fig. 2)37. Alternatively, generative agents could be programmed to function as virtual psychologists, capable of detecting symptoms and diagnosing disorders based on interactions with other agents. This generative agent framework could offer a novel method for experimentally investigating how socio-environmental factors influence mental health outcomes, potentially advancing our understanding of mental health in real-world contexts.

Fig. 2: Using LLM-based generative agents to investigate the effects of adverse life events on mental health.
figure 2

Generative agents can be created with personalized biographies and exposed to virtual adverse and non-adverse life events. Adverse events, such as job loss, bullying, or loneliness can simulate stressors with negative impact on mental health. Subsequently agents can be prompted to self-report their mood or mental health status using standardized scales enabling the assessment of their mental health in these scenarios.

Microlevel simulations of socio-environmental systems

Microlevel environments, such as families, dyads (pairs of individuals), or peer groups, are shaped significantly by individual characteristics (e.g., personality traits, beliefs, values, cognitive attributes) and the nature of their interpersonal relationships (e.g., dyadic interactions, social networks, group dynamics). Socio-environmental factors within these systems, such as childhood trauma44,45,46, bullying47,48, and loneliness49,50, have been shown to exert profoundly detrimental effects on mental health (Table 1). While epidemiological and qualitative research has provided valuable insights into these phenomena, agent-based simulations offer a complementary framework that enables the exploration of potentially causal mechanisms and dynamic interactions that are challenging to capture through observational approaches alone. For instance, simulations allow the controlled manipulation of variables enabling the study of “what-if” scenarios that are impractical or unethical to investigate in real-life settings (Fig. 2). Furthermore, these agent-based models could address a key limitation of observational research e.g. by providing a testbed for understanding how internal states (e.g., cognitive processes) interact with external environments over time or by incorporating confounding factors that often bias observational studies.

Table 1 Socio-environmental determinants of mental health according to micro-, meso- and macrolevel societal systems

As a specific example, simulations could explore whether adverse events are particularly detrimental during vulnerable developmental periods51,52,53, providing insights into the timing of interventions. Similarly, they could assess how negative social encounters might diminish mental health or how positive interactions could foster resilience and aid in overcoming challenging life circumstances54,55. These simulations also provide a novel opportunity to study system-level phenomena, such as how specific family structures might buffer against, or exacerbate, the effects of adversity56 or how negative influences could propagate through dysfunctional family systems to indirectly affect others (Fig. 3).

Fig. 3: Modern Urban Environments and Their Socio-Environmental Influences on Mental Health.
figure 3

Modern urban environments are characterised by multiple socio-environmental influences and complex micro- and mesolevel interactions with relevance for mental health of inhabitants.

Additionally, agent-based models can simulate the effects of psychotherapeutic interventions on mental health57,58, offering a way to tailor treatment strategies to individual needs based on personality structures or other characteristics. By modeling these interventions in-silico, such approaches can optimize resource allocation and refine hypotheses for real-world application. Rather than replacing traditional research methods, these simulations serve as a complementary tool, enhancing our ability to test hypotheses, explore dynamic systems, and bridge gaps in understanding that are otherwise difficult to address. This integrative approach provides actionable insights for clinical practice and policy-making, particularly in tailoring interventions to improve mental health outcomes40.

Meso- and macrolevel simulations of socio-environmental systems

In meso- and macrolevel contexts, factors such as physical properties of the environment or the infrastructure of the community are of increasing importance (Table 1). Environmental stressors like noise, air, light and visual pollution as well as climate change have been shown to have severe effects on mental health and well-being7,59,60,61 which are expected to aggravate in the coming years. Conversely, access to public transportation26, green spaces16, canals and rivers62 as well as sports and healthcare facilities63 is essential to support mental health. Using agent-based simulations we can achieve a more detailed understanding of how these factors act and interact to allow a more complete picture of how mental health evolves in dynamic urban environments.

One promising application of agent-based simulations is to explore how combinations of environmental stressors - such as noise, air pollution, and lack of green spaces - affect mental health outcomes in specific urban settings. These simulations could allow researchers to identify which mitigating strategies, such as green space allocation or noise reduction measures, are most effective in reducing the mental health burden. Furthermore, simulations could help to forecast mental health outcomes under hypothetical scenarios, such as rising temperatures or increased urbanization, helping to develop climate-resilient strategies for mental health support.

Another potential application is in guiding urban planning and policy-making. For example, simulations can optimize the placement of parks, healthcare facilities, or public transport stops by modeling their effects on reducing loneliness and improving mental health in underserved areas64. They could also enable researchers to explore long-term systemic effects, such as how improved access to public transportation might mitigate the combined impact of environmental and social stressors over longer time periods.

Incorporating additional variables, such as somatic diseases or mobility restrictions, into these simulations provides further insights into vulnerable populations, such as older adults. While aging is often associated with increased health challenges, older adults who remain mentally and physically active can exhibit resilience and improved outcomes, highlighting the potential for active aging. Simulations could assess how urban design improvements, such as increased accessibility, might reduce the mental health burden among ageing populations. Similarly, agent-based models can be used to test interventions aimed at specific demographic groups, allowing for the tailoring of strategies to the needs of diverse communities.

In summary, agent-based simulations serve as a powerful tool for addressing complex research questions that are challenging to tackle through observational or experimental methods alone. By capturing the dynamic interplay between global influences, such as climate change, and locally variable factors, such as air pollution and infrastructure, these models enhance our understanding of the determinants of mental health. They also provide actionable insights for designing evidence-based interventions, informing future public health strategies, and optimizing urban planning to foster mental well-being.

Validation of Generative Agents in Mental Health Research

Systematic methods need to be developed to validate the accuracy and reliability of generative agents for studying mental health. One promising approach is to replicate established psychological findings within these simulated environments. For instance, the personality trait of neuroticism is consistently associated with a higher risk of affective disorders65, and individuals in specific developmental periods (e.g. adolescence) are particularly vulnerable to adverse events that can have lasting effects on mental health52,66. To recreate such findings, agents could be assigned developmental characteristics reflective of adolescence, such as heightened emotional sensitivity or increased susceptibility to peer influence, and placed in virtual environments representing real-world contexts like schools, peer groups, and families. Adverse events, such as bullying or social exclusion, can then be introduced as controlled scenarios, enabling researchers to track their impact on the agents over time.

The outcomes of these simulations can be assessed using longitudinal in silico studies. For example, generative agents could periodically complete standardized mental health assessments, such as the PHQ-9 for depressive symptoms67, the GAD-7 for anxiety68, or tools specifically designed to measure subjective stress levels, such as the Perceived Stress Scale (PSS)69 or the Perceived Stress Questionnaire (PSQ)70. By measuring changes in these scores over time, researchers can evaluate how adverse experiences during adolescence influence mental health trajectories into adulthood. Comparing these simulated results to empirical findings from longitudinal studies provides a means of validating the models’ ability to mirror real-world psychological phenomena.

Further validation can be achieved by investigating whether the simulated environments can replicate observed empirical patterns or predict novel outcomes. For example, simulations could explore the interaction of neuroticism with environmental stressors, testing whether the predicted outcomes align with real-world data. Additionally, data from digital sensing technologies (e.g., actimetry, speech markers) and ecological momentary assessments can be used to augment agent behaviors, ensuring alignment with real-world behavioral patterns and enhancing the realism of the simulations71,72,73.

Ultimately, the ability of generative agents to consistently replicate both established and novel empirical observations will be critical for their acceptance and utility. Validated models could provide deeper insights into how socio-environmental moderators influence mental health and a powerful tool to explore the mechanisms underlying mental health outcomes and design targeted interventions.

Challenges in Using Generative Agents for Mental Health Research

While LLMs present significant potential for advancing mental health research by simulating social and environmental determinants, their use is accompanied by several notable challenges. Firstly, most LLMs are designed as general-purpose models which are not specifically tailored to model human behaviour for mental health research. Approaches such as fine-tuning to domain-specific datasets is a common practice that can significantly enhance their performance for targeted use cases including mental health74. A related challenge is the limited availability of detailed, high-quality datasets from individuals with validated mental illness diagnoses. This scarcity could hinder the ability to train and validate models that accurately capture the nuances of mental health conditions. One promising source of rich and accurate data to train these models could be audio and video recordings of social interactions, such as normal conversations within families or friends, as well as interactions in psychotherapy sessions. These recordings can capture a wide range of emotional responses and social dynamics, providing detailed and realistic insights into human behavior. Additionally, ecological momentary assessments (EMAs) and audio diaries offer a complementary approach, allowing the collection of emotionally rich data in naturalistic settings with high temporal precision. These methods capture emotional experiences as they occur in daily life, providing an ecologically valid and temporally precise assessment of how emotions evolve in response to real-world contexts.

Another important limitation is that by design LLMs operate within the domain of language. Many facets of mental health risk and resilience operate causally at the origin of individual life (genetic risk) or in early childhood (urban upbringing, many forms of abuse) and it is not immediately obvious how this could be reflected in a language-based agent. Even in adulthood, data show that many resilience factors are influencing behaviour outside awareness (e.g. greenspace visibility in urban contexts16) and would not be reflected in language. Even if they were, the question remains how language-based training datasets would reflect such context factors. It is likely that human social behaviours are best represented both in training data and in language based models and might thus be a useful initial focus of using generative agents.

One of the primary ethical concerns involves the inherent biases within LLMs, particularly towards minority groups75,76,77. AI models are often trained on vast datasets that may contain prejudices and stereotypes, which can be inadvertently perpetuated and even amplified when these models are deployed in research or clinical settings78. Addressing these biases is crucial to ensure that LLMs do not contribute to discrimination or unequal treatment in mental health interventions. Ethical considerations also include the generalizability of potential findings in mental health derived from generative agents. As the majority of training data for LLMs is derived from western world, it is to be expected that this line of research might not perform well in cultural contexts which are not sufficiently represented in these models. Thus, researchers must consider both minorities underrepresented in training data and vulnerable populations facing systemic disadvantages, such as poverty or severe mental illness.

Furthermore, the capacity of LLMs to model human behaviour presents both opportunities and risks. While these models could potentially be used to promote positive mental health outcomes, there is also the danger of their being exploited to manipulate behaviour in harmful ways. These hazards need to be considered in future research and safeguards need to be established.

Lastly, technical challenges remain with generative agents, particularly the computational demands of simulating large environments like virtual cities, which can cause bottlenecks. Additionally, many mental health researchers lack the programming skills to fully utilize these tools. To address these issues, future efforts should aim to make generative agents more accessible by developing user-friendly platforms and automated processes. This would enable a broader range of researchers to engage with these technologies more effectively, fostering interdisciplinary collaboration.

Outlook of generative agents in mental health research

Besides the mentioned promising applications of generative agents from mental health research, there is a range of further developments and expansions of this framework which might provide future fruitful research avenues.

As an example, the current form of generative agents includes some form of cognitive architecture consisting of a memory, a retrieval mechanism and the ability to reflect on previous experiences32. At the same time, decades of mental health research has generated a wealth of cognitive models ranging from Beck’s cognitive models of depression79 or behavioural analysis of stimulus and response80 to modern models in the area of computational psychiatry81,82,83. Including these rich models in the context of generative agents might help to stimulate future investigations of the interplay of cognitive processes and socio-environmental influences. Furthermore, there are known biological consequences of exposure to socio-environmental risk factors such as substances of abuse (e.g. cannabis, tobacco), childhood maltreatment, air pollution or loneliness10,50,84,85,86. Expanding generative agents by integrating such biological processes, might improve the modelling of the effects on mental health27. Another potential research direction is the investigation of specific policies and how they affect mental health outcomes. As an example Occhipinti et al. employ a system-level approach to simulate how socioeconomic policies can impact suicide rates87.

Lastly, generative agents offer a unique platform for fostering interdisciplinary collaboration. Psychologists and psychiatrists can contribute specialised knowledge of mental health, while computer scientists provide expertise in stimulating environments and optimising the use of LLMs. Sociologists and epidemiologists can lend insights into socio-environmental factors, and ethicists can ensure responsible implementation.

Conclusion

Generative agents powered by LLMs could offer an innovative approach to advancing mental health research by simulating the intricate interplay of socio-environmental determinants on mental health outcomes. By creating realistic virtual environments where agents exhibit human-like behaviours and interactions, researchers could systematically manipulate variables and observe emergent phenomena that are difficult to capture through traditional observational methods. This innovative framework holds the potential to deepen our understanding of mental health dynamics at micro-, meso-, and macro-levels, while also contributing to broader research on whole health, which integrates physical, behavioral and socioeconomic dimensions of well-being.