Machine learning flags hidden anxiety in children with chronic abdominal
Long-lasting stomach pain that has no clear physical cause is one of the most common reasons children and teenagers visit doctors who specialize in stomach and digestive problems. Doctors use a set of rules called Rome IV to group these problems under the name functional abdominal pain disorders. This group includes functional dyspepsia, which causes pain or discomfort in the upper belly; irritable bowel syndrome; abdominal migraine; and functional abdominal pain that does not fit into another specific group. Doctors now understand that these conditions are not just problems with the digestive system. They involve communication between the gut and the brain. How much pain a child feels, how well they sleep, how strongly they notice physical symptoms, how they manage school, and the mental health of their family can all affect the condition. Anxiety is especially important. It can make pain feel worse, lead to more doctor visits, make everyday activities harder, and cause symptoms to continue. At the same time, stomach pain can make children worry about future pain, avoid activities, and miss school. But doctors may overlook anxiety when a child mainly complains about stomach pain, especially when mental health checks are not a regular part of digestive health care.
Researchers from the Department of Pediatric Gastroenterology at The Second Affiliated Hospital and Yuying Children’s Hospital of Wenzhou Medical University wanted to help doctors recognize this hidden anxiety. They developed a tool that could help doctors identify children who are more likely to have an anxiety disorder. In a study published in Frontiers in Psychiatry, Weiwei Wu, Quanquan Ye, Xiaochun Lin, Sisi Li, Shishi Wang, and Xiaoyan Liu created and tested a machine learning model called a stacking model. It was designed to find signs of anxiety disorders in children and teenagers who already had functional abdominal pain disorders. The researchers used existing medical records to build a model that predicts risk. They also tested the model using part of their own dataset. The hospital’s Ethics Committee approved the research. Because the researchers used older medical records that did not identify individual patients, the committee did not require informed consent. The study followed the Declaration of Helsinki, a set of ethical rules for medical research.
The study included 629 patients between 7 and 18 years old. All met the Rome IV rules for functional abdominal pain disorders and had been examined between December 2021 and December 2025. The researchers did not include children whose stomach pain could be explained by a physical digestive disease, inflammation, a problem with how the body processes substances, an infection, or a structural problem. They also left out children who had not received a standard anxiety assessment, those who had received psychological or psychiatric treatment before their stomach pain assessment, and those whose records were missing too much important information. Of the 629 patients, 210, or 33.4 percent, also had an anxiety disorder. The researchers randomly divided the patients into two groups, using a 7:3 ratio. They made sure the groups had similar proportions of children with anxiety. The training group had 440 patients, including 147 with anxiety disorders. The internal validation group, used to test the model, had 189 patients, including 63 with anxiety disorders. Most characteristics were similar between the two groups. The differences were generally small, although stomach pain intensity showed a slightly larger standardized mean difference of 0.11.
The researchers used careful rules to decide which children had anxiety disorders. First, the children completed the Chinese version of a questionnaire called the Screen for Child Anxiety Related Emotional Disorders, or SCARED. It contains 41 questions that children answer about themselves. Scores range from 0 to 82, and a score of 25 or higher suggests that a child may have anxiety. But this questionnaire alone did not decide the final diagnosis. Trained child psychiatrists or clinical psychologists made that decision using DSM-5 diagnostic rules. The diagnoses included generalized anxiety disorder, separation anxiety disorder, social anxiety disorder, panic disorder, specific phobias, and other anxiety disorders recognized by clinicians. Importantly, the researchers did not let the machine learning model use the SCARED scores, scores from its different sections, doctors’ final diagnoses, psychiatric interview results, or treatment information collected after diagnosis. This meant the model had to predict anxiety using information doctors could normally collect, rather than simply copying the results of an anxiety test. All anxiety assessments were completed before the researchers started building the model. The professionals who diagnosed anxiety did not help develop the model.
The researchers collected possible warning signs from six areas before deciding which patients had anxiety. Basic personal information included age, sex, body mass index, where the child lived, and whether the child was an only child. Information about pain included how long symptoms had lasted, how often pain happened, how strong the pain was on a number scale, whether pain happened in the morning, whether it woke the child at night, and whether it happened around stressful events. The researchers also recorded Functional Disability Inventory scores, which measure how much symptoms interfere with daily activities. They counted how many school days each child had missed during the previous month, previous emergency department visits, earlier use of digestive system medicines, and the type of abdominal pain disorder. They recorded other physical problems, including constipation, diarrhea, nausea, bloating, headaches, and allergies. They also separately recorded whether children avoided school or refused to attend, rather than simply counting missed days. Measures of the children's mental and social well-being included the Sleep Disturbance Scale for Children, the Children’s Somatic Symptoms Inventory-24, how strongly children expected or feared the worst about pain, symptoms of depression, problems with friendships, and recent school-related stress. Family information included parents’ anxiety symptoms measured with the Generalized Anxiety Disorder-7 questionnaire, parents’ depression symptoms, conflict between parents, whether the child lived with one parent, whether the child had been left behind by parents living elsewhere, overly protective parenting, and family histories of repeated stomach pain or mental health disorders.
Before building the machine learning models, the researchers used a statistical method called multivariable logistic regression to look at which factors were linked to anxiety while accounting for other factors. Older children had a slightly higher chance of anxiety. For each additional year of age, the adjusted odds ratio was 1.07. Longer-lasting symptoms and more frequent pain were also linked to anxiety. After the researchers changed these measurements using a mathematical formula called log2(1 + x), their adjusted odds ratios were 1.31 and 1.36, respectively. Children who woke up at night because of pain had an odds ratio of 1.55. Pain that happened around stressful events had an odds ratio of 1.86. Every 5-point increase on the Sleep Disturbance Scale for Children, or SDSC, had an odds ratio of 1.18. Every 5-point increase on the Children’s Somatic Symptoms Inventory-24, or CSI-24, had an odds ratio of 1.26. Every 5-point increase in a parent's GAD-7 anxiety score had an odds ratio of 1.46. School absence, after the researchers mathematically changed the measurement, had an odds ratio of 1.28. These odds ratios describe how strongly each factor was linked to anxiety, not how much it directly caused anxiety. The researchers used these results to describe patterns in the patients. They did not use this regression analysis to choose which information the machine learning models would receive.
The researchers took many steps to prevent information from the test group from accidentally helping the models learn. They divided the patients into training and validation groups before doing any model development. They saved the validation group only for the final test. They did not use it to choose important factors, adjust model settings, calibrate predictions, choose cutoff scores, decide how the models should work, or train the model that combined the other models. Very little information was missing. Out of 27,676 possible measurements for the factors being studied, 248, or 0.90 percent, were missing before the researchers filled in missing values. No individual factor had more than 3.2 percent of its values missing. The researchers worked out how to fill in missing information using only training data, then applied the same rules to data held back during training and to the final validation group. To choose useful predictors, they used a method called least absolute shrinkage and selection operator, or LASSO, logistic regression. They repeated this process in each round of cross-validation, a method that trains a model on some data and checks it on data held aside. They kept factors whose mathematical weights were not zero at the level of penalty chosen through cross-validation within that round. They then built four types of machine learning models chosen in advance. The first was an explainable boosting machine, which can recognize complicated patterns while making its predictions easier to understand. The second was a calibrated support vector machine, which separates groups using mathematical boundaries and adjusts its outputs to estimate probabilities. The third was a random forest, which combines many decision trees trained on different samples. The fourth was CatBoost, which builds a series of models that learn from earlier errors and uses controls to reduce overfitting. CatBoost is especially useful for data arranged in tables, such as medical records.
The researchers then combined these four models into one stacking model. Each model made predictions for patients whose records it had not used during that round of training. For every patient in the training group, the combined model received only predictions made while that patient was in the held-out group. This helped prevent the combined model from learning from predictions that looked unusually good simply because the original models had already seen the same patients. The four sets of predicted probabilities were passed into another model called L2-penalized logistic regression. This final model combined the predictions to estimate each child's chance of also having an anxiety disorder. All four original models made positive contributions. CatBoost had the greatest influence, followed by the explainable boosting machine, random forest, and support vector machine. The researchers also checked whether the four models made different kinds of predictions instead of simply repeating one another. The correlations between their predicted probabilities ranged from 0.55 to 0.68. Their rates of disagreeing on predictions ranged from 0.24 to 0.33, while the rates at which two models made the same wrong prediction ranged from 0.103 to 0.150. The researchers chose the cutoff points for deciding whether a prediction counted as anxiety using a method called the Youden index and only the training group. They then used those same cutoff points for the validation group without changing them.
When the researchers tested predictions made on held-out parts of the training data, the stacking model achieved an area under the curve, or AUC, of 0.831 and a Brier score of 0.151. AUC measures how well a model separates patients with anxiety from those without it. A higher AUC is better. The Brier score measures how close predicted probabilities are to actual outcomes, and a lower score is better. In the separate validation group, the stacking model had the best numerical results among the models tested. Its AUC was 0.846, with a 95 percent confidence interval from 0.789 to 0.894. This interval shows the uncertainty around the estimated AUC. Its accuracy was 0.788, meaning it correctly classified about 78.8 percent of patients. Its sensitivity was 0.762, meaning it identified about 76.2 percent of patients who had anxiety. Its specificity was 0.802, meaning it correctly identified about 80.2 percent of patients who did not have anxiety. Its positive predictive value was 0.658, meaning about 65.8 percent of patients flagged as having anxiety actually had it. Its negative predictive value was 0.871, meaning about 87.1 percent of patients flagged as not having anxiety truly did not have it. Its F1 score, which combines measures of how well a model finds positive cases and how reliable its positive predictions are, was 0.706. Its Brier score was 0.146, the lowest of all the models tested. Using a statistical comparison called the DeLong test, the researchers found that the stacking model performed significantly better than the explainable boosting machine and the support vector machine. Its advantage over random forest was close to the usual cutoff for statistical significance. But its improvement over CatBoost, the best individual model, was small and not statistically significant. Another test, called decision curve analysis, suggested that the stacking model could offer more benefit than either treating every patient as having anxiety or treating none as having anxiety, across cutoff points that could matter in medical care. The model's predicted risks also generally matched the anxiety rates actually seen in patients, although the validation results showed some small ups and downs.
The researchers used a method called SHAP to understand which pieces of information had the greatest influence on the complete stacking model's predictions. SHAP gives each factor a value showing how much it pushes a prediction up or down. In this study, the values were measured on a mathematical scale called log-odds. Missing school had the largest average absolute SHAP value, making it the most influential factor. Next came the parent's GAD-7 anxiety score and the child's CSI-24 physical symptom score. This suggested that trouble attending school, anxiety symptoms in parents, and the number or strength of physical symptoms in children were the biggest contributors to the model's predictions. Other important factors included whether pain happened around stressful events, how long symptoms had lasted, how often pain occurred, the child's SDSC sleep score, age, and whether pain woke the child at night. Higher values for these factors generally pushed the model toward predicting a greater chance of anxiety. The relationships between the different predictors were weak to moderate. None had a correlation above 0.60. The strongest relationship was between school absence and CSI-24 score, with a correlation of 0.55. The authors warned that their model had only been tested internally, using patients from the same study. Because the research was observational, it could not prove that any of the factors caused anxiety. They also noted that the model's slightly higher AUC in the validation group might simply be due to random differences between groups, especially because the validation group was only moderately sized and the researchers divided the data randomly just once. Before doctors can use the model in everyday care, it needs to be tested at independent medical centers, with consistent methods for diagnosing anxiety. Future studies must also follow patients over time to find out whether using the model to identify higher-risk children actually helps doctors decide who needs a mental health referral and improves patient outcomes. The model is meant to help doctors, not replace their judgment. Its purpose is to identify children who may need a more detailed mental health assessment.
Subject of Research: Using machine learning to identify anxiety disorders in children with functional abdominal pain disorders
Article Title: A stacking machine learning model for identifying comorbid anxiety disorder in children and adolescents with functional abdominal pain disorders
Article References: Wu, W., Ye, Q., Lin, X., Li, S., Wang, S., & Liu, X. (2026). A stacking machine learning model for identifying comorbid anxiety disorder in children and adolescents with functional abdominal pain disorders. Frontiers in Psychiatry, 17, Article 1904174. [https://doi.org/10.3389/fpsyt.2026.1904174](https://doi.org/10.3389/fpsyt.2026.1904174)
Image Credits: AI Generated
DOI: 10.3389/fpsyt.2026.1904174
Keywords: machine learning, anxiety disorder, children and adolescents, functional abdominal pain disorders, stacking ensemble, LASSO, SHAP, Rome IV, pediatric gastroenterology, predictive modeling, stacking, machine
