Introduction

A recent coronavirus has caused an infectious disease called coronavirus disease—also referred to as COVID-19. The majority of people infected with this virus experienced mild to moderate respiratory illnesses and recover with no need for special treatment (Banerjee 2020). By July 1, COVID-19 spread almost in all countries in the world. Meanwhile, in the Persian Gulf Region, Iran stands on the top of the list, because more than 738,000 confirmed cases and approximately 40,582 total deaths were recorded (Centers for Disease Control and Prevention 2020).

People with suspected or confirmed COVID-19 are likely to be afraid of this potentially fatal infection (Logie and Turan 2020). Bo et al. (Bo et al. 2020) carried out a study in China, in which 714 participants took part. The majority (i.e., 96.2%) of these subjects suffered from significant posttraumatic stress symptoms before discharge. Furthermore, merely 50% of these patients have confirmed the mental stress crisis.

Also Boyraz and Legros (2020) reviewed several studies that investigated the risk factors for post-traumatic stress disorder (PTSD) and chronic psychological distress related to COVID-19. They found that pandemic-related stressors and worries, loss of a loved individual, exposure-related factors (e.g., living in a highly affected area), and sociodemographic factors are likely to contribute to an increased risk of chronic psychological distress and PTSD related to COVID-19. Moreover, Wu et al. (2020) carried out a large-scale study consisting of more than 4000 medical staff and college students from all provinces in China and asked them to fill out a questionnaire regarding the psychological stress status during the outbreak of COVID-19. The findings of their study suggested that in all Chinese provinces and on all items of the questionnaire, medical staff reported significantly higher levels of psychological stress compared to college students.

It is highly important, especially for healthcare workers to psychologically cope with the current circumstances. Hopefulness, knowledge-ability, resiliency, hardiness, etc., are among the factors that can well help people cope with this outbreak. Therefore, studies that investigate these factors are highly deified. One such study was carried out in Vietnam, in which 327 healthcare workers participated [ref.]. Most of these participants, fortunately, showed good knowledge and had a positive attitude concerning the risk of personal and family members becoming ill. Furthermore, most of these subjects were knowledgeable and had a positive viewpoint on COVID-19 (Giao et al. 2020). Another study was conducted in China, which also dealt with the attitudes of Chinese residents about this outbreak. The vast majority of these respondents (i.e., 97.1%) pointed out that they were confident that China will be able to overcome the current situation caused by COVID-19 (Zhong et al. 2020). Additionally, the majority of residents with an over average socioeconomic status, especially females reported that they have optimistic attitudes toward COVID-19 (Zhong et al. 2020).

Resiliency is another factor that appears to be beneficial in coping with the current circumstances. This is because one characteristic of resiliency is to keep our personality healthy when facing harmful effects such as distress. Resiliency can also help us become more flexible and responsible for fluctuating our system of personality adaptively when encountering environmental or internal demands. Meanwhile, it might appear that traumas always cause one to become less resilient. Despite this, the inverse relationship can also happen, because people may become more resilient and purposeful as a result of an external threat. This has an important implication concerning the COVID-19 outbreak, such that we can be hopeful that as a result of this situation we can become more resilient in the face of similar future conditions.

Spiritual well-being also seemingly plays an important role in coping with stressful events. Park (2017), for instance, surveyed 436 students who had survived trauma and found that there is a relationship between all aspects of spiritual well-being-meaning, peace, and faith and psychological adjustment. Moreover, Florez et al. (2018) examined whether basic levels of religious as well as existential well-being mediate the relation between levels of future suicidal ideation and hopelessness and levels of PTSD symptoms. They found that unlike religious well-being, existential well-being serves as an important future buffer against the negative impact of PTSD on suicidal ideation and hopelessness. Park and Cho (2017) also carried out a study in which they examined the relationship between spiritual well-being and post-cancer adjustment. The results of their study revealed that there is a positive relationship between these two variables. Furthermore Gaskin-Wasson et al. (2018), found that spiritual well-being serves as a buffer against feelings of social isolation, which in turn, is likely to help qualify the risk of negative mental outcomes.

Aim

At the gut level, it can be concluded that hopefulness, resiliency, and spiritual well-being can help us deal with the COVID-19 outbreak more effectively. Therefore, in the present study, we endeavor to examine the relationship between resiliency and hope with the stress of COVID-19 by mediating the role of spiritual well-being. Throughout this research, we are employing a machine learning method to extract nonlinear and relatively insignificant important factors that were challenging to identify using traditional techniques, thereby enabling a more accurate completion of the feature selection procedure. Machine learning methods may greatly reduce the time needed to extract critical factors from massive data sets and eventually increase precision in predictions. To the best of our knowledge, this is the first study in Iran that makes use of the machine learning method for COVID-19 to analyze the data.

Method

Participants and Procedures

The statistical population included the Iranian public. The inclusion criteria involved understanding spoken and written Persian language, and residence of Iran. In this case, Iranian public was encouraged to take part in an online survey promoted by Internet ads, e-mails, forums, social networks, and short message service (SMS) programs. We had 755 participants in this study with 32% and 67.7% of the participants are male and female, respectively.

Ethical Considerations

The present study was carried out following the approval of the Ethics Committee at Alzahra University, Iran, in 2020. All of the procedures conducted in this research with humans is consistent with the National Research Committee's ethical standards, the Helsinki Declaration of 1964 and its subsequent revisions, or equivalent ethical norms. Informed consent and participants’ information sheet indicated the right for the participants to withdraw at any point of the conducted research.

Measures

Sociodemographic characteristics of the participants in this study were comprised of the level of education, gender, age, knowing, or not knowing someone diagnosed with COVID-19.

The Resilience Scale

It is a self-report scale that was developed by Connor and Davidson in 2003. A scale is a 25-item tool that measures the resilience structure in a five-point Likert type from zero to four, with zero being the minimum resilience score. This scale has been standardized in Iran by Jowkar, Friborg, and Hjemdal (2010). They used Cronbach's alpha method to determine the reliability of the Connor–Davidson resilience scale and reported a reliability coefficient of 0.89. In the present research, its reliability was obtained 0.79 by Cronbach's alpha.

The Adult Hope Scale (He and Dong 2017; Sharif et al. 2017)

This scale has 12 items, 8 of which are used, and the other 4 are lie detectors that are not included in the scoring. The purpose of this questionnaire is to assess people's life expectancy. The scoring method is based on the five-point Likert type from 0 to 4. But this scoring method is reversed on items 3, 7, and 11. The score of each question should be calculated to get the overall score of the questionnaire. Higher scores indicate a higher life expectancy in the respondent and vice versa. Khodarahimi (2013) reported its reliability by Cronbach’s alpha 0.82. In this research, its Cronbach's alpha was 0.79.

Paloutzian & Ellison’s Spiritual Wellbeing Scale

This was developed in 1982. This scale has 20 items, 10 of which measure existential well-being and 10 items measure religious well-being. The range of religious and existential well-being scores is 10–60. The range to these items is in the form of a six-point Likert type; “completely disagree” to “completely agree.” The high score in this scale indicates the individual's spiritual and existential well-being, and the low score indicates that the person does not have the desired spiritual and existential well-being. In the study of Biglari Abhari et al. (2018) reliability of the spiritual well-being, the scale was determined by Cronbach's alpha 0.82. In this research, its Cronbach's alpha was 0.83.

The Stress of the Covid-19 Scale

Is a seven-item scale that was developed by Nooripour et al. (n.d.). The range to these items is a five-point Likert-type scale (strongly agree = 5, agree = 4, neither agree nor disagree = 3, disagree = 2, strongly disagree = 1). The minimum score possible for each item is 1, and the maximum is 5. A total score has been calculated by adding up each item score (ranging from 7 to 35). A higher score indicating greater stress of COVID-19 and vice versa. Nooripour et al. (n.d.) showed reliability internal consistency (α = 0.84) was appropriate and also they used confirmatory factor analysis (CFA) that the results are acceptable since the factor loadings for all the items were significant. The CFA findings also demonstrated that the single-factor structure provided a good fit to the data: sbX2 = 27.52 (p = 0.01), standardized root mean square residual (SRMR) = 0.022, CFI = 1.0, NFI = 0.99, IFI = 1.0, RFI = 0.99, GFI = 0.96, RMSEA = 0.050.

Data Analyses

To analyze our collected data, machine learning (ML)—model was employed. The missing values have been imputed before feature selection. Research focuses on the performance of the nonlinear model in predicting the stress of COVID-19 so the linear model is mainly used as an auxiliary comparative study. In the next section, a detailed description of the proposed ML-based model has given as its central role in the current study.

Machine Learning Algorithms

Undoubtedly in the contemporary world, artificial intelligence (AI) is one of the most important achievements of human beings. Artificial intelligence (AI) by incorporating several soft computational components like fuzzy logic neural networks, evolutionary algorithms can imitate human intelligence and use them to solve some problems that are solvable very hard or even they are intractable problems by the classic method (Hasanzadeh et al. 2020a). The intelligent models using machine learning algorithms can learn the behavior of the system and use the learned knowledge to solve the vast variety of problems from the industry to social science, neuroscience, psychology, etc. For example, we can find so many papers in the field of neuroscience that they have used an ML-based method. In this paper, we are trying to use machine learning to find a universal approximation model for the prediction of stress in response to some psychological inputs and mediators (Hasanzadeh et al. 2020b, 2018, 2019).

In this research, the adaptive neuro-fuzzy inference system (ANFIS) network was utilized for our prediction. In this case, a neural network is combined with a fuzzy inference system (FIS) to learn the underlying data details and adjust the parameters of the fuzzy membership function such that it can adapt to the environment dynamicity. The network can be utilized to solve various nonlinear and complex problems (Sonmez et al. 2018). Introduced by Jang (1993), the network is based on Sugeno Fuzzy using backpropagation and least square estimation as shown in Fig. 1. Consider a FIS with two inputs referred to as x and y and one output z. Let us consider two rules based on FIS as described by Güneri, Ertay, and Yücel (2011) using the first-order polynomial Sugo Fuzzy model where:

Fig. 1
figure 1

Architecture of the ANFIS model (Güneri et al. 2011)

Rule 1: \(If \, x \, is \, A_{1} \, and \, Y \, is \, B_{1} \, then \, f_{1} = p_{1} x + q_{1} y + r_{1}\).

Rule 2: \(If \, x \, is \, A_{{^{2} }} \, and \, Y \, is \, B_{2} \, then \, f_{2} = p_{2} x + q_{2} y + r_{2}\).

As shown in Fig. 1, at the first layer the nodes include squared function, while at the second layer, the products of the inputs to these layers are passed to the third layer. In the third layer, the mean ratios of the rule firing strength are determined and passed to the fourth layer. Similar to the first layer, every node in the fourth layer has a square function. The sum of the incoming input signals from the fourth layer is calculated in the final layer to create the output.

Results

Participant Characteristics

Our results showed that 389 participants (51.1%) were married and 366 are singles (48.5%) (Refer to Table 1). Furthermore, 666 participants (88.2%) knew someone who was infected with COVID-19, and only 89 cases (11.8%) knew no one with this condition. Concerning the level of education, 182 people (24.1%) had high school education, 47 cases (6.2%) had been graduated with a high school diploma, 259 people (34.3%) had an associate’s degree, 231 participants (30.6%) had a bachelor’s degree, and 36 individuals (4.8%) had higher degrees above bachelor’s degree. Mean and standard deviation (SD) for participants’ age was 32.53 and 10.63 years old, respectively.

Table 1 Sociodemographic characteristics of participants

Let “Hope” and “Resiliency” be represented by “\(x_{1} (n)\)” and “\(x_{2} (n)\),” respectively, while “Existential” and “Religious” are represented by “\(m_{2} (n)\)” and “\(m_{2} (n)\),” respectively, and finally “Stress” by “\(t(n)\),” where “\(x_{1} (n)\)” and “\(x_{2} (n)\)” represent the inputs of the ML, “\(m_{1} (n)\)” and “\(m_{2} (n)\)” are mediators, and “\(t(n)\)” is our target prediction. All the inputs, mediators, and targets are discrete functions of n variable, where n is the case number.

First Analysis: Linear Correlation

We have investigated the linear correlation of the inputs and the mediators with our target values as shown in Table 2.

Table 2 Linear correlation of the inputs and mediators with the target

As illustrated in Table 2, “hope” and “resiliency” have a weak negative linear correlation with “stress,” while the mediators’ values showed no linear correlation with “stress.” This indicates that by the increase of “hope” and “resiliency,” “stress” will be decreased. On the other hand, this linear correlation has no clarification about the synergistic effect of neither inputs nor the combination of inputs and mediators. Hence, to address this problem a machine learning-based method has been adopted to show both linear and nonlinear relationships of all inputs, mediators, and their combinations with stress.

Second Analysis: ML-based Analysis

Let “Hope” and “Resiliency” be represented by “\(x_{1} (n)\)” and “\(x_{2} (n)\),” respectively, while “Existential” and “Religious” are represented by “\(m_{2} (n)\)” and “\(m_{2} (n)\),” respectively, and finally “Stress” by “\(t(n)\),” where “\(x_{1} (n)\)” and “\(x_{2} (n)\)” represent the inputs of the ML, “\(m_{1} (n)\)” and “\(m_{2} (n)\)” are mediators, and “\(t(n)\)” is our target prediction. All the inputs, mediators, and targets are discrete functions of n variable, where \(n\) is the case number.

To determine the real relationship among inputs and mediators and the stress and their combinations and predict the stress using inputs and mediators, stress behaviors are predicted using the following nine states:

State 1: \(x_{1} (n) \to t(n)\).

State 2: \(x_{2} (n) \to t(n)\).

State 3: \((x_{{_{1} }} (n),x_{2} (n)) \to t(n)\).

State 4: \((x_{1} (n),x_{2} (n)\left| {m_{1} } \right.(n)) \to t(n)\).

State 5: \((x_{1} (n),x_{2} (n)\left| {m_{2} } \right.(n)) \to t(n)\).

State 6: \((x_{1} (n),x_{2} (n)\left| {m_{2} } \right.(n)) \to t(n)\).

State 7: \((m_{1} (n)) \to t(n)\).

State 8: \((m_{2} (n)) \to t(n)\).

State 9: \((m_{1} (n),m_{2} (n)) \to t(n)\).

For example, in “State 1” “Stress” is predicted using only “Hope,” on the other hand, in “State 6” the prediction of “Stress” is performed using both inputs (“Hope” and “Resiliency”) on the condition to know both mediators (“Existential” and “Religious”). For this prediction, machine learning has used and correlation of “Predicted Stress (\(t^{ \wedge } (n)\))” and actual “Stress (\(t(n)\))” have been calculated to describe the accuracy of the model in the nine mentioned states as shown in Table 3 and Figs. 2, 3.

Table 3 “Predicted Stress (\(t^{ \wedge } (n)\))” and actual “Stress (\(t(n)\))”
Fig. 2
figure 2

Predicted stress (\(t^{ \wedge } (n)\)) and actual “Stress (\(t(n)\))

Fig. 3
figure 3

Actual stress (Red) and its prediction by the proposed ML model (Blue) (Color figure online)

Several states have been adapted in this work to identify the relationship between the inputs and mediator and characterize the effect of the mediator to predict the stress; the effect of input can be measured separately. For example, in-state 1 using hope as the only input to predict stress showed inaccurate prediction. Another example is presented in-state 2 in which resiliency has been used as input to our model where stress cannot be predicted properly. However, using both hope and resiliency as in state 3, accuracy has been increased but it is still below the expected level. Hence, mediators have been added as conditional terms in the model. As illustrated in Table 3, adding mediator in addition to hope and resiliency as inputs in Stage 4, the prediction accuracy has been improved significantly which encourages us to test other states. Hence, in state 6 both subscales of mediator have included in addition to hope and resiliency, in this case, accuracy has been improved to 80% indicating that the ML model can effectively predict stress accurately using hope and resiliency as inputs and religious and existential as mediators, showing that mediators have a significant effect in the analysis of the stress among our sample.

To investigate the efficacy between the mediators and the stress, two other experiments have been conducted; in the former, state 7, the only existential mediator has been used showing -2.30% (as Table 3). This shows that existential has no significant relationship with stress; however, it has significant help synergistically to predict stress.

We have five vectors that we call “Hope” and “Resiliency” as “\(x_{1} (n)\)” and “\(x_{2} (n)\),” “Existential” and “Religious” as “\(m_{1} (n)\)” and “\(m_{2} (n)\)” and finally “Stress” as “\(t(n)\),” where “\(x_{1} (n)\)” and “\(x_{2} (n)\)” are inputs of the model, “\(m_{1} (n)\)” and “\(m_{2} (n)\)” are mediators where they are also the potential inputs of the model, and “\(t(n)\)” is the target. The aim of the proposed model is the prediction of \(t(n)\) using the inputs and mediators themselves and their combinations and finds the effects of all combinations.

Mathematically, we are looking for an approximation of the following relation:

$$t(n) = f(u(n))$$
(1)

where \(u(n)\) can be each of the inputs, mediators, or their combinations; for example, for the realization of states 1, 6, and 9 it should be \(u(n) = x_{1} (n)\), \(u(n) = (x_{1} (n),x_{2} (n),m_{1} (n),m_{2} (n))\) and \(u(n) = (m_{1} (n),m_{2} (n))\), respectively. The proposed method for approximation \(f()\) is the development of inputs and mediators interactions using polynomial functions (Annabestani et al. 2019; Hasanzadeh et al. 2019) which for state 6 is defined as follows:

$$t(x) = \theta_{0} + \sum\limits_{{i_{1}}}^{4} ={}_{1} \theta_{{i_{1}}} u_{{i_{1} }} (n) + \sum\limits_{{i_{1}}}^{4} ={}_{1} \sum\limits_{{i_{2}}}^{4} ={}_{1} \theta_{i1i2} u_{i1} (n)u_{i2} (n) +\cdots + \sum\limits_{i2}^{4} = 1\ldots\sum\limits_{j4}^{4} = 1\theta_{i1} \ldots i_{4} u_{i1} (n)\ldots u_{i4} (n)$$
(2)

The ultimate purpose of this model is to find the unknown parameters, i.e., \(\Theta\) \(\theta\) parameters which according to the least mean square (LMS) method and using the real data that will be predicted. Algorithm 1 shows our proposed methodology.

Algorithm 1: Prediction of COVID-19 Stress Using ANFIS Network

Let X represents the set of inputs where X = {“Hope,” “Resiliency”}.

Let M represents the set of mediators where M = {“Existential,” “Religious”}.

Let t(n) represents the stress for variable n.

Let S represents the set of state.

$$\begin{gathered} S = \left\{ {s_{i} \left| {i \in \left[ {1,9} \right],inputs} \right. \in XUM,outputst(n)} \right\} \hfill \\ \forall s_{i} \in S,\exists ANIS \to Accuracy\left[ {S_{i} } \right] \ge Accuracy\left[ {S_{i} } \right]\,where\,i,j \in \left[ {1,9} \right]\,and\,i \ne j \hfill \\ \hfill \\ \end{gathered}$$

Discussion

The present study aimed to examine how machine learning, in particular adaptive neuro-fuzzy inference system, helps psychiatrists to predict stress of Covid-19, mediating by spiritual well-being.

Our extensive simulation results indicate that each of the variables can predict a relatively small amount of stress of Covid-19, but in the presence of both spiritual well-being subscales (religious and existential), the stress of Covid-19 is very low in individuals, and the two variables hope and resiliency alone cannot be a good as a predictor for spiritual well-being, but in the presence of spiritual well-being subscales (religious and existential) can predict appropriately. On the other hand, spiritual well-being itself cannot predict stress of Covid-19 alone, and in fact, someone who has high spiritual well-being does not necessarily have a small amount of stress, and this variable, along with hope and resiliency, can be a good predictor of stress.

Analysis of the literature on neurobiological and psychosocial influences correlated with stress, resilience, and hope and spiritual well-being leads to some potential treatments for people suffering from COVID-19 stress or at risk of experiencing it (Wu et al. 2020). Potential interventions involve cognitive rehabilitation, psychological, social, cultural, and neurobiological methods mixture of such methods. It should be noted that there is a need for a multi-level approach in resilience research and resilience-promoting strategies—which involves the criticality of conducting hope and spirituality, as well as stress.

The conventional feature selection approach is focused on a large volume of relevant knowledge and domain expertise and aims to select features using a linear correlation. Many latent and nonlinear characteristics are also largely neglected and withdrawn from the simulation. Such nonlinear features may play a crucial role in predicting target variables (Yagiz et al. 2009). Factors with a strong linear correlation or nonlinear correlation can be detected more quickly, and the result indicates that such a feature selection method finds certain nonlinear features (with low Pearson scores) that were invisible in the linear feature analysis. The predictive model can be improved by including those features in the modeling. It is necessary to adopt a nonlinear model with nonlinear correlated features to capture the nonlinear relationships between the features and the target variables. A deep neural network is a powerful form of nonlinear machine learning. Active functions on a large number of neurons provide nonlinearity, while network depth gives an elastic capacity to catch complex relationships compared to conventional approaches such as random forest (Orfanoudaki et al. 2020). It is important to address the following concerns to construct an effective predictive model: When a feature is chosen, it should allow a sound contribution in the prediction phase, not simply because it has a causal relationship with the target variable. In other terms, it is more important to consider the correlation between the features and the target variables than causality here.

The result of this paper cannot be used for intervention: Changing a function will not necessarily have any effect on the target variables. This does not mean that using machine learning methods to address such problems is futile. Conversely, an accurate predictive model is valuable, e.g., for production scheduling preparation, etc.

These selected features often provide a novel starting point for further analysis: why are they related, especially when this correlation is nonlinear? Machine learning methods can help social scientists discover hidden factors previously ignored and form a new hypothesis based on these, which is a new paradigm of data-driven social science research. The method's implementation relies on its predictive potential. Many relevant scenarios involve forecasting different social factors, pre-allocating capital, and enabling other similar industries to develop.

Depending on the statistical model, we can also construct an intervention construct through the further advancement of the causality analysis (based on approaches such as the Bayesian network). Our approach has more efficient capabilities in processing data than conventional approaches. The most significant benefit of using machine learning methods is the ability to process large, complex data sets quickly. In Iran and around the world, the use of machine learning and also deep learning is too common in the field of behavioral and cognitive studies. Machine learning methods are quicker, more consistently reliable, and have higher results compared to conventional approaches.

Another advantage of our approach is its potential for generalization. Since our approach to the selection of features requires no prior knowledge, it can be applied to a wide range of domains. However, the modeling method is not domain-specific: A general-purpose model is a deep neural network. While it requires to change the hyper-parameters in various programming contexts, most of the training procedures are automatically implemented and can respond to specific domains.

Limitations

Despite the contribution of nonlinear feature selection algorithms and the benefit of non-parametric machine learning models in terms of prediction performance, models' limitations should also be recognized. It is well known that there is a trade-off between the precision of the forecast and the explainability of the model. However, since the main goal of the research is to identify methods and procedures that optimize the process of selection of features and facilitate prediction, we did not provide a detailed discussion on predictor explainability.

Conclusion

Machine learning techniques have been shown to provide a useful tool for the prediction of stress values among the Iranian population due to their nonlinear structure. Our extensive study showed that traditional social science analytical methods, including multiple linear regression, cannot detect nonlinear features which are necessary for such application due to the nature of the data; on the other hand, feature selection information is designed around the data and the effects are determined directly from the data. This saves a considerable amount of time in comparison to manually reviewing the literature and evaluates review-based characteristics. It can also avoid the interference of prior knowledge and bring a new way of thinking and perspective.

In summary, the whole process of the machine learning methods will minimize the influence of expertise and contribute to greater dependence on the data to achieve accurate predictions. It can be used to build data-driven, general analysis paradigms that can be transferred to any domain.