1 Introduction

In México, the first death from COVID-19 recognized by the Ministry of Health was reported on March 19th. From this date until September 30th, a total of 77,646 cumulative deaths from COVID-19 have been recorded according to the “Daily Technical Report” [1]. With this number, México ranks in the first places of mortality from COVID-19 globally, based on data registered by the Johns Hopkins University [2]. The vulnerability that México presents at the national level due to virus infection depends on the high number of the sick population with multiple comorbidities. On April 30, 1859 deaths were registered, determining that the deceased suffered from other diseases such as hypertension, diabetes and obesity [3]. On the other hand, hospitalized patients and those with pneumonia carry an increased risk of mortality [4]. With these factors, México will surely continue at risk of increasing its level of mortality, coupled with the season of manifestation of other infectious diseases such as influenza [5] and dengue [6]. Given the imminent risk due to the spread of the virus, it is essential to model and predict both the number of cases of COVID-19 infection and the number of deaths, in order to provide scenarios for the health sector that can reinforce the measures of prevention and control.

In recent months, various investigations have emerged with the aim of modeling and predicting the dynamics of COVID-19 applying important models, as reported: Rahman et al. [7] developed a fractional-order fuzzy dynamical system for modeling COVID-19. The results show that when applying a random model determined by a system of random differential equations, they obtain better results. Ndaïrou et al. [8] proposed a compartmental mathematical model for the spread of the COVID-19 focused on the transmissibility of super-spreading individuals. The results show that the model fits well with the real data of confirmed cases and deaths presented per day in Wuhan, China. Giordano et al. [9] proposed a new SIDARTHE model that predicts the course of the COVID-19 epidemic in Italy. The results show that when social distancing measures are combined with widespread testing, they can end the course of the pandemic. Fanelli and Piazza [10] predicted the spread of COVID-19 in China, Italy and France through a SIRD model. The results show that the recovery rate for Italy and China is the same, while the infection and death rates are different. Acuña-Zegarra et al. [11] used a modification of the Kermack–McKendrick SEIR model to analyze the effect of behavior change and containment of COVID-19 in México. The results indicate that the maximum incidence depends on the compliance and the abandonment rate of the Sanitary Emergency Measures.

Analyzing previous the research works, focused on modeling and predicting the dynamics of COVID-19, it is noted that they are based on complex mathematical models. Therefore, the application of alternative models becomes feasible when they demonstrate the ability to solve nonlinear dynamic problems. An example is the Gompertz model, based on a differential equation designed to analyze the dynamics of a specific behavior through growth curves. This model has been implemented in the dynamics of COVID-19, as reported by: Manca et al. [12] applied simple models to predict intensive care unit beds and mortality rate for hospital emergency planning due to COVID-19. The results show that the Gompertz model has better accuracy and reliability in predicting deaths compared to other simple models. Sánchez-Villegas and Codina [13] described a methodology based on Gompertz curves to predict factors that are key in the COVID-19 epidemic. The authors emphasize that a simple model can be effective by using only the observed data, without applying some type of external covariate. Perez et al. [14] compared an autoregressive integrated moving average (ARIMA) and a Gompertz function growth model in the COVID-19 cases applied for Austria, Switzerland and Israel. The results show that both models have a correlation index higher than 0.999, predicting that the end of the pandemic is close in the three countries. Another example of an alternative model, where it has been applied to model the dynamics of COVID-19, is through artificial neural networks (ANNs), as described by: Wieczorek et al. [15] developed a neural network model for COVID-19 spread prediction in various countries. The results show a high precision with 99% in some cases and a general precision 87.70% in most of the regions. Torrealba-Rodriguez et al. [16] applied mathematical and computational models to predict the number of COVID-19 cases in México. The results show a better correlation between the observed data and those obtained by an artificial neural network with respect to the mathematical models. Mollalo et al. [17] examined an artificial neural network model for the nationwide prediction of COVID-19 incidence in the USA. The results show that with the precision obtained in various factors, they can reveal relevant information to monitor the COVID-19 outbreak.

The aim of this paper is to compare an artificial neural network with respect to a Gompertz model to carry out the prediction of the dynamics of deaths caused by COVID-19 in México. Before carrying out the prediction, it is necessary to develop the modeling process applying multiple optimization algorithms to obtain the best data fit. To estimate the coefficients of the ANN model during learning, the optimization algorithms were applied: Levenberg–Marquardt, BFGS quasi-Newton and batch gradient descent. To estimate the parameters of the Gompertz model in the sense of least squares, the optimization algorithms were applied: Nelder–Mead simplex, nonlinear regression and curve fitting. The data published by the daily technical report COVID-19 in Mexico from March 19th to September 30th were used for the development of both models. Once the best optimization algorithm to fit the data has been determined, the prediction of cumulative deaths from COVID-19 is carried out including recent data for the month of October.

In summary, the main contributions of this paper are:

  1. 1.

    Comparison of two models with different approaches applied for the modeling and prediction of the dynamics of deaths from COVID-19 in México.

  2. 2.

    Propose an efficient optimization algorithm that performs the fit of the real data for each model based on the calculation time and convergence.

  3. 3.

    Determine similarities and differences during the development of both models.

  4. 4.

    Demonstrate that the proposed models can predict reliable data within a suitable time period for decision making.

The remainder of this paper is organized as follows: In Sect. 2, details on the source and behaviors of the data set are presented. In Sect. 3, the artificial neural network and Gompertz methodologies are specified, as well as the statistical criteria to evaluate both models, containing three subsections: the first focused on describing the development of the artificial neural network, its inverse and the optimization algorithms used to fit the coefficients. The second dedicated to explaining the development of the Gompertz model, its reparametrization and the optimization algorithms to fit the parameters. The third aimed at determining the correlation and difference when comparing the real data with respect to those fitted by both models. In Sect. 4, the results of the modeling and prediction are presented for each methodology, as well as a comparison between both, divided into three subsections: the first exposes the modeling and prediction of the dynamics of deaths applying the artificial neural networks model. The second is the modeling and prediction of the dynamics of deaths applying the Gompertz model are presented. The third shows an analysis, resulting from the comparison of both models, highlighting their similarities and differences. Finally, the last section presents the conclusions.

2 Dataset

In this work, the data set used to develop the artificial neural network and the Gompertz model was obtained from the "Daily Technical Report" [1] by the Ministry of Health. The government of México issues the analysis and results of the data referring to COVID-19 obtained from the health authorities of all the states of the country through the transmission by national television network, beginning the transmission at 7:00 pm and ending at 8 pm (Time in México City, CDMX). The information issued is detailed in the "Daily Technical Report," which is made available with other documents on the official website of the Federal Health Secretariat, through the General Directorate of Epidemiology.

Figure 1 shows the daily deaths recorded at the national level from March 19th to September 30th (196 real data) and cumulative number of deaths by COVID-19, registering a maximum value of 1092 deaths (June 3rd). The data reflect ups and downs uniform in the last months, so it is difficult to determine an overall trend, unlike the confirmed cases of COVID-19. For this reason, the present work focuses on modeling cumulative number of deaths, considering that the ups and downs will test the capacity of both models.

Fig. 1
figure 1

Number of daily and cumulative deaths from COVID-19 in Mexico

3 Methodology

In this section, the particular specifications to apply the artificial neural network and the Gompertz model are described in order to perform the modeling and prediction of the dynamics of deaths from COVID-19 in Mexico.

3.1 Artificial neural network model

3.1.1 Development of the artificial neural network

An artificial neural network (ANN) is based on a computational structure of layers, in which information is introduced in order to model linear and nonlinear outputs through a learning process. The ANN model of the feedforward type has demonstrated the efficiency of combined local and global approximation capabilities [18].

The general architecture of a simple ANN is designed with three layers. The input layer, which is determined from the input variables (\(ln\)) and the number of input data (\(k\)) to be used, assigns a weight factor (\(Wi\)) for each one and adds a compensation value called bias (\(b_{1}\)) to generate an input (\(n_{s}\)), as described in the following equation:

$$ n_{s} = \mathop \sum \limits_{{k = 1}}^{K} \left( {Wi_{{s,k}} \cdot ~ln_{k} + ~b_{{1\left( s \right)}} } \right) $$
(1)

In the hidden layer, the number of neurons (s) is determined through the application of a transfer function to represent the desired output, highlighting the hyperbolic tangent sigmoid transfer function (TANSIG). In the output layer, the associated coefficients in the hidden layer (W0, b2) are coupled and grouped in matrices to generate a final output. Generally, a linear function (PURELIN) is used to represent the final output of the artificial neural network.

The transfer functions are given by the following:

$$ {\text{TANSIG}} = \frac{2}{{1 + e^{{ - 2n_{s} }} }} - 1 $$
(2)
$$ {\text{PURELIN}} = n_{s} $$
(3)

To carry out the development of the ANN model, the data must be divided randomly. The division aims to generate information to train (60%), test (20%) and validate (20%) the ANN model. The input variable (\({X}_{n}\)) was normalized in the interval [0.1–0.9] using the following equation:

$$ x_{N} = 0.8 \times \left( {\frac{{X_{n} - X_{{{\text{min}}}} }}{{X_{{{\text{max}}}} - { }X_{{{\text{min}}}} }}} \right) + 0.1 $$
(4)

The output value to be modeled (cumulative number of deaths) was divided by 1000 to avoid obtaining large coefficients and improve computing time. With the normalized data, a learning process is executed in order to minimize the difference between the desired output and the result obtained by the ANN model through a backpropagation algorithm. The square root of the mean error (RMSE) was applied as a criterion to determine the fit of the ANN model during training. Figure 2 shows in a general way the development of the ANN model, described above.

Fig. 2
figure 2

Schematic diagram of the development of the ANN model

The ANN model in general proposed to model the cumulative number of deaths (\(N_{D}\)) from COVID-19 is represented by the following equation:

$$ N_{D} = b_{2} - \mathop \sum \limits_{{s = 1}}^{s} Wo_{{\left( s \right)}} + \mathop \sum \limits_{{s = 1}}^{s} \left( {\frac{{2Wo_{{\left( s \right)}} }}{{1 + e^{{\left( { - 2 \cdot \left( {Wi_{{\left( s \right)}} \cdot t + b_{{1\left( s \right)}} } \right)} \right)}} }}} \right) $$
(5)

where \(t\) is the number of days since the first death.

3.1.2 Inverted ANN model approach

The inverse ANN prediction methodology has been applied as an extrapolation tool to determine values of interest [19]. The development of the inverse ANN model consists of applying the coefficients obtained by the ANN model to propose an objective function, which allows extrapolating the output value depending on the search for the input value. To carry out the prediction of the cumulative number of deaths using the inverse ANN model, it is necessary to propose an objective function for calculating the number of days \(\left( t \right)\) on which a certain number of cumulative deaths (\(N_{D}\)) from COVID-19 will occur. This can be represented through the following equation:

$$ {Fun\left( t \right) = - N_{D} + b_{2} - \mathop \sum \limits_{{s = 1}}^{s} Wo_{{\left( s \right)}} + \mathop \sum \limits_{{s = 1}}^{s} \left( {\frac{{2Wo_{{\left( s \right)}} }}{{1 + e^{{\left( { - 2 \cdot \left( {Wi_{{\left( s \right)}} \cdot t + b_{{1\left( s \right)}} } \right)} \right)}} }}} \right)~} $$
(6)

The objective function must be minimized as close to zero as possible to obtain with certainty the number of deaths with respect to the number of days.

3.1.3 Optimization algorithms for estimating the coefficients in data fit

To estimate the coefficients (weights and bias) during the learning process of the ANN model, an optimization algorithm must be applied. In this work, three different optimization algorithms were tested, outstanding for solving complex optimization problems and effective in finding coefficients in artificial neural networks. The Levenberg–Marquardt algorithm was designed to approach second-order training fast without having to compute the Hessian matrix obtaining better convergence when training neural networks [20]. The quasi-Newton BFGS is an iterative algorithm that belongs to the quasi-Newton methods, which avoid the inversion of the Hessian matrix by directly calculating the inverse of a pseudo-Hessian matrix, improving the computational efficiency of the whole calculation [21] and demonstrating a better performance in the development of the ANN model architecture [22]. The batch gradient descent algorithm is based on calculating the coefficients in the direction of the negative gradient and is characterized by reducing the error of the neural network as rapidly as possible [23]. All the calculations necessary to develop the ANN model and the application of the optimization algorithms were carried out with MATLAB mathematical software.

3.2 Gompertz model

3.2.1 Development of the Gompertz model

The Gompertz model was developed to determine human mortality through a growth curve [24]. Subsequently, it was applied in aspects related to health such as tumor growth [25], bacterial growth [26], among others. The Gompertz model uses a differential equation, where a sigmoidal growth curve for specific behavior is described. The basic equation of Gompertz model can be written in the following form:

$$ \frac{{{\text{d}}L\left( t \right)}}{{{\text{d}}t}} = - \alpha L\left( t \right)ln\frac{L\left( t \right)}{C} $$
(7)

where \(L\left( t \right)\) is the dependent variable in the model (the number of cumulative deaths at time \(t\)), \(\alpha\) are the parameters for the growth rate in the model and \({\varvec{C}}\) is the maximum possible value obtained from the model (the maximum number of cumulative deaths per unit of time).

3.2.2 Reparameterization of the Gompertz model

The reparameterization of the growth model is essential to obtain mathematical parameters with an important meaning in the generated function. The growth curves of the Gompertz model can be expressed in different ways depending on the number of parameters to be used, but they coincide in including a double exponential. In this work, an equation with three parameters was applied to model the dynamics of deaths from COVID-19:

$$ L\left( t \right) = ae^{{ - e^{{ - b\left( {t - c} \right)}} }} $$
(8)

where \(L\left( t \right)\) is the number of cumulative deaths for each day \(\left( t \right)\); \(a\) is the maximum number of cumulative deaths at the end of the epidemic; \(b\) is the estimated relative growth rate of total deaths;\((t)\) is the number of days from the first case and \(\left( c \right)\) is the moment at which the inflection point of the curve is estimated. Figure 3 shows in a general way the proposed procedure to apply the Gompertz model to carry out the modeling of the dynamics of deaths.

Fig. 3
figure 3

Schematic diagram of the development of the Gompertz model

3.2.3 Optimization algorithms for estimating the parameters in data fit

To carry out the estimation of parameters in the Gompertz model, it is necessary to apply an optimization algorithm to fit the data. For the particular case of the Gompertz model, three optimization algorithms were tested, notable for performing the search for parameters in the shortest possible time starting from initial conditions. The Nelder–Mead simplex algorithm was designed to solve nonlinear optimization problems without restrictions and does not require derivative computation of the function under test [27]. Nonlinear regression algorithm is a type of regression to determine parameters of a model that requires fitting real data [28]. Curve fitting algorithm is characterized by solving equations with multiple parameters associated with the curve jointly [29]. All the calculations necessary to develop the Gompertz model and the application of the optimization algorithms were carried out with MATLAB mathematical software. These algorithms determine the parameters using the least squares method in order to minimize the sum of the squared of the differences between the data obtained from the Gompertz model and the real data, as represented by the following equation:

$$ Min_{a,b,c} \left\{ {SSE = \mathop \sum \limits_{i = 1}^{n} \left( {y_{i}^{{{\text{real}}}} - yi^{{{\text{model}}}} } \right)^{2} } \right\} $$
(9)

3.3 Evaluation of the models

From the coefficients and parameters estimated for the artificial neural network and the Gompertz model, the modeled data were compared with the real data. To evaluate the fit of the models, statistical criteria were applied to determine the correlation index and error measurement. The regression coefficient (R2) is widely used to infer the degree of linear correlation between the data. The mean absolute percentage error (MAPE) measures the size of the absolute error in percentage terms. These criteria are calculated through the following equations:

$$ R^{2} = 1 - \frac{{\mathop \sum \nolimits_{i = 1}^{n} \left( {x_{{{\text{real}}\left( i \right)}} - x_{model\left( i \right)} } \right)^{2} }}{{\mathop \sum \nolimits_{i = 1}^{n} \left( {x_{{{\text{real}}\left( i \right)}} - \overline{x}_{real} } \right)^{2} }} $$
(10)
$$ MAPE = \frac{{\mathop \sum \nolimits_{i = 1}^{n} \left| {\frac{{ _{{x_{{{\text{real}}\left( i \right)}} - x_{model\left( i \right)} }} }}{{x_{{{\text{real}}\left( i \right)}} }}} \right|}}{n} \times 100 \left( \% \right) $$
(11)

where \(\overline{x} = \frac{1}{n}\mathop \sum \limits_{i = 1}^{n} x_{\left( i \right)}\) is the average of the real value; \(x_{model\left( i \right)}\) is the output value obtained by the model; and \(x_{{{\text{real}}\left( i \right)}}\) is the real value.

4 Results and discussion

In this section, the results obtained from modeling and predicting the dynamics of deaths in Mexico with the application of the models are presented. In the modeling process, various optimization algorithms were used to obtain a proof equation and thus support the prediction. Finally, a comparative analysis between both models is described.

4.1 Modeling and prediction of death dynamics applying artificial neural networks

4.1.1 Modeling the cumulative number of deaths with ANN

The ANN model was developed using an optimal architecture to carry out the modeling of cumulative number of deaths by COVID-19 in México from March 19th to September 30th. To estimate the coefficients, three optimization algorithms were applied, which fit the weights and biases through a feedforward backpropagation. All calculations were performed on a computer with the following characteristics: Intel® Core™ i3-3217U CPU, 1.80 GHz, 4 GB RAM and 500 GB hard disk. Figure 4 shows the real data of cumulative deaths by COVID-19, as well as the estimated data of the ANN model applying the optimization algorithms: a) Levenberg–Marquardt, b) BFGS quasi-Newton and c) batch gradient descent. The comparison between the real data and those obtained by the ANN model when using the optimization algorithms presents a satisfactory correlation with an R2 > 0.999. Table 1 shows the errors (RMSE) and times in which the coefficients were estimated during the learning process. The criterion of MAPE was useful to determine the percentage error of the real data with respect to the models focused on the last trimester of the period studied; this is because the registered deaths show uniform ups and downs and the models adapt better.

Fig. 4
figure 4

Comparison between cumulative deaths and those estimated by the ANN model applying the optimization algorithms: a Levenberg–Marquardt, b BFGS quasi-Newton and c batch gradient descent

Table 1 Application of three optimization algorithms to fit the coefficients for the ANN model

The results show that the Levenberg–Marquardt algorithm estimated the coefficients in the shortest possible time (46.23 s) using an architecture of three neurons in the hidden layer. On the other hand, the BFGS quasi-Newton algorithm demonstrated greater precision during reflected training with an RMSE of 0.2165 and MAPE of 0.33% using an architecture of three neurons in the hidden layer. Finally, the batch gradient descent algorithm presented the least capacity to model the real data, as it required of six neurons in the hidden layer and a greater computation time (268.75 s). Based on computation time, the Levenberg–Marquardt algorithm is the most suitable for modeling the dynamics of deaths. With the best optimal architecture (1–3-1) and hyperbolic tangent sigmoid transfer function (TANSIG).

In this work, Eqs. (1215) are presented as proof to demonstrate the coupling of the coefficients obtained during the learning process to the ANN model (Eq. 5), as well as illustrating that using three neurons in the hidden layer, ten coefficients are generated. Therefore, Eqs. (1215) can be applied directly to simulate the cumulative number of deaths (\(N_{D}\)).

$$ \begin{aligned} N_{D} &= 45.0504 - \left[ {\left( { - 44.8528} \right) + \left( {2.1309} \right) + \left( {3.7335} \right)} \right] \\ \; + \left[ {\frac{{2 \cdot \left( { - 44.8528} \right)}}{{1 + e^{{\left( {x_{1} } \right)}} }} + \frac{{2 \cdot \left( {2.1309} \right)}}{{1 + e^{{\left( {x_{2} } \right)}} }} + \frac{{2 \cdot \left( {3.7335} \right)}}{{1 + e^{{\left( {x_{3} } \right)}} }}} \right] \\ \end{aligned} $$
(12)

where in \(x\), the input variable (\(t\)) is integrated for the 3 neurons in the hidden layer.

$$ x_{1} = - 2 \cdot \left( {\left( { - 3.3207} \right) \cdot t + 2.1520} \right) $$
(13)
$$ x_{2} = - 2 \cdot \left( {\left( { - 8.9762} \right) \cdot t + 1.5450} \right) $$
(14)
$$ x_{3} = - 2 \cdot \left( {\left( {12.9962} \right) \cdot t + \left( { - 5.9835} \right)} \right) $$
(15)

*Remember that it is necessary to normalize the input value (\(t\)) according to Eq. (4) and the final result (\(N_{D}\)) multiply by 1000.

4.1.2 Prediction of the cumulative number of deaths with inverse ANN

To carry out the prediction of cumulative number of deaths, the ANN model was developed again using recent data (month of October) in order to obtain a better prediction in the data extrapolation. To estimate the coefficients of the ANN model, the Levenberg–Marquardt algorithm was applied based on its efficiency (previously demonstrated). Table 2 presents the coefficients to predict the cumulative number of deaths applying three neurons in the hidden layer. Subsequently, the coefficients are coupled in Eq. (6) to propose the inverse ANN model. The resulting objective function is minimized by applying a genetic algorithm, as shown in Fig. 5.

Table 2 Estimated coefficients for the inverse ANN model considering the real data from March 19th to October 31st
Fig. 5
figure 5

Minimization of the objective function

Table 3 compares the number of real cumulative deaths and those predicted by the inverse ANN model from November 1st to 15th. The purpose of the comparison is to verify that the proposed model can serve as a guide to predict and control the number of deaths caused by COVID-19 infection taking advantage of a period of 15 days to strengthen sanitary measures. The maximum error when comparing the real and predicted data was 2.22% per day, which is satisfactory for making decisions.

Table 3 Comparison of the real data with respect to those predicted by the inverse ANN model

4.2 Modeling and prediction of death dynamics applying Gompertz model

4.2.1 Modeling the cumulative number of deaths with Gompertz model

The Gompertz model was developed to carry out the modeling of cumulative number of deaths from COVID-19 in México from March 19th to September 30th. To estimate the parameters, optimization algorithms were applied, which minimize the sum of the nonlinear squares in the shortest possible time and obtain a significant correlation in the data fit. Figure 6 shows the real data of cumulative deaths by COVID-19, as well as the estimated data of the Gompertz model applying the optimization algorithms a) Nelder–Mead simplex, b) nonlinear regression and c) curve fitting. The comparison between the real data and those obtained by the Gompertz model when using the optimization algorithms presents a good fit with an R2 > 0.999. All calculations were performed on a computer with the same characteristics used to develop the ANN model. Table 4 shows that the optimization algorithms present the same coefficient of determination of 0.9998 and percentage error of 0.65%. (The MAPE was applied to the real data with respect to the models in the last trimester of the period studied.)

Fig. 6
figure 6

Comparison between cumulative deaths and those estimated by the Gompertz model applying the optimization algorithms: a Nelder–Mead simplex, b nonlinear regression and c curve fitting

Table 4 Application of three optimization algorithms to fit the parameters for the Gompertz model

The results show that the Nelder–Mead simplex algorithm estimated the parameters with the shortest possible time (0.26 s), followed by the nonlinear regression (0.42 s) and finally the curve fitting (1.51 s). Based on this factor, the Nelder–Mead simplex optimization algorithm is the most appropriate to model the cumulative number of deaths from COVID-19.

In this work, Eq. (16) is described as a proof to demonstrate the coupling of the three parameters obtained by the least-squares method to the Gompertz model (Eq. 8). Therefore, Eq. (16) can simulate the cumulative number of deaths (\(L\)) as a function of the number of the day (\(t\)).

$$ L\left( t \right) = 98008.0988e^{{ - e^{{ - 0.01830109\left( {t - 117.8062} \right)}} }} $$
(16)

4.2.2 Prediction of the cumulative number of deaths with Gompertz model

In the same way as in the ANN model, to carry out a better prediction applying the Gompertz model, recent data were used (month of October). To estimate the parameters of the Gompertz model, the Nelder–Mead simplex algorithm was applied based on its efficiency (previously demonstrated). Unlike the inverse ANN model, the Gompertz model only extrapolates based on the application of Eq. (8) and applying the parameters presented in Table 5.

Table 5 Estimated parameters for the Gompertz model considering the real data from March 19th to October 31st

Table 6 compares the number of real cumulative deaths and those predicted by the Gompertz model from November 1st to 15th. In the same way as in the inverse ANN model, the proposed Gompertz model has the objective of predicting and controlling the number of deaths. The maximum error when comparing the real and predicted data was 5.48% per day, which is moderately satisfactory for making decisions.

Table 6 Comparison of the real data with respect to those predicted by the Gompertz model

4.3 Comparison between both models

According to the results obtained on the modeling of cumulative deaths from COVID-19 in México through artificial neural networks and the Gompertz model, some similarities stand out between both models, such as the mathematical and computational development is considered moderate compared to other models that apply a series of complex mathematical equations. However, these models are capable of modeling nonlinear behaviors with significant fit. The data estimated by the both models present differences with the real data in the first days of the studied period, obtaining negative values in artificial neural networks and high values in the Gompertz model with respect to the real data.

In addition to the similarities, in the development of both models, some differences stand out such as the Gompertz model is capable of modeling nonlinear behavior through three parameters, unlike the ANN model, which requires ten coefficients to carry this function. However, the ANN model has better correlation and precision compared to the Gompertz model. The optimization algorithms applied in the Gompertz model allow estimating the parameters in a considerably fast time (t < 1.6 s). On the other hand, the ANN model requires a longer calculation time (t < 269 s), due to the fitting of coefficients during the learning process.

In prediction, the inverse ANN model has a better precision when compared with the real data. However, the inverse ANN model requires more procedures to predict than the Gompertz model. Figures 7 and 8 show a projection of the cumulative number of deaths by the end of the year 2020 by the inverse ANN and Gompertz models, respectively. The inverse ANN model predicts a total cumulative death of 109,724 and the Gompertz model a total of 100,482 by the end of 2020.

Fig. 7
figure 7

Application of the inverse ANN model to predict cumulative number of deaths by COVID-19 from November 1st to December 31st

Fig. 8
figure 8

Application of the Gompertz model to predict cumulative number of deaths by COVID-19 from November 1st to December 31st

The approximation of the value predicted by the both models, as in other prediction models, depends on multiple factors, such as population mobility, compliance with sanitary security measures (use of face masks), change in methodology for capturing data by the corresponding authorities, among others. Considering the total cumulative deaths (91,753) reported until October 31st [30], the number predicted by both models compared to the real data is worrying. Therefore, infection prevention and control measures should be strengthened, since these last months of the year in México other infections caused by the influenza and dengue intensify.

5 Conclusions

In this paper, the dynamics of deaths from COVID-19 in Mexico were modeled and predicted by comparing an artificial neural network and a Gompertz model applying different optimization algorithms.

The cumulative deaths from COVID-19 in México were modeled during the period from March 19th to September 30th. The results of both models show a good fit with the real data when obtaining an R2 > 0.999. For the ANN model, three optimization algorithms were applied, using hyperbolic tangent sigmoid transfer function. Based on computational time, the Levenberg–Marquardt algorithm was found to converge in the shortest possible time, but the BFGS quasi-Newton algorithm fits the real data better. The batch gradient descent algorithm resulted with the least fit, as well as requiring more computation time and neurons in the hidden layer. Therefore, this algorithm is not recommended for modeling nonlinear data such as cumulative deaths from COVID-19. For the Gompertz model, three optimization algorithms were applied to minimize nonlinear sum of squares. The Nelder–Mead simplex algorithm demonstrated to converge in the shortest possible time, followed by nonlinear regression and finally the curve fitting. Based on this factor, the Nelder–Mead simplex algorithm is recommended to search for parameters using the least squares method.

In the prediction, the same period of the modeling was applied including the data reported in the month of October in order to have the most recent projection. The inverse ANN model turned out to have a better prediction compared to the Gompertz model. However, to propose the prediction of the inverse ANN model, it is necessary to develop an objective function and couple an algorithm to obtain the resolution.

Comparing both models, it is summarized that they satisfactorily achieve the function of simulating the nonlinear behavior, obtaining various fits according to the applied optimization algorithm. However, it is important to mention that the Gompertz model simulates the dynamics of deaths from COVID-19 using three parameters compared to the ANN model that uses ten coefficients. Based on the mathematical origin of each model, it is highlighted that the Gompertz model performs a projection through the reparameterization of a differential equation designed to estimate the cumulative growth of a specific behavior, unlike the inverse ANN model, which predicts from the acquired learning of the real data.

Finally, it was demonstrated that the inverse ANN and Gompertz model coupled with an efficient optimization algorithm predict the cumulative number of deaths with an acceptable precision in a period of 15 days. In a practical physical sense, both models could be programmed and applied to determine, through the prediction of cases or deaths from COVID-19, the possible change in color of the epidemiological traffic light that is reported in Mexico (every 15 days), supporting the health sector in delimiting the presence of the population in socioeconomic activities in the country.