Quantifying Urban Dynamics: An Investigation of Employment Mobility, Spatial Proximity, and Residential Attractiveness in Moroccan Small Cities Applying Data Science Methods

The primary objective of this study is to delve into the intricate interplay between workforce mobility and the spatial proximity to agglomerations, and their collective impact on the residential attractiveness of small cities in Morocco. Initially, we meticulously estimated the net migration rate, a robust and widely acknowledged metric within scholarly discourse, employed to gauge the territorial magnetism. Subsequently, employing this metric as the dependent variable, we embarked on a thorough examination of how the mobility of the workforce and territorial proximity to agglomerations synergistically shape the attractiveness of small cities. The assessment of the net migration rate unearthed a pattern of dispersion, a phenomenon that catalyzed our adoption of quantile regression modeling. Therefore, our rigorous analysis has unveiled a compelling revelation: the geographical proximity of small cities exerts a pronounced influence on their allure. Specifically, a closer adjacency to agglomeration zones invariably results in an augmented residential attractiveness. Furthermore, our research has discerned a robust correlation between heightened workforce mobility and an amplified migratory interest in small Moroccan cities. These compelling findings challenge the prevailing notion that the residential magnetism of small cities in Morocco hinges solely on their socio-economic profile. Instead, it underscores the profound impact wielded by their spatial disposition and the dynamic movements of the workforce.


INTRODUCCIÓN
Territorial attractiveness is a pivotal focus for stakeholders invested in matters about territories, economics, societal dynamics, and evolving communities due to globalization and delocalization.It involves competition to entice and secure investors, manufacturers, and skilled labour.Territories and their stakeholders need to focus on attracting external resources to enhance their competitiveness.This requires adopting strategies for fortifying territorial appeal.
The residential attractiveness of a territory is its ability to attract inhabitants and revenue.Various economic, social, and spatial factors contribute to a city's appeal.Employment opportunities have the greatest impact on the ability of urban areas, particularly smaller cities, to attract people in Morocco.This paper examines the effects of labour mobility and proximity to major employment centers on the residential attractiveness of small cities in Morocco.
First, we needed a measure to evaluate a city's ability to attract people.The best indicator for this is the net migration rate, used in existing research to measure migration patterns.However, since the High Commission for Planning in Morocco doesn't release migration data, we estimated the net migration rate for each small city in Morocco.This enabled us to draw meaningful conclusions using appropriate statistical models.

Target population, definition of small city
The term "small city" does not have a universal definition.Similarly, due to the diversity of territories and urban areas, it is impossible to create a single typology for urban spaces.
Small's city heterogeneous category in terms of number of inhabitants has never yet found a consensus. (1)oreover, the role of small and medium-sized cities varies according to different criteria, such as accessibility or service provision which does not allow them to be represented as a homogeneous group.Given their diversity, public policies for these cities are not very well developed, especially in a context that values the metropolitan fact.
In most cases, the approach used to describe this type of urban formation is based on several criteria, such as the administrative criterion, the functional criterion, and the morpho-statistical criterion.
For this article, the morpho-statistical criterion will be the basis for the definition of a small city.The High Commission for Planning of Morocco specifies that an urban area is considered to be a small city if it falls within the category with a threshold of between 1000 and 50,000 residents.According to this criterion, the urban framework of Morocco includes exactly 292 small cities, According to the most recent Census of Population and Habitat, conducted in 2014. (2)

List of variables
The phenomenon of attractiveness depends on several factors: social, economic, and geographical. (3)As mentioned before, the objective of this paper is to test the causality between the mobility of working population and spatial proximity on the capacity of small cities to attract new migratory flows.On the other hand, we seek to discover whether the attractiveness of a small city is linked to the socio-economic framework it provides, or whether its capacity to attract is also conditioned by other latent phenomena such as labor mobility.
The attractiveness of a territory is theoretically linked to its geographical environment and proximity to employment basins, (4) and for small cities, this fact can have a huge influence on their capacity to polarize and attract people, (2) even though it remains latent and veiled by the other determinants.A small city can appear attractive, not because of the economic and social conditions that it guarantees, but simply because it is considered to be the place of residence of a demographic group that has a significant impact on the migration phenomenon, namely the active occupied population.Of course, a worker, even if he lives in a given territory, Data and Metadata.2023; 2:167 2 can choose to work outside his home area.The area of residence is considered attractive for this worker, but his choice is probably only based on factors of proximity and the job offer provided by his second work territory.
To investigate this matter several indicators related to migration, employment, worker mobility and territorial proximity were used.The table below contains the variables used in this article and their respective descriptions.

Data sources and tools
Several statistical and geographical tools have been used.Regarding statistical manipulation and econometrics modeling,all figures and outputs have been the authors' own production under R language.The manipulation and treatement of geographical data was the authors' own production under arcGIS softward.The analysis of varaince was the authors' production with Orange software.
All data except the estimate of the net migration rate were provided from official publications of the High Commission for Planning.This paper relies in particular on two different exhaustive surveys conducted in 2004 and 2014 by the High Commission on Planning (HCP) in Morocco.The General Population and Housing Census (RGPH) of 2004 and 2014 provides data on births, deaths, fertility rates, the proportion of the population in employment, etc.

Quantile regression theoretical framework
Modeling by the average is an approach often criticized. (5,6)Although the average is essential to provide information on the phenomena studied, this approach remains very limited.Indeed, the study of the average of the net migration rate does not provide information on the unequal distribution of migration flows between cities.Moreover, modeling by the average has a technical limit, since it is difficult to follow this approach in the presence of extreme or outlying values, to which the average is more sensitive than the quantiles. (7,8)Indeed, when the distribution of the response variable is very spread out, which is our case in the modeling of the net migration rate, the average can vary excessively depending on the sample taken into consideration. (9)or the reasons given above, quantile regression is considered a practical technique to address the limitations of average modeling.It provides a more accurate description of the distribution of a response variable conditional on its determinants.
The purpose of quantile regression is to evaluate how the conditional quantiles q_t (Y│X) gets modified when the independent variables, X = (1, X 1 , …X p )'in the model vary.
The formula for conditional quantiles is given below: qt (YIX)=inf(y: Each independent variable X k has its own behavior according to each quantile.In the usual and standard quantile regression it is assumed that the quantiles of the conditional distribution have a linear form.So they can be written in the following form (10)  qt (YIX)=X'βt (2)   Each τ has an own vector of coefficients: β_τ=(1,β_(1,τ),…β_kτ)' (3) The model can be written in the following analytical form: Y=X^' β_τ+ε_τ with qτ (ετIX)=0 (4) Equation ( 4) is close to that of the usual linear regression condition, but there is a fundamental difference, in quantile regression, the coefficients can change as the quantile.

Estimation and Mapping
The net migration rate is considered to be the most relevant indicator for measuring the territorial dynamics of migration,this indicator is also the most widely used proxy for measuring the residential attractiveness of territories.Given that the High Commission for Planning in Morocco does not publish its own data on migration, estimating this aggregate seems necessary.
Therefore, we first estimate the net migration rate as the difference between the total population growth and the natural balance rate.The natural balance rate is measured as the excess of births to deaths in a city and is derived from fertility and child mortality data between the last two censuses of 2004 and 2014.
The estimation equation can be defined as: Net Migration Rate i =Overall Growth Rate i -Natural Growth Rate i (5) For each city i such as i= {1, 2…292}.Natural Growth Rate i =Rate Births i -Rate Deaths i (6) Where i refers to city such as i= {1, 2…292}.
Cartography is one of the privileged tools in geography for analysis and popularization of space data.It is commonly used to better visualize, analyze, and understand space, territories, and landscapes.
Hence, this sub-section will be consecrated to the spatialization of two main indicators that provide information on the residential attractiveness of small cities and worker mobility, respectively.
Firstly, we will realize the mapping of the estimated net migration rate, Secondly, we will also realize the Mapping of worker mobility, estimated by the share of workers residing in the small city and working outside of it.The figure above shows that the attractiveness of small cities is linked to their spatial location; in fact, proximity to the coast or to an agglomeration has a significant positive impact on the net migration rate per city.This observation makes spatial proximity, especially to an agglomeration, a justifiable factor to study its influence on the attractiveness of small cities in Morocco.
Data and Metadata.2023; 2:167 4 Morocco's small cities can be categorized into two axes: the coast and the interior.The coast has become a highly concentrated urban area, with the most dynamic small cities situated nearby.On the other hand, moderately dynamic cities are located in the interior.Unfortunately, most small cities experience demographic decline due to their relative isolation from large agglomerations or their lack of economic dynamism.However, these small cities represent an opportunity for strengthening the national urban framework, particularly because of their location in sensitive areas such as border and oasis areas, and rural production areas.
Agglomerations play an important role in attracting small cities. 80 of them are located in the first ring (30 minutes away or less from the agglomerations), 100 in the second ring (between 30 and 60 minutes away), and 112 outside the area of influence (more than 60 minutes).
Between 2004 and 2014, small cities located in the first ring recorded the highest average annual growth rate reaching 4 %.Those of the second ring is significantly lower, at 2,6 %.Cities outside the zone of influence of the agglomerations, i.e. those further away than 60 minutes, have an average growth rate of only 2,2 %.
After mapping the net migration rate, we will do the same for the share of employees working outside the city.It will help us to better visualize labor mobility and make the right conclusions based on the spatial interaction of labor mobility and the small city's spatial proximity to an agglomeration.The two maps above show that external employment mobility tends to follow the same pattern and spread as the net migration rate.This observation leads us to suspect a causal link between the residential attractiveness of small cities, the geographical positioning, and the mobility of their workers.However, these conclusions are only based on observations, and we will need to verify them statistically.

Primly statistical analysis
As can be seen in the table and figure below, the net migration rate is characterized by a fairly wide distribution and contains many outliers.The net migration rate is significantly positively correlated with the rate of employment (0,43***) and the rate of employed persons working outside the city (0,42***).This finding highlights that migration flows progress in the same direction as the rate of employment and the high mobility of employed persons.The more attractive a city, the more likely it is that there will be a high rate of employment and strong out-mobility rates.In this subsection, we will perform an analysis of variance (ANOVA) to test whether or not a city's net migration rate interacts with its distance from an agglomeration (the nearest one).
The hypotheses (ANOVA) H 0 : The null hypothesis states that: all averages of the net migration rate for each agglomeration distance are equal.
H 1 : The alternative hypothesis states that: There is at least one agglomeration distance whose average net migration rate is different from the others.As can be seen in the table upper, P_value<0,001, which means that the null hypothesis is rejected.The average net migration rate changes according to the distance between the city and the nearest agglomeration.Furthermore the figure below demostrate that the average of classes in terms of net migration rate increases as the proximity to an agglomeration.In addition, cities in the first ring with a distance of less than 30 minutes from a metropolitan area are by far more attractive than other cities.Thus, we can argue that a city is more likely to be more attractive residentially when it is geographically closer to an agglomeration.

Result of quantile regression analysis
A quantile regression model was designed to capture the interaction of the chosen explanatory variables with the residential attraction phenomenon of small cities, which is characterized by high variability and dispersion.
The quantile regression coefficients can change according to the quantile, this characteristic makes it possible to capture the change in the behavior of the explanatory variables with regards to the different levels of the net migration rate.
Regarding spatial dimension, the coefficients of the distance variable from a city showed that cities in the second ring (between 30 min and 60 min) of agglomerations still have a slightly positive influence on their attractiveness.This effect is quite interesting in the sense that it confirms the descriptive and ANOVA results analyzed earlier in the sense that, even at a small scale, agglomerations still exert their influence on the small cities of the second ring.
Worker mobility is the most interactive variable with the city's residential attractiveness.Indeed, the contribution of mobility shows a positive sharp upward trend with the evolution of the ability of the city to attract people.This phenomenon proves that the attractiveness of small Moroccan cities is conditioned by the mobility of workers, and this factor weighs even more heavily when the city is more attractive.This evidence proves that the most attractive small Moroccan cities are marked by the high external mobility of workers. in other words, these cities are undoubtedly under the influence of the proximity of the employment basin, making a large proportion of their workforce related to the jobs generated by other neighboring territorial entities.

DISCUSSION
Our results show that the temporal proximity of a small city to an agglomeration and the high external mobility of its workers are evenly correlated.In other words, the most attractive cities, compared to the least attractive ones, are in fact those that are closest to an agglomeration and at the same time those that are characterized by a higher proportion of resident workers who work outside its spatial borders. (11)This duality between the spatial proximity of the small city and the high external mobility of the workforce clearly shows that the attractiveness of small cities in Morocco is masked by latent effects other than the socioeconomic framework that they provide.As a result, the spatial dimension has a rather strong impact on the migration dynamics of the small urban areas in Morocco.
These results confirm that job proximity is a major factor in where households choose to live in small cities.They supplement qualitative research based on perception questionnaires.
In a qualitative study conducted by Edouard (17) the latter confirms that the proximity of employment, Data and Metadata.2023; 2:167 8 although not considered as an attribute of quality of life or well-being, is strongly involved in the orientation of managers' location choices.Indeed, the quality of life in certain locations is determined by the set of basic economic components, including the proximity of employment and the quality of the necessary facilities, like roads and highways, (3) to ensure everyday mobility between residence and workplace.In this regard, we would like to highlight that our results take into account the quality of transport facilities in the sense that the spatial proximity considered in this work is expressed in time, which is different from spatial distance in kilometers.
Living close to employment areas, particularly in metropolitan areas, is emphasized in studies on housing patterns.Households go through two stages of choosing a place to live.Firstly, they choose an area at a reasonable distance from their work.Secondly, they refine their choice according to subjective preferences.The final decision on where to live is a combination of proximity to employment and subjective factors, especially in small cities. (13,14) Moroccan cities' attractiveness is based on their location relative to densely populated areas and access to employment.Small cities' migration patterns depend on infrastructure availability, such as good-quality roads, highways, and railways.The map of the most appealing small cities in Morocco follows the main communication networks, such as highways.
Several government studies, such as the study on the competitiveness of small cities in Morocco, have underlined that the accessibility of communication networks plays an indispensable role in promoting the attractiveness of small cities in Morocco. (2)It was during the colonial period that communication networks, in particular roads and railways, were imposed as the historical heritage skeleton of the urban framework.Since then, although the road network has developed with a network of highways and the multiplication of national, provincial, and secondary roads, in reality, the first skeleton is still in major play, without the new axes gaining in importance.In particular, building highways has affected negatively all the small cities that have not been connected to them, (15,16) in this same trend, the creation of a dignified basic infrastructure supports the emergence of other aspects of territorial attractiveness, such as the tourisme attraction. (14)In fact, the highway in Morocco favors the big cities and penalizes the small ones that used to benefit from the passage.The same applies to airports, which are often located outside large cities and have no proper connection with the surrounding area.
Cities follow a universal spatial logic.Large and small cities distribution is determined by geography, history, and economy, and tends to develop along a valley or major communication route like rail or road, (11) this is known as the linear urban framework, this form of urbanization differs from circular arrangements, giving rise to a series of small, more or less autonomous bodies and cities that spread out, forming a street of towns. (17)mall cities' development is influenced by multiple factors, including historical, administrative, natural, and functional determinants.Though historical heritage fades over time, the other determinants shape cities and territories more permanently.The combined effects of natural and functional determinants have significantly shaped the Moroccan territory, especially the urban framework.
In terms of development, natural factors like relief, water, soil resources, and proximity to the coastline or agglomeration are potential factors that can be exploited by territorial managers.However, these factors can lead to the concentration of populations and activities in certain areas, leading to negative impacts on disadvantaged territories.Public authorities must intervene to ensure spatial equity.In Morocco, coastal and agglomerated areas have had the largest human concentrations historically, and urbanization policy has prioritized the development of large and medium-sized cities in these areas.Unfortunately, this has led to neglect of smaller cities and rural areas in the interior.
Small cities in Morocco have not received enough support to fulfill their potential roles as centers for local services and activities.To address this issue, a coordinated strategy for their development should be implemented, which includes strengthening their human and material capacities to improve their attractiveness and competitiveness.Development actors should work together at national, regional, and local levels to achieve this objective.

CONCLUSIONS
This article found that the attractiveness of small cities in Morocco is influenced by their location and accessibility for the workforce.Small cities can be appealing for workers who choose to live there while working elsewhere, especially if they are located near larger urban centers.Thus, the attractiveness of small cities is not solely due to their economic and social environment.Small cities in Morocco need attention to preserve socio-economic balance.Local authorities must develop policies to promote and integrate small cities and prevent them from becoming dormitory areas.

Figure 1 .
Figure 1.Net Migration Rate per City

Figure 2 .
Figure 2. Proportion of Employed persons working outside per City

Table 1 .
List of variables