# Exploratory analysis of machine learning models for state and trait anxiety based on Spielberger questionnaire data in nursing students

**Authors:** Reza Salehinia, Sajjad Salehian, Marzieh Nasiri Sangari, Mohammad Amin Nasiri Sangari, Hossein Abbassian

PMC · DOI: 10.1186/s12909-026-08842-3 · 2026-02-21

## TL;DR

This study explores how machine learning can help assess anxiety in nursing students using the Spielberger questionnaire, finding that social and demographic factors are more influential than physiological ones.

## Contribution

The study introduces machine learning as a complementary tool for analyzing state and trait anxiety in nursing students, revealing patterns overlooked by traditional methods.

## Key findings

- State and trait anxiety are strongly correlated (p < .001) in nursing students.
- Machine learning models showed moderate predictive accuracy (R² ≈ 0.11–0.13) for anxiety scores.
- Gender, academic major, and physiological factors like SpO₂ and body temperature were key predictors.

## Abstract

This study aimed to explore the ability of machine learning models to assess state and trait anxiety using data collected from the Spielberger State-Trait Anxiety Inventory (STAI). Considering the significant impact of mental health on the academic and professional performance of medical students, the research sought to determine whether machine learning could complement traditional assessment methods and provide insights into the relative influence of demographic and physiological factors on anxiety levels.

A census sampling approach was applied, including all 106 eligible students from the Tabas Faculty of Nursing. Participants with a history of anxiety disorders or use of psychoactive medications were excluded. State and trait anxiety were measured using the STAI. Data analysis was performed using SPSS and MATLAB. Bivariate tests (Kruskal-Wallis and Chi-Square) examined associations between anxiety and demographic/physiological variables. Multiple linear regression was used as an exploratory modeling approach to predict anxiety, with model performance evaluated via 10-fold cross-validation, RMSE, and R². Standardized coefficients were calculated to estimate the relative importance of predictors.

Participants had a mean age of 21.36 years, with 58.5% being female. Most demographic and physiological variables were not significantly associated with anxiety, except for marital status and the strong correlation between state and trait anxiety (p < .001). The regression model captured overall trends in anxiety scores but showed moderate predictive accuracy, particularly for extreme values (state anxiety: RMSE ≈ 8.89, R² ≈ 0.13; trait anxiety: RMSE ≈ 8.70, R² ≈ 0.11). Gender, academic major, and some physiological factors (e.g., SpO₂, body temperature) were the most influential predictors, while other variables had minimal contribution. These results reflect relative associations rather than precise individual-level predictions.

This study confirms the strong relationship between state and trait anxiety and highlights the relative influence of social and demographic factors over physiological indicators in this population. Although predictive accuracy was moderate, machine learning models can reveal complex patterns that may be overlooked by traditional statistical methods, offering guidance for exploratory assessment and targeted interventions for anxiety among nursing students.

The online version contains supplementary material available at 10.1186/s12909-026-08842-3.

## Full-text entities

- **Diseases:** anxiety (MESH:D001007)

## Figures

2 figures with captions in the complete paper: https://tomesphere.com/paper/PMC13032597/full.md

---
Source: https://tomesphere.com/paper/PMC13032597