Minimizing Dependency Ratio in Spain through Demographic Variables

: The population pyramids in Europe have changed in the last decades, particularly in Spain, where population aging is observed and implies an increase in the dependency ratio. The present study aims to modify a mathematical model of population deﬁned by age and sex based on the von Foerster-Mckendrick equations in order to have birth and migration rates as control variables. To achieve this objective, the necessary mathematical changes are made in the model, and the new mathematical model is veriﬁed and validated for the case of Spain, in the period 2008–2019, being considered successful both in its deterministic and stochastic formulation. Finally, through the method of strategies and scenarios and a genetic algorithm, a modiﬁcation of the population pyramid is obtained in the direction of a decrease in the dependency ratio, increasing the birth rate and immigration and decreasing the emigration rate. These changes lead to a modiﬁcation of the population pyramid in the year 2040; in particular, an increase of the female population in the age range from 20 to 39 years old.


Introduction
The decline in the birth rate and the increase in longevity are facts in the developed countries and growing trends in the developing countries. The implications of these facts on future well-being are fundamental; in particular, the impact on the population pyramid. The age structure of these countries' population is changing, showing a growth in the number of elderly people and a declining number of young people.
The dependency ratio is an important indicator of age structures. It is defined as the ratio of dependents (people younger than 15 or older than 64) to the working-age population (those aged  [1]. This ratio indicates whether working-age people are able to support the youth and the elderly of the considered population. It is obvious that a low dependency ratio is desirable. Nevertheless, according to the studies on EU-28 [2] the proportion of working-age people is decreasing, while the relative number of retired people is increasing. In the case of Spain (Figure 1), this evolution has been a clear combination of logistic trends, with a decreasing trend from 1975 to 2005. This period coincides with the growth of children born during the "baby boom" (1958)(1959)(1960)(1961)(1962)(1963)(1964)(1965)(1966)(1967)(1968)(1969)(1970)(1971)(1972)(1973)(1974)(1975)(1976), as well as with the migratory movement that occurred between approximately 2000 and 2007. However, since 2006, this trend has been reversed, leading to a dependency ratio of 52% by 2020. The question that this paper seeks to answer is what steps need to be followed to change the trend of the dependency ratio? Before starting with the mechanisms to modify the dependency ratio, it should be noted that changes in the age structures of population are shaping the development trajectories of many countries, as the aging of population has negative impacts on the economy [3]. On the other hand, to drive a 1% increase in the working-age population implies a 1.6% increase in gross domestic product per capita (GDP) [4].
Demographers warn that this is due to a decrease in births [5,6], but it is not only this demographic phenomenon that affects this increase in the dependency ratio.
Migration control is the most powerful tool. It is one of the most controversial political topics in industrialized countries. One important aspect to consider is its effect over the population aging and, consequently, over the dependency ratio. The Department of Economic and Social Affairs of UN warns that only a fifteen per cent of the Governments control their current immigration to address their population aging, and only a thirteen per cent of them deal with the long-term population decline problem [2]. Simon et al. [3] conclude that a way to control the dependency ratio is to step up immigration.
Underlying these facts, a problem arises: what would be the appropriate birth and migration happening for a society such that, within a reasonable period, its dependency ratio changes its trend?
A similar question to the one posed here is asked in a United Nations study [7], in which the authors determine whether migration of a country can be used to hinder the aging of its population. They refer to this as replacement migration. They examine the situation of eight industrialized countries during the time period from 1995 to 2040.
While the UN study cited above only considered age as a relevant human characteristic, the simulation model presented in this paper also considers the difference between gender, because the gender per age is important in terms of gender equality. In this work, birth rate and emigration control are considered important as well [5,6] and they are included in the model unlike other works [2, 7,8].
The aim of this work is to adapt the demographic model presented by Micó et al. [9] to solve the described problem. This latest work is based on the von Foerster-McKendrick model, which is widely used for the analysis of age-structured populations and is applied to predict population dynamics per sex and age of a generic human population [10].
The remainder of this work is organized as follows: the model modifications are presented in Section 2.1, considering the birth and migration rates as control variables, which obligates to change some model parts. In Sections 2.2 and 2.3 the software and the adjustment of the model equations to be implemented in the software are given. Results are shown in Section 3 and divided into the model validation, for the case of Spain in its deterministic and stochastic formulations, and the application case, determining the future evolution of the birth and migration rates in Spain in order to decrease the dependency Before starting with the mechanisms to modify the dependency ratio, it should be noted that changes in the age structures of population are shaping the development trajectories of many countries, as the aging of population has negative impacts on the economy [3]. On the other hand, to drive a 1% increase in the working-age population implies a 1.6% increase in gross domestic product per capita (GDP) [4].
Demographers warn that this is due to a decrease in births [5,6], but it is not only this demographic phenomenon that affects this increase in the dependency ratio.
Migration control is the most powerful tool. It is one of the most controversial political topics in industrialized countries. One important aspect to consider is its effect over the population aging and, consequently, over the dependency ratio. The Department of Economic and Social Affairs of UN warns that only a fifteen per cent of the Governments control their current immigration to address their population aging, and only a thirteen per cent of them deal with the long-term population decline problem [2]. Simon et al. [3] conclude that a way to control the dependency ratio is to step up immigration.
Underlying these facts, a problem arises: what would be the appropriate birth and migration happening for a society such that, within a reasonable period, its dependency ratio changes its trend?
A similar question to the one posed here is asked in a United Nations study [7], in which the authors determine whether migration of a country can be used to hinder the aging of its population. They refer to this as replacement migration. They examine the situation of eight industrialized countries during the time period from 1995 to 2040.
While the UN study cited above only considered age as a relevant human characteristic, the simulation model presented in this paper also considers the difference between gender, because the gender per age is important in terms of gender equality. In this work, birth rate and emigration control are considered important as well [5,6] and they are included in the model unlike other works [2, 7,8].
The aim of this work is to adapt the demographic model presented by Micó et al. [9] to solve the described problem. This latest work is based on the von Foerster-McKendrick model, which is widely used for the analysis of age-structured populations and is applied to predict population dynamics per sex and age of a generic human population [10].
The remainder of this work is organized as follows: the model modifications are presented in Section 2.1, considering the birth and migration rates as control variables, which obligates to change some model parts. In Sections 2.2 and 2.3 the software and the adjustment of the model equations to be implemented in the software are given. Results are shown in Section 3 and divided into the model validation, for the case of Spain in its deterministic and stochastic formulations, and the application case, determining the future evolution of the birth and migration rates in Spain in order to decrease the dependency ratio. Finally, Section 4 discusses the obtained results and indicates some points of future work.

Demographic Model
The starting model [9], written in its continuous form, is constituted by the following equations: where, i = 1 represents men and i = 2 represents women. Equation (1) is a von Foerster-McKendrick equation that determines the dynamics of population density depending on time and age, w i (t, x), where d i (x), f i (x), and g i (x) represent respectively the death, immigration, and emigration rates, respectively, as a function of age. Furthermore, grde i (t, x), gryn i (t, x), and grem i (t, x) are, respectively, the growth rates for each previous demographic phenomena, as functions of age and time.
Equation (2) represents the boundary condition, that is, births at x = 0. In this equation, is the proportion of men or women born (according to i = 1 or 2, respectively), that is, births per sex b i (t)) divided by the total number of births (b 1 (t) + b 2 (t)); birt(t) is the birth rate, i.e., the total numbers of births (b 1 (t) + b 2 (t)) divided by the total population; and b i (x) is the ratio between the fertility rate and births. Equation (3) is the initial condition, that is, the initial population density u i (x) at t = t 0 . Some simplifying hypotheses are made in Equations (1) and (2) (similar to those made by Schmertmann [8]) to introduce the death, emigration, and immigration rates temporarily defined. Thus, the modifications introduced in the model are the following: In these equations, popt(t) represents the total population, and the proportions of deaths, immigration, or emigration for men or women, ( e 1 (t)+e 2 (t) , respectively) (according to i = 1 or 2, respectively) are considered, that is, deaths, immigration, and emigration per sex (d i (t), y i (t), and e i (t)) divided by the total number of deaths, immigration or emigration. Finally, d i (x), f i (x), and g i (x) are the ratios between the different demographic rates (functions of age) and deaths, immigration, and emigration, respectively, in t = 0. Note that, popt(t) can be calculated by the model as: Mathematics 2022, 10, 1471

of 15
With these considerations on the initial model, the following equations are obtained:

Research Data
As this work deals with a demographic model, an international demographic database is used. The information is obtained from the Eurostat [11]. Given that the model is going to be applied to the case of Spain, the available information at the moment is in the 2007-2019 period.
, , With these considerations on the initial model, the following equations are obtained: , 0 , , , ,

Research Data
As this work deals with a demographic model, an international demographic database is used. The information is obtained from the Eurostat [11]. Given that the model is going to be applied to the case of Spain, the available information at the moment is in the 2007-2019 period.
Equations (8)- (10) have been represented in a Forrester's Diagram [12], given in Fig   The model has been written as a set of differential and functional equations, and the solutions have been calculated with the Euler Method following Djidjeli et al. [13] and Letellier et al. [14], which explained that the Euler Method is more adequate to solve such equations. In the case of the integral in Equation (9), it is calculated through the Simpson Composite Rule.
The input variables must be fitted to apply the model in a real case. For this reason, birth, death, emigration, and immigration rates per time are fitted to the data of the 2007-2019 period (in the case of Spain the only available data [11]). Canh [15] presented the relation between demographic rates and time. He determined a cyclical trend that can be formulated as a combination of logistics, as demonstrated by Marchetti et al. [16]. These mathematical structures, given by Equation (11), specifically the coefficients a 0 , a 1 , and a 2 for demographic rates have been found by a trial-and-error process and with a specific software, Regint, which is a function search engine [17,18].
Moreover, in Equation (9) The function considered to fit the variables is a linear combination of Gaussians with positive parameters, as given in Equation (12).
Note that the adjustment is considered if four conditions are met: the overlap of the real and simulated values is good, a determination coefficient higher than 0.8, a randomness of the residuals is found, and the data normality is verified with the Kolmogorov-Smirnov test.
Finally, population structured by age is wrong in the database used [11]. In the work presented by Sanz [19], it is observed that there are errors in the validation trials being performed that can be corrected if a population structured by age is built from the other existing data presented in the same databases used. Concretely, the populations structured by age that [11] provide us differ greatly from the corresponding populations calculated from births, deaths, and historical migrations (structured by age) also provided by [11]. For this reason, in the present work, the population structured by age has been calculated previously as Sanz [19]. Two steps are followed to calculate the populations in the different years: (1) the initial population of reference is taken as that of the beginning of the period, in our case, the population of the year 2007 (Equation (13)); and (2) the population in year t and cohort x are calculated as follows in Equations (14) and (15), Note that detail about the needed demographic variables in the model, which are searched in databases is shown in Table A1 in Appendix A.

Instruments
This research included two goals: (a) validating the presented model and (b) optimizing the results of a simulation. These goals require different software tools and methodologies. For this reason, three subsections are included.

Verification and Validation of the Model
The software used for validation was SIGEM [17,18]. The model is adapted to this tool, then it has been written as a set of differential and functional equations as stated before and it has been programmed in Visual Basic 6.0 using SIGEM.
Synthetically, verification consists in testing for errors and validation consists in testing for suitability. Good reproduction of the past values after fitting the model to the same past data is verification of the model. Good reproduction of past data after fitting the model with different past data is commonly used and called "ex post" validation (which is not the only validation method). In the present case, the method used for validation is "revision by experts".
The methodology to validate the model depends on its formulation, which can be deterministic or stochastic. In the first case, the historical and simulated data are graphically overlying. Furthermore, the model has been verified numerically in two ways: calculating the coefficients of determination and testing the randomness of the residuals. In the second case, the real and simulated data are graphically superimposed, but the simulated data consist of a confidence interval of 95% for each outcome, and the real data must be included within this range.

Optimizing with Strategies and Scenarios
The strategies and scenarios methodology requires different phases [20], and for all of them, the model programmed in Visual Basic 6.0 using SIGEM will be required.
The first phase is an analysis of the input variables of the mathematical model, which must be divided into control variables and scenario variables. The control variables can be modified through external instruments, such as an expert or competent organism in the subject to be studied, while scenario variables cannot be modified.
In the present study, there are four input variables, the demographic rates defined temporarily, birth, mortality, immigration, and emigration. Given the characteristics of the model and its objective, to minimize the dependency rate, migration and birth rates are considered as control variables, the death rate maintains its tendency in all cases.
In the second phase the different strategies and scenarios are established. The strategies will be defined by the modification of the control variables and the scenarios by the scenario variables. Note that in this work, there are no scenario variables and, therefore, only strategies will be defined, as shown in Table 1. The changes in the input variables must be smooth, since sudden movements can create chaos in the model. For this reason, increases or decreases at 5% are considered. It should be noted that birth rates must be increased in any case for a change in the population pyramid and reduce the dependency rate [5,6]. Thus, in the four planned strategies, the birth rate will increase by 5%. Regarding the emigration and immigration rates, the strategies are generated according to the existing literature [3,7,8], and all possible combinations are made, not considering in any case maintaining the current trend.  [20] explained, SIGEM has implemented a genetic algorithm. The genetic algorithm allows optimizing, in each time step, an objective variable previously defined from other variables included in the model.
In the application case of this research, the aim is to minimize the dependency ratio. This minimization decreases the pressure on the productive population. It is worth remembering that the dependency ratio is defined as the dependent population divided by the productive population, that is: In Equation (16), x m is the minimum working age, generally x m = 15, and x M the retirement age, generally x M = 65.
The difference between the optimization obtained with the genetic algorithm and the quasi-optimization obtained with the strategies and scenarios method is that the input variables that were determined as control variables are now calculated by the model using the genetic algorithm. This algorithm searches for the optimal combination of control variables to achieve the objective.
Thus, the algorithm implemented in SIGEM requires different values to start its simulation in the future. On the one hand, the control variables are part of a vector, called chromosome (CROM in Table 2), and they are substituted in the model by CROM(i), i = 1 to n, where n is the number of control variables. CROM has an initial value vector, CROI, in which the initial values of the variables defined in the CROM vector are placed. In this work CROI contains the data for the last year for which there are real data for demographic rates, year 2019 [11] (see detail in Table 2).
In addition, Table 2 defines another vector, PCRO, in which the user will mark the minimum and maximum values between which the CROM variables can take a value (in the opinion of the experts). Also, a 95% confidence interval is defined in each iteration. After implementing the model in its formulation for the genetic algorithm, the SIGEM computer tool requires the user to provide six pieces of information: the number of individuals in the algorithm's population, the percentage of reproducers, the number of immigrants in each algorithm's generation, the rate of mutants, the number of algorithm's generations, and the number of iterations of the algorithm. Details of how the algorithm works can be found in the study of Caselles et al. [20].

Model Verification
The verification process is considered successful in both formulations, deterministic and stochastic. We show the dependency ratio and the total population in the 2008-2019 period. These variables present very high determination coefficients, R 2 , and the maximum relative error does not exceed 4.59% in any case (Figures 3a and 4a). In the case of the stochastic validation (Figures 3b and 4b), all the real data are within the 99% generated confidence interval. The real data and minimum and maximum simulated values are given in Table A2 of Appendix A. confidence interval. The real data and minimum and maximum simulated values are given in Table A2 of Appendix A.   confidence interval. The real data and minimum and maximum simulated values are given in Table A2 of Appendix A.

Application Case
In the application case, the aim is to minimize the dependency ratio, as it is explained in Section 2, and two different methods are applied.

Strategies and Scenarios
For the application case here presented (the case of Spain), the time t runs in the 2020-2040 period. Figure 5 shows that to reduce the dependency ratio, i.e., to get more people in working ages with respect to those in non-working ages, it is necessary to apply Strategy SS4, that is, to modify the trend of the demographic control variables on those terms: increasing the birth and immigration rates and reducing the emigration rate. More details about the stochastic formulation results, with a 99% confidence interval, are shown in Table A3 of Appendix A. (a)

Application Case
In the application case, the aim is to minimize the dependency ratio, as it is explained in Section 2, and two different methods are applied.

Strategies and Scenarios
For the application case here presented (the case of Spain), the time t runs in the 2020-2040 period. Figure 5 shows that to reduce the dependency ratio, i.e., to get more people in working ages with respect to those in non-working ages, it is necessary to apply Strategy SS4, that is, to modify the trend of the demographic control variables on those terms: increasing the birth and immigration rates and reducing the emigration rate. More details about the stochastic formulation results, with a 99% confidence interval, are shown in Table A3 of Appendix A.

Application Case
In the application case, the aim is to minimize the dependency ratio, as it is explai in Section 2, and two different methods are applied.

Strategies and Scenarios
For the application case here presented (the case of Spain), the time t runs in the 20 2040 period. Figure 5 shows that to reduce the dependency ratio, i.e., to get more people in wo ing ages with respect to those in non-working ages, it is necessary to apply Strategy S that is, to modify the trend of the demographic control variables on those terms: increas the birth and immigration rates and reducing the emigration rate. More details about stochastic formulation results, with a 99% confidence interval, are shown in Table A Appendix A. (a)

Genetic Algorithm
With the genetic algorithm, for the case of Spain, it can be observed that by the year 2040 a dependency ratio close to 0.6188 is achieved (Figure 6a), which is what we expected to determine. The strategy to be applied in the rates of population: (Figure 6b-d), an increase (0.02%) in emigration, in immigration (0.46%), and in the birth rate (0.11%).

Genetic Algorithm
With the genetic algorithm, for the case of Spain, it can be observed that by the year 2040 a dependency ratio close to 0.6188 is achieved (Figure 6a), which is what we expected to determine. The strategy to be applied in the rates of population: (Figure 6b-d), an increase (0.02%) in emigration, in immigration (0.46%), and in the birth rate (0.11%).

Genetic Algorithm
With the genetic algorithm, for the case of Spain, it can be observed that by the year 2040 a dependency ratio close to 0.6188 is achieved (Figure 6a), which is what we expected to determine. The strategy to be applied in the rates of population: (Figure 6b-d), an increase (0.02%) in emigration, in immigration (0.46%), and in the birth rate (0.11%).

Discussion and Final Remarks
There is no doubt that European population pyramids have changed, particularly in the case of Spain, which is among the longest-lived and oldest countries in the EU [21] with an age dependency ratio around 53%. In Spain, the scenario is not expected to improve according to projections to 2040 by INE (70%), AIReF (80%), and Eurostat (75%) [21], which raises widespread fears about the negative economic and fiscal consequences of this demographic trend. As a consequence, migration and efforts to increase fertility have been raised as possible policies to counteract population aging.
This paper shows how changes in these two directions are possible, contrary to what some papers claim [2, 7,8], thus improving the dependency ratio, since the forecast for the year 2040 [21] ranges between 70% and 80%, and those obtained in the present work range between 58% and 60% in the case of strategies and scenarios, and between 61% and 63% in the case of the genetic algorithm. Figure 7 shows the change in the population pyramid for the case of Spain in the year 2040. Figure 7a,b show a similar change in the population pyramid, although Figure 7b shows a smooth change produced by the strategy and scenario technique, in which the experts have determined the increase or decrease of the variables that must be modified to reach the objective. This pyramid is the result of a 5% increase in the birth rate starting in 2019, following [5,6], as well as a change in migratory movements [3,7,8], in particular, a 5% increase in immigration and a 5% reduction in emigration, always following the trend in 2019. Thus, there is a significant increase in both men and women in the age range of 15 to 39 years. However, the genetic algorithm method modifies the population pyramid (Figure 7c), since the increase in population is greater in all age cohorts. It should be noted in both cases (Figure 7b,c) a significant reduction in the male population and the difference in the female population. Thus, what is observed, mainly, with the threshold year 2040, is an increase in the female population in the age range 20 to 39 years.

Discussion and Final Remarks
There is no doubt that European population pyramids have changed, particularly in the case of Spain, which is among the longest-lived and oldest countries in the EU [21] with an age dependency ratio around 53%. In Spain, the scenario is not expected to improve according to projections to 2040 by INE (70%), AIReF (80%), and Eurostat (75%) [21], which raises widespread fears about the negative economic and fiscal consequences of this demographic trend. As a consequence, migration and efforts to increase fertility have been raised as possible policies to counteract population aging.
This paper shows how changes in these two directions are possible, contrary to what some papers claim [2,7,8], thus improving the dependency ratio, since the forecast for the year 2040 [21] ranges between 70% and 80%, and those obtained in the present work range between 58% and 60% in the case of strategies and scenarios, and between 61% and 63% in the case of the genetic algorithm. Figure 7 shows the change in the population pyramid for the case of Spain in the year 2040. Figure 7a,b show a similar change in the population pyramid, although Figure 7b shows a smooth change produced by the strategy and scenario technique, in which the experts have determined the increase or decrease of the variables that must be modified to reach the objective. This pyramid is the result of a 5% increase in the birth rate starting in 2019, following [5,6], as well as a change in migratory movements [3,7,8], in particular, a 5% increase in immigration and a 5% reduction in emigration, always following the trend in 2019. Thus, there is a significant increase in both men and women in the age range of 15 to 39 years. However, the genetic algorithm method modifies the population pyramid (Figure 7c), since the increase in population is greater in all age cohorts. It should be noted in both cases (Figure 7b,c) a significant reduction in the male population and the difference in the female population. Thus, what is observed, mainly, with the threshold year 2040, is an increase in the female population in the age range 20 to 39 years.
Regarding the policies that determine both pyramids, they are based on an incentive to the birth rate through fiscal measures, housing, and reconciliation of work and family life [5,6] and policies that encourage migratory movement. In this second aspect, Marois et al. [22] stated that the educational level of migrants is what favors change, as well as an increase in the country's economy. In this direction, the mathematic model presented can be modified in future works, in which the educational level per age of emigrants and immigrants can be included. Finally, it should be noted that this increase in the population aged between 20 and 39 years, approximately, with both techniques, implies that the real change in the population will be observed in the years 2060 to 2070, when the births produced by these women will be the real reflection of the change. Although there is no significant increase in the fertility rate, there will be a real increase in births, since there will be an increase in Regarding the policies that determine both pyramids, they are based on an incentive to the birth rate through fiscal measures, housing, and reconciliation of work and family life [5,6] and policies that encourage migratory movement. In this second aspect, Marois et al. [22] stated that the educational level of migrants is what favors change, as well as an increase in the country's economy. In this direction, the mathematic model presented can be modified in future works, in which the educational level per age of emigrants and immigrants can be included.
Finally, it should be noted that this increase in the population aged between 20 and 39 years, approximately, with both techniques, implies that the real change in the population will be observed in the years 2060 to 2070, when the births produced by these women will be the real reflection of the change. Although there is no significant increase in the fertility rate, there will be a real increase in births, since there will be an increase in the number of women of fertile age. In addition, given that the educational stage has been extended by dedicating more years to study [23], a margin of at least 20 years should be given for women aged 20 years to finish their formative stage. This implies that the instrument used to make the projections would have a higher robustness than the one used in the present study, and, therefore, for future work, the possibility of improving the instrument will be studied.