Artificial intelligence and smartphones for predicting opioid use outcomes
Despite effective treatments for opioid use disorder, relapse and treatment dropout persist. Predicting these in advance – using real-time data from patients’ daily lives – could enable just-in-time adaptive interventions that help prevent them. This study investigates whether daily smartphone assessments, combined with artificial intelligence, can identify when someone in treatment is at risk of relapse or dropping out.
Relapse and suboptimal treatment retention are driven by complex, interacting factors. Yet, most prior research has focused on static, group-level risk factors (e.g., sex, age, or substance use history), which do not adequately capture the dynamic, daily fluctuations in stress, mood, cravings, or social context that shape recovery trajectories. Understanding these moment-to-moment influences can help inform just-in-time adaptive interventions that detect heightened risk and deliver timely, personalized support when it is most needed. This study sought to address the first step in this process by testing whether ecological momentary assessment – brief smartphone app-delivered surveys completed several times per day that asked about participants’ stress, mood, cravings, pain, withdrawal symptoms, substance use, and environmental context – combined with artificial intelligence-based deep learning models could accurately forecast future risks of non-prescribed opioid use (i.e., relapse), buprenorphine nonadherence, or treatment dropout.
HOW WAS THIS STUDY CONDUCTED?
This study was a secondary analysis of data from a 12-week observational study involving 62 adults (mean age = 37 years) receiving buprenorphine for opioid use disorder (often prescribed in a formulation with naloxone, known as Suboxone) at an outpatient addiction treatment clinic in California between June 2020 and January 2021. Participants were predominantly White (71%) and about half were male (50%). During the study period, more than half self-reported non-prescribed opioid use (52%) or medication non-adherence (55%) at least once.
Primary outcomes included: 1) self-reported non-prescribed opioid use (via daily smartphone surveys), 2) self-reported buprenorphine nonadherence (via daily smartphone surveys), 3) objective buprenorphine nonadherence (based on prescription information in electronic health records), and 4) objective retention in opioid use disorder treatment (based on prescription information in electronic health records).
Predictors were drawn from ecological momentary assessments (i.e., brief daily smartphone surveys delivered 3 times daily) that asked about participants’ sleep, medication adherence, stress, pain, cravings, withdrawal symptoms, mood, self-regulation, and social/environmental context, as well as substances used in the past hour or past day. Across all participants, 14,322 observations from these daily smartphone surveys were collected. Any missed opioid use report was counted as having used an opioid; any missed medication adherence report was counted as having not adhered to one’s medication plan. Assuming bad outcomes if missing are common, conservative methods of accounting for missing data.
For the analysis, the researchers used recurrent deep learning models (a type of artificial intelligence) to test whether patterns in the smartphone survey data could predict next-day outcomes. They did this by looking at 7-day blocks of survey responses at a time. For example, data from days 1-7 were used to see if the model could correctly forecast outcomes for days 2-8. Then the window shifted forward by 1 day (days 2-8 used to predict days 3-9), and so on. This process was repeated across the entire 12-week study, allowing the model to learn from many overlapping sequences of data. Separate models were built for each of the 4 outcomes (e.g., self-reported non-prescribed opioid use, self-reported buprenorphine nonadherence) and for each of the 12 types of daily survey items (e.g., cravings, mood), resulting in 48 models in total. Model accuracy was evaluated using a statistic called the area under the curve (AUC), a value between 0 and 1 where 0.50 means the prediction is no better than chance and values above 0.70 are considered moderately accurate. To better understand what was driving the model predictions, the researchers also applied an interpretability method that highlighted which daily survey items were most influential in shaping the forecasts.
WHAT DID THIS STUDY FIND?
Daily smartphone survey data predicted relapse risk especially well
Models predicting next-day non-prescribed opioid use (called “relapse” in the study) performed with very high accuracy. See graphic below. The strongest predictors of next-day opioid use were self-reported substance use in the past hour (AUC = 0.97; non-prescribed opioids, cocaine, methamphetamine, benzodiazepines, cannabis, alcohol); situational risk cues such as current alcohol or nicotine use and exposure to triggers like stress or seeing drug cues (AUC = 0.93); self-regulation difficulties like low ability to plan or follow through (AUC = 0.92); mood states including boredom, exhaustion, or low contentment (AUC = 0.91); and social or environmental context (AUC = 0.90), which captured where participants were, who they were with, and what activities they were engaged in. Further analysis indicated that relapse risk was influenced both by low-latency (immediate) predictors, such as context (e.g., being at a bar or club) and mood (e.g., boredom, exhaustion) that raised risk within hours to the next day, and by high-latency (delayed) predictors, such as pain and stress levels, which accumulated risk more gradually over several days.
Treatment retention could also be forecasted well
Models predicting whether participants remained in treatment, based on electronic health record data, also performed strongly. See graphic below. The most important predictors were social and environmental context (AUC = 0.89), reports of recent substance use in the past hour (AUC = 0.86), self-regulation (AUC = 0.85), mood (AUC = 0.83), and cravings (AUC = 0.81). Further analyses indicated that the strongest predictors of treatment discontinuation generally operated at higher time latencies, with mood (boredom and exhaustion), self-regulation (difficulty planning or finishing tasks), cravings for cocaine and methamphetamine, nicotine use, pain, and social or environmental context (reporting recent drug use in one’s environment) forecasting dropout risk several days in advance rather than immediately.
Buprenorphine nonadherence was harder to predict
Models predicting self-reported buprenorphine nonadherence performed poorly, with a best AUC of 0.68, below the threshold for moderate accuracy. See graphic below. Context and recent substance use were the most informative predictors but only provided limited signal. In contrast, objective buprenorphine nonadherence, based on prescription information in electronic health records, was predicted moderately well. The strongest predictors were situational risk cues (AUC = 0.79), self-reported buprenorphine adherence (AUC = 0.79), substance use in the past hour (AUC = 0.78), self-regulation (AUC = 0.77), and mood (AUC = 0.77). Further analyses indicated that objective buprenorphine nonadherence was most strongly linked to high-latency predictors, including self-regulation (difficulty planning or finishing tasks), mood (bored, exhausted, discontent), cravings for cocaine, and past hour substance use (any non-prescribed opioid, crack cocaine, benzodiazepines, alcohol, or cannabis), which forecasted risk over several days. Low-latency predictors such as nicotine use and pain level also contributed, influencing outcomes more immediately.
WHAT ARE THE IMPLICATIONS OF THE STUDY FINDINGS?
This study demonstrates that pairing brief daily smartphone assessments with artificial intelligence-based prediction models can yield clinically useful early warning signals of opioid use and treatment discontinuation, and, to a lesser extent, medication nonadherence, among individuals in outpatient treatment for opioid use disorder.
Findings highlight the potential for smartphone and other digitally collected psychological and contextual data to predict both self-reported outcomes such as non-prescribed opioid use and objective outcomes from electronic health records, such as buprenorphine nonadherence and treatment dropout. The study also identified different time windows of risk. Some predictors – such as mood, particularly boredom and exhaustion, and being in high-risk contexts where substance use was present – signaled elevated risk for non-prescribed opioid use within hours. Other predictors, such as stress and pain, forecasted relapse risk several days in advance. However, the study did not report, if a certain risk factor was present, how many days it would take for the negative outcome to occur (i.e., opioid use). Most predictors of treatment retention operated at higher time latencies, with mood, self-regulation, cravings, and pain forecasting treatment discontinuation several days in advance.
Consistent with prior research, and as might be expected, substance use in the past hour was among the most influential predictors across outcomes, underscoring the intuitive role of recent substance use in predicting future substance use-related behaviors.
In terms of what predicts this initial substance use, it is worth noting that cannabis use was among the influential recent substance use items in predicting non-prescribed opioid use and treatment discontinuation, consistent with prior findings indicating that cannabis use may increase risk for opioid use and hinder recovery efforts. Self-regulation consistently emerged as a strong predictor across outcomes, echoing prior research linking factors such as perseverance, sensation seeking, andemotion regulation with substance use and substance use disorder. Mood states such as boredom and exhaustion were similarly important predictors across outcomes, reinforcing the role of negative affect in relapse risk and treatment engagement. Together, these findings suggest that recent substance use (including alcohol and cannabis use, as well as an initial return to opioid use), mood and emotional states, difficulties with self-regulation, and day-to-day social and environmental contexts can serve as strong early warning signals of relapse and treatment discontinuation.
Results from latency analyses further suggest that predictive signals of risk differ in timing across outcomes. Non-prescribed opioid use was shaped by both low latency factors – such as social and environmental context, self-regulation, and mood, which signaled risk within hours to the next day – and higher latency factors like pain and stress, which signaled risk several days in advance. By contrast, many predictors of buprenorphine nonadherence and treatment discontinuation, such as cravings, self-regulation difficulties, mood, and past-hour substance use, showed longer latencies, sometimes detectable 5 to 8 days before outcomes occurred. This is consistent with a process that takes time – making a decision to discontinue care – suggesting that digital monitoring could provide valuable lead time for proactive intervention. Understanding these latency patterns could inform the design of just-in-time adaptive interventions that deliver timely supportive messages, coping strategies, or clinical outreach precisely when individuals are most vulnerable.
While these data highlight the promise of strategies that detect risk for bad outcomes, caution is warranted. Predictive models are not perfectly accurate, and both false positives and false negatives were observed in this study, each of which could carry consequences in real-world settings. Models predicting self-reported non-prescribed opioid use and buprenorphine nonadherence appeared more prone to false positives (i.e., indicating opioid use when it does not occur), while models predicting treatment retention appeared more prone to false negatives (i.e., indicating treatment dropout when it does not occur). This model tendency to “jump to conclusions” makes sense given the life-impacting risks of not catching relapse or dropout. At the same time, incorrect alerts could damage trust between patients and providers if not handled carefully.
The study sample was relatively small and drawn from a single health system in California, with limited demographic diversity. This limits generalizability of the findings to broader populations.
The researchers used conservative methods to fill in missing responses from the smartphone surveys, which may have influenced the results. It remains uncertain how well these predictive models would perform in real-world settings where missing data are more common.
BOTTOM LINE
Real-time data collected through daily smartphone assessments, when paired with advanced artificial intelligence prediction models, shows promise for forecasting relapse and treatment dropout – and, to a lesser extent, medication nonadherence – among individuals receiving outpatient opioid use disorder treatment.
Recent substance use, mood and emotional states, difficulties with self-regulation, and day-to-day social and environmental contexts emerged as strong predictors of future non-prescribed opioid use and treatment dropout. The models also revealed different time windows of risk; relapse was predicted by both immediate signals (e.g., mood and high-risk social contexts) that indicated vulnerability within hours to a day, as well as by longer-term factors like stress and pain, which signaled risk building gradually over several days. Treatment dropout, in contrast, was typically predicted several days in advance by factors such as mood, self-regulation, cravings, and pain. Together, these findings suggest that smartphone-based monitoring, coupled with artificial intelligence predictions, could enable just-in-time adaptive interventions that provide support at moments when individuals are most vulnerable, potentially shifting care toward a more proactive and personalized approach – though further research and careful implementation are needed.
For individuals and families seeking recovery: For individuals and families, this highlights the importance of paying attention to daily experiences. Simple check-ins on stress, mood, and cravings, can provide valuable signals of relapse risk before it happens. In the future, technology-based tools such as smartphone applications that track these experiences and apply predictive artificial intelligence models may help individuals, families, and care providers recognize and respond to early warning signs in time to prevent relapse or treatment dropout.
For treatment professionals and treatment systems: Findings suggest that integrating digital monitoring tools – such as daily smartphone surveys on stress, substance use, mood, and cravings – with electronic health records and artificial intelligence-based predictions could strengthen clinical decision-making. Such tools may help generate real-time alerts when patients show signs of elevated relapse or treatment dropout risk, enabling timelier outreach and adaptive, personalized interventions.
For scientists: These findings highlight the value of pairing intensive self-report data collected through smartphones with advanced artificial intelligence predictions to capture the dynamic course of opioid use disorder and forecast relapse or treatment discontinuation. Future research should evaluate these approaches in larger and more diverse samples and explore integration with passive sensing technologies (e.g., wearables) to test whether outcomes can be predicted even more effectively. Such work is essential to advance the development of personalized, just-in-time adaptive interventions that detect moments of elevated risk and trigger automated support in the form of timely messages, resources, and provider alerts.
For policy makers: This study found that daily smartphone assessments combined with artificial intelligence-based predictions could accurately forecast relapse risk and treatment dropout. Such tools could help detect and offset these risks before they occur, creating opportunities for proactive intervention. Investing in research to further develop and disseminate digital health tools that enable just-in-time adaptive interventions could strengthen opioid use disorder treatment systems, reduce relapse, improve treatment retention, and ultimately lessen the broader societal burden of opioid use disorder.
Relapse and suboptimal treatment retention are driven by complex, interacting factors. Yet, most prior research has focused on static, group-level risk factors (e.g., sex, age, or substance use history), which do not adequately capture the dynamic, daily fluctuations in stress, mood, cravings, or social context that shape recovery trajectories. Understanding these moment-to-moment influences can help inform just-in-time adaptive interventions that detect heightened risk and deliver timely, personalized support when it is most needed. This study sought to address the first step in this process by testing whether ecological momentary assessment – brief smartphone app-delivered surveys completed several times per day that asked about participants’ stress, mood, cravings, pain, withdrawal symptoms, substance use, and environmental context – combined with artificial intelligence-based deep learning models could accurately forecast future risks of non-prescribed opioid use (i.e., relapse), buprenorphine nonadherence, or treatment dropout.
HOW WAS THIS STUDY CONDUCTED?
This study was a secondary analysis of data from a 12-week observational study involving 62 adults (mean age = 37 years) receiving buprenorphine for opioid use disorder (often prescribed in a formulation with naloxone, known as Suboxone) at an outpatient addiction treatment clinic in California between June 2020 and January 2021. Participants were predominantly White (71%) and about half were male (50%). During the study period, more than half self-reported non-prescribed opioid use (52%) or medication non-adherence (55%) at least once.
Primary outcomes included: 1) self-reported non-prescribed opioid use (via daily smartphone surveys), 2) self-reported buprenorphine nonadherence (via daily smartphone surveys), 3) objective buprenorphine nonadherence (based on prescription information in electronic health records), and 4) objective retention in opioid use disorder treatment (based on prescription information in electronic health records).
Predictors were drawn from ecological momentary assessments (i.e., brief daily smartphone surveys delivered 3 times daily) that asked about participants’ sleep, medication adherence, stress, pain, cravings, withdrawal symptoms, mood, self-regulation, and social/environmental context, as well as substances used in the past hour or past day. Across all participants, 14,322 observations from these daily smartphone surveys were collected. Any missed opioid use report was counted as having used an opioid; any missed medication adherence report was counted as having not adhered to one’s medication plan. Assuming bad outcomes if missing are common, conservative methods of accounting for missing data.
For the analysis, the researchers used recurrent deep learning models (a type of artificial intelligence) to test whether patterns in the smartphone survey data could predict next-day outcomes. They did this by looking at 7-day blocks of survey responses at a time. For example, data from days 1-7 were used to see if the model could correctly forecast outcomes for days 2-8. Then the window shifted forward by 1 day (days 2-8 used to predict days 3-9), and so on. This process was repeated across the entire 12-week study, allowing the model to learn from many overlapping sequences of data. Separate models were built for each of the 4 outcomes (e.g., self-reported non-prescribed opioid use, self-reported buprenorphine nonadherence) and for each of the 12 types of daily survey items (e.g., cravings, mood), resulting in 48 models in total. Model accuracy was evaluated using a statistic called the area under the curve (AUC), a value between 0 and 1 where 0.50 means the prediction is no better than chance and values above 0.70 are considered moderately accurate. To better understand what was driving the model predictions, the researchers also applied an interpretability method that highlighted which daily survey items were most influential in shaping the forecasts.
WHAT DID THIS STUDY FIND?
Daily smartphone survey data predicted relapse risk especially well
Models predicting next-day non-prescribed opioid use (called “relapse” in the study) performed with very high accuracy. See graphic below. The strongest predictors of next-day opioid use were self-reported substance use in the past hour (AUC = 0.97; non-prescribed opioids, cocaine, methamphetamine, benzodiazepines, cannabis, alcohol); situational risk cues such as current alcohol or nicotine use and exposure to triggers like stress or seeing drug cues (AUC = 0.93); self-regulation difficulties like low ability to plan or follow through (AUC = 0.92); mood states including boredom, exhaustion, or low contentment (AUC = 0.91); and social or environmental context (AUC = 0.90), which captured where participants were, who they were with, and what activities they were engaged in. Further analysis indicated that relapse risk was influenced both by low-latency (immediate) predictors, such as context (e.g., being at a bar or club) and mood (e.g., boredom, exhaustion) that raised risk within hours to the next day, and by high-latency (delayed) predictors, such as pain and stress levels, which accumulated risk more gradually over several days.
Treatment retention could also be forecasted well
Models predicting whether participants remained in treatment, based on electronic health record data, also performed strongly. See graphic below. The most important predictors were social and environmental context (AUC = 0.89), reports of recent substance use in the past hour (AUC = 0.86), self-regulation (AUC = 0.85), mood (AUC = 0.83), and cravings (AUC = 0.81). Further analyses indicated that the strongest predictors of treatment discontinuation generally operated at higher time latencies, with mood (boredom and exhaustion), self-regulation (difficulty planning or finishing tasks), cravings for cocaine and methamphetamine, nicotine use, pain, and social or environmental context (reporting recent drug use in one’s environment) forecasting dropout risk several days in advance rather than immediately.
Buprenorphine nonadherence was harder to predict
Models predicting self-reported buprenorphine nonadherence performed poorly, with a best AUC of 0.68, below the threshold for moderate accuracy. See graphic below. Context and recent substance use were the most informative predictors but only provided limited signal. In contrast, objective buprenorphine nonadherence, based on prescription information in electronic health records, was predicted moderately well. The strongest predictors were situational risk cues (AUC = 0.79), self-reported buprenorphine adherence (AUC = 0.79), substance use in the past hour (AUC = 0.78), self-regulation (AUC = 0.77), and mood (AUC = 0.77). Further analyses indicated that objective buprenorphine nonadherence was most strongly linked to high-latency predictors, including self-regulation (difficulty planning or finishing tasks), mood (bored, exhausted, discontent), cravings for cocaine, and past hour substance use (any non-prescribed opioid, crack cocaine, benzodiazepines, alcohol, or cannabis), which forecasted risk over several days. Low-latency predictors such as nicotine use and pain level also contributed, influencing outcomes more immediately.
WHAT ARE THE IMPLICATIONS OF THE STUDY FINDINGS?
This study demonstrates that pairing brief daily smartphone assessments with artificial intelligence-based prediction models can yield clinically useful early warning signals of opioid use and treatment discontinuation, and, to a lesser extent, medication nonadherence, among individuals in outpatient treatment for opioid use disorder.
Findings highlight the potential for smartphone and other digitally collected psychological and contextual data to predict both self-reported outcomes such as non-prescribed opioid use and objective outcomes from electronic health records, such as buprenorphine nonadherence and treatment dropout. The study also identified different time windows of risk. Some predictors – such as mood, particularly boredom and exhaustion, and being in high-risk contexts where substance use was present – signaled elevated risk for non-prescribed opioid use within hours. Other predictors, such as stress and pain, forecasted relapse risk several days in advance. However, the study did not report, if a certain risk factor was present, how many days it would take for the negative outcome to occur (i.e., opioid use). Most predictors of treatment retention operated at higher time latencies, with mood, self-regulation, cravings, and pain forecasting treatment discontinuation several days in advance.
Consistent with prior research, and as might be expected, substance use in the past hour was among the most influential predictors across outcomes, underscoring the intuitive role of recent substance use in predicting future substance use-related behaviors.
In terms of what predicts this initial substance use, it is worth noting that cannabis use was among the influential recent substance use items in predicting non-prescribed opioid use and treatment discontinuation, consistent with prior findings indicating that cannabis use may increase risk for opioid use and hinder recovery efforts. Self-regulation consistently emerged as a strong predictor across outcomes, echoing prior research linking factors such as perseverance, sensation seeking, andemotion regulation with substance use and substance use disorder. Mood states such as boredom and exhaustion were similarly important predictors across outcomes, reinforcing the role of negative affect in relapse risk and treatment engagement. Together, these findings suggest that recent substance use (including alcohol and cannabis use, as well as an initial return to opioid use), mood and emotional states, difficulties with self-regulation, and day-to-day social and environmental contexts can serve as strong early warning signals of relapse and treatment discontinuation.
Results from latency analyses further suggest that predictive signals of risk differ in timing across outcomes. Non-prescribed opioid use was shaped by both low latency factors – such as social and environmental context, self-regulation, and mood, which signaled risk within hours to the next day – and higher latency factors like pain and stress, which signaled risk several days in advance. By contrast, many predictors of buprenorphine nonadherence and treatment discontinuation, such as cravings, self-regulation difficulties, mood, and past-hour substance use, showed longer latencies, sometimes detectable 5 to 8 days before outcomes occurred. This is consistent with a process that takes time – making a decision to discontinue care – suggesting that digital monitoring could provide valuable lead time for proactive intervention. Understanding these latency patterns could inform the design of just-in-time adaptive interventions that deliver timely supportive messages, coping strategies, or clinical outreach precisely when individuals are most vulnerable.
While these data highlight the promise of strategies that detect risk for bad outcomes, caution is warranted. Predictive models are not perfectly accurate, and both false positives and false negatives were observed in this study, each of which could carry consequences in real-world settings. Models predicting self-reported non-prescribed opioid use and buprenorphine nonadherence appeared more prone to false positives (i.e., indicating opioid use when it does not occur), while models predicting treatment retention appeared more prone to false negatives (i.e., indicating treatment dropout when it does not occur). This model tendency to “jump to conclusions” makes sense given the life-impacting risks of not catching relapse or dropout. At the same time, incorrect alerts could damage trust between patients and providers if not handled carefully.
The study sample was relatively small and drawn from a single health system in California, with limited demographic diversity. This limits generalizability of the findings to broader populations.
The researchers used conservative methods to fill in missing responses from the smartphone surveys, which may have influenced the results. It remains uncertain how well these predictive models would perform in real-world settings where missing data are more common.
BOTTOM LINE
Real-time data collected through daily smartphone assessments, when paired with advanced artificial intelligence prediction models, shows promise for forecasting relapse and treatment dropout – and, to a lesser extent, medication nonadherence – among individuals receiving outpatient opioid use disorder treatment.
Recent substance use, mood and emotional states, difficulties with self-regulation, and day-to-day social and environmental contexts emerged as strong predictors of future non-prescribed opioid use and treatment dropout. The models also revealed different time windows of risk; relapse was predicted by both immediate signals (e.g., mood and high-risk social contexts) that indicated vulnerability within hours to a day, as well as by longer-term factors like stress and pain, which signaled risk building gradually over several days. Treatment dropout, in contrast, was typically predicted several days in advance by factors such as mood, self-regulation, cravings, and pain. Together, these findings suggest that smartphone-based monitoring, coupled with artificial intelligence predictions, could enable just-in-time adaptive interventions that provide support at moments when individuals are most vulnerable, potentially shifting care toward a more proactive and personalized approach – though further research and careful implementation are needed.
For individuals and families seeking recovery: For individuals and families, this highlights the importance of paying attention to daily experiences. Simple check-ins on stress, mood, and cravings, can provide valuable signals of relapse risk before it happens. In the future, technology-based tools such as smartphone applications that track these experiences and apply predictive artificial intelligence models may help individuals, families, and care providers recognize and respond to early warning signs in time to prevent relapse or treatment dropout.
For treatment professionals and treatment systems: Findings suggest that integrating digital monitoring tools – such as daily smartphone surveys on stress, substance use, mood, and cravings – with electronic health records and artificial intelligence-based predictions could strengthen clinical decision-making. Such tools may help generate real-time alerts when patients show signs of elevated relapse or treatment dropout risk, enabling timelier outreach and adaptive, personalized interventions.
For scientists: These findings highlight the value of pairing intensive self-report data collected through smartphones with advanced artificial intelligence predictions to capture the dynamic course of opioid use disorder and forecast relapse or treatment discontinuation. Future research should evaluate these approaches in larger and more diverse samples and explore integration with passive sensing technologies (e.g., wearables) to test whether outcomes can be predicted even more effectively. Such work is essential to advance the development of personalized, just-in-time adaptive interventions that detect moments of elevated risk and trigger automated support in the form of timely messages, resources, and provider alerts.
For policy makers: This study found that daily smartphone assessments combined with artificial intelligence-based predictions could accurately forecast relapse risk and treatment dropout. Such tools could help detect and offset these risks before they occur, creating opportunities for proactive intervention. Investing in research to further develop and disseminate digital health tools that enable just-in-time adaptive interventions could strengthen opioid use disorder treatment systems, reduce relapse, improve treatment retention, and ultimately lessen the broader societal burden of opioid use disorder.
Relapse and suboptimal treatment retention are driven by complex, interacting factors. Yet, most prior research has focused on static, group-level risk factors (e.g., sex, age, or substance use history), which do not adequately capture the dynamic, daily fluctuations in stress, mood, cravings, or social context that shape recovery trajectories. Understanding these moment-to-moment influences can help inform just-in-time adaptive interventions that detect heightened risk and deliver timely, personalized support when it is most needed. This study sought to address the first step in this process by testing whether ecological momentary assessment – brief smartphone app-delivered surveys completed several times per day that asked about participants’ stress, mood, cravings, pain, withdrawal symptoms, substance use, and environmental context – combined with artificial intelligence-based deep learning models could accurately forecast future risks of non-prescribed opioid use (i.e., relapse), buprenorphine nonadherence, or treatment dropout.
HOW WAS THIS STUDY CONDUCTED?
This study was a secondary analysis of data from a 12-week observational study involving 62 adults (mean age = 37 years) receiving buprenorphine for opioid use disorder (often prescribed in a formulation with naloxone, known as Suboxone) at an outpatient addiction treatment clinic in California between June 2020 and January 2021. Participants were predominantly White (71%) and about half were male (50%). During the study period, more than half self-reported non-prescribed opioid use (52%) or medication non-adherence (55%) at least once.
Primary outcomes included: 1) self-reported non-prescribed opioid use (via daily smartphone surveys), 2) self-reported buprenorphine nonadherence (via daily smartphone surveys), 3) objective buprenorphine nonadherence (based on prescription information in electronic health records), and 4) objective retention in opioid use disorder treatment (based on prescription information in electronic health records).
Predictors were drawn from ecological momentary assessments (i.e., brief daily smartphone surveys delivered 3 times daily) that asked about participants’ sleep, medication adherence, stress, pain, cravings, withdrawal symptoms, mood, self-regulation, and social/environmental context, as well as substances used in the past hour or past day. Across all participants, 14,322 observations from these daily smartphone surveys were collected. Any missed opioid use report was counted as having used an opioid; any missed medication adherence report was counted as having not adhered to one’s medication plan. Assuming bad outcomes if missing are common, conservative methods of accounting for missing data.
For the analysis, the researchers used recurrent deep learning models (a type of artificial intelligence) to test whether patterns in the smartphone survey data could predict next-day outcomes. They did this by looking at 7-day blocks of survey responses at a time. For example, data from days 1-7 were used to see if the model could correctly forecast outcomes for days 2-8. Then the window shifted forward by 1 day (days 2-8 used to predict days 3-9), and so on. This process was repeated across the entire 12-week study, allowing the model to learn from many overlapping sequences of data. Separate models were built for each of the 4 outcomes (e.g., self-reported non-prescribed opioid use, self-reported buprenorphine nonadherence) and for each of the 12 types of daily survey items (e.g., cravings, mood), resulting in 48 models in total. Model accuracy was evaluated using a statistic called the area under the curve (AUC), a value between 0 and 1 where 0.50 means the prediction is no better than chance and values above 0.70 are considered moderately accurate. To better understand what was driving the model predictions, the researchers also applied an interpretability method that highlighted which daily survey items were most influential in shaping the forecasts.
WHAT DID THIS STUDY FIND?
Daily smartphone survey data predicted relapse risk especially well
Models predicting next-day non-prescribed opioid use (called “relapse” in the study) performed with very high accuracy. See graphic below. The strongest predictors of next-day opioid use were self-reported substance use in the past hour (AUC = 0.97; non-prescribed opioids, cocaine, methamphetamine, benzodiazepines, cannabis, alcohol); situational risk cues such as current alcohol or nicotine use and exposure to triggers like stress or seeing drug cues (AUC = 0.93); self-regulation difficulties like low ability to plan or follow through (AUC = 0.92); mood states including boredom, exhaustion, or low contentment (AUC = 0.91); and social or environmental context (AUC = 0.90), which captured where participants were, who they were with, and what activities they were engaged in. Further analysis indicated that relapse risk was influenced both by low-latency (immediate) predictors, such as context (e.g., being at a bar or club) and mood (e.g., boredom, exhaustion) that raised risk within hours to the next day, and by high-latency (delayed) predictors, such as pain and stress levels, which accumulated risk more gradually over several days.
Treatment retention could also be forecasted well
Models predicting whether participants remained in treatment, based on electronic health record data, also performed strongly. See graphic below. The most important predictors were social and environmental context (AUC = 0.89), reports of recent substance use in the past hour (AUC = 0.86), self-regulation (AUC = 0.85), mood (AUC = 0.83), and cravings (AUC = 0.81). Further analyses indicated that the strongest predictors of treatment discontinuation generally operated at higher time latencies, with mood (boredom and exhaustion), self-regulation (difficulty planning or finishing tasks), cravings for cocaine and methamphetamine, nicotine use, pain, and social or environmental context (reporting recent drug use in one’s environment) forecasting dropout risk several days in advance rather than immediately.
Buprenorphine nonadherence was harder to predict
Models predicting self-reported buprenorphine nonadherence performed poorly, with a best AUC of 0.68, below the threshold for moderate accuracy. See graphic below. Context and recent substance use were the most informative predictors but only provided limited signal. In contrast, objective buprenorphine nonadherence, based on prescription information in electronic health records, was predicted moderately well. The strongest predictors were situational risk cues (AUC = 0.79), self-reported buprenorphine adherence (AUC = 0.79), substance use in the past hour (AUC = 0.78), self-regulation (AUC = 0.77), and mood (AUC = 0.77). Further analyses indicated that objective buprenorphine nonadherence was most strongly linked to high-latency predictors, including self-regulation (difficulty planning or finishing tasks), mood (bored, exhausted, discontent), cravings for cocaine, and past hour substance use (any non-prescribed opioid, crack cocaine, benzodiazepines, alcohol, or cannabis), which forecasted risk over several days. Low-latency predictors such as nicotine use and pain level also contributed, influencing outcomes more immediately.
WHAT ARE THE IMPLICATIONS OF THE STUDY FINDINGS?
This study demonstrates that pairing brief daily smartphone assessments with artificial intelligence-based prediction models can yield clinically useful early warning signals of opioid use and treatment discontinuation, and, to a lesser extent, medication nonadherence, among individuals in outpatient treatment for opioid use disorder.
Findings highlight the potential for smartphone and other digitally collected psychological and contextual data to predict both self-reported outcomes such as non-prescribed opioid use and objective outcomes from electronic health records, such as buprenorphine nonadherence and treatment dropout. The study also identified different time windows of risk. Some predictors – such as mood, particularly boredom and exhaustion, and being in high-risk contexts where substance use was present – signaled elevated risk for non-prescribed opioid use within hours. Other predictors, such as stress and pain, forecasted relapse risk several days in advance. However, the study did not report, if a certain risk factor was present, how many days it would take for the negative outcome to occur (i.e., opioid use). Most predictors of treatment retention operated at higher time latencies, with mood, self-regulation, cravings, and pain forecasting treatment discontinuation several days in advance.
Consistent with prior research, and as might be expected, substance use in the past hour was among the most influential predictors across outcomes, underscoring the intuitive role of recent substance use in predicting future substance use-related behaviors.
In terms of what predicts this initial substance use, it is worth noting that cannabis use was among the influential recent substance use items in predicting non-prescribed opioid use and treatment discontinuation, consistent with prior findings indicating that cannabis use may increase risk for opioid use and hinder recovery efforts. Self-regulation consistently emerged as a strong predictor across outcomes, echoing prior research linking factors such as perseverance, sensation seeking, andemotion regulation with substance use and substance use disorder. Mood states such as boredom and exhaustion were similarly important predictors across outcomes, reinforcing the role of negative affect in relapse risk and treatment engagement. Together, these findings suggest that recent substance use (including alcohol and cannabis use, as well as an initial return to opioid use), mood and emotional states, difficulties with self-regulation, and day-to-day social and environmental contexts can serve as strong early warning signals of relapse and treatment discontinuation.
Results from latency analyses further suggest that predictive signals of risk differ in timing across outcomes. Non-prescribed opioid use was shaped by both low latency factors – such as social and environmental context, self-regulation, and mood, which signaled risk within hours to the next day – and higher latency factors like pain and stress, which signaled risk several days in advance. By contrast, many predictors of buprenorphine nonadherence and treatment discontinuation, such as cravings, self-regulation difficulties, mood, and past-hour substance use, showed longer latencies, sometimes detectable 5 to 8 days before outcomes occurred. This is consistent with a process that takes time – making a decision to discontinue care – suggesting that digital monitoring could provide valuable lead time for proactive intervention. Understanding these latency patterns could inform the design of just-in-time adaptive interventions that deliver timely supportive messages, coping strategies, or clinical outreach precisely when individuals are most vulnerable.
While these data highlight the promise of strategies that detect risk for bad outcomes, caution is warranted. Predictive models are not perfectly accurate, and both false positives and false negatives were observed in this study, each of which could carry consequences in real-world settings. Models predicting self-reported non-prescribed opioid use and buprenorphine nonadherence appeared more prone to false positives (i.e., indicating opioid use when it does not occur), while models predicting treatment retention appeared more prone to false negatives (i.e., indicating treatment dropout when it does not occur). This model tendency to “jump to conclusions” makes sense given the life-impacting risks of not catching relapse or dropout. At the same time, incorrect alerts could damage trust between patients and providers if not handled carefully.
The study sample was relatively small and drawn from a single health system in California, with limited demographic diversity. This limits generalizability of the findings to broader populations.
The researchers used conservative methods to fill in missing responses from the smartphone surveys, which may have influenced the results. It remains uncertain how well these predictive models would perform in real-world settings where missing data are more common.
BOTTOM LINE
Real-time data collected through daily smartphone assessments, when paired with advanced artificial intelligence prediction models, shows promise for forecasting relapse and treatment dropout – and, to a lesser extent, medication nonadherence – among individuals receiving outpatient opioid use disorder treatment.
Recent substance use, mood and emotional states, difficulties with self-regulation, and day-to-day social and environmental contexts emerged as strong predictors of future non-prescribed opioid use and treatment dropout. The models also revealed different time windows of risk; relapse was predicted by both immediate signals (e.g., mood and high-risk social contexts) that indicated vulnerability within hours to a day, as well as by longer-term factors like stress and pain, which signaled risk building gradually over several days. Treatment dropout, in contrast, was typically predicted several days in advance by factors such as mood, self-regulation, cravings, and pain. Together, these findings suggest that smartphone-based monitoring, coupled with artificial intelligence predictions, could enable just-in-time adaptive interventions that provide support at moments when individuals are most vulnerable, potentially shifting care toward a more proactive and personalized approach – though further research and careful implementation are needed.
For individuals and families seeking recovery: For individuals and families, this highlights the importance of paying attention to daily experiences. Simple check-ins on stress, mood, and cravings, can provide valuable signals of relapse risk before it happens. In the future, technology-based tools such as smartphone applications that track these experiences and apply predictive artificial intelligence models may help individuals, families, and care providers recognize and respond to early warning signs in time to prevent relapse or treatment dropout.
For treatment professionals and treatment systems: Findings suggest that integrating digital monitoring tools – such as daily smartphone surveys on stress, substance use, mood, and cravings – with electronic health records and artificial intelligence-based predictions could strengthen clinical decision-making. Such tools may help generate real-time alerts when patients show signs of elevated relapse or treatment dropout risk, enabling timelier outreach and adaptive, personalized interventions.
For scientists: These findings highlight the value of pairing intensive self-report data collected through smartphones with advanced artificial intelligence predictions to capture the dynamic course of opioid use disorder and forecast relapse or treatment discontinuation. Future research should evaluate these approaches in larger and more diverse samples and explore integration with passive sensing technologies (e.g., wearables) to test whether outcomes can be predicted even more effectively. Such work is essential to advance the development of personalized, just-in-time adaptive interventions that detect moments of elevated risk and trigger automated support in the form of timely messages, resources, and provider alerts.
For policy makers: This study found that daily smartphone assessments combined with artificial intelligence-based predictions could accurately forecast relapse risk and treatment dropout. Such tools could help detect and offset these risks before they occur, creating opportunities for proactive intervention. Investing in research to further develop and disseminate digital health tools that enable just-in-time adaptive interventions could strengthen opioid use disorder treatment systems, reduce relapse, improve treatment retention, and ultimately lessen the broader societal burden of opioid use disorder.