1 Introduction

In urban areas, crime is a determinant factor affecting the quality of life. Crime may be more prevalent in cities because of the social, economic, and spatial configuration of urban areas (Malathi & Baboo, 2011). Higher crime levels are also associated with disruptions in social and economic development in cities and countries (Bogomolov et al., 2014). Additionally, the level of safety in any zone may influence the behavior of individuals. For instance, decreased security influences people’s decisions to move to another neighborhood or avoid certain areas of a city (ToppiReddy et al., 2018).

Some negative human conditions (Núñez et al., 2003 and Bogomolov et al., 2014), such as depravity or mental illness (Entorf & Spengler, 2000), can predispose people to commit illegal activities. Crime may also result from a cost–benefit assessment of decisions to commit criminal offences. Seeking to maximize utility and minimize uncertainty, individuals weigh the monetary benefits of these offences against the potential risks and punishments (years in prison, conflicts between criminals, etc.) (Allen, 1996 and Núñez et al., 2003). The spatial perspective is another important factor when assessing crime. For instance, Xiao et al. (2018) analyzed patterns of distance decay of criminals’ decisions to commit robbery in a specific location. Within the context previously mentioned, the present research assesses the impact of socioeconomic indicators on crime and identifies the spatial and temporal patterns of urban crime.

Environmental criminology addresses the spatial distribution of crime (Bruinsma & Johnson, 2018) based on the assumption that spatial distribution of crime in a city is not random (Anselin et al., 2000; Block & Block, 1995; Fitzgerald et al., 2004; Kounadi et al., 2020; Ristea et al., 2020). Additionally, it is important to consider the context (e.g., the built environment) in the spatial analysis of crime (Fitzgerald et al., 2004; Kinney et al., 2008; Lama & Rathore, 2017), as reported offences vary from one area to another in response to the interaction of urban context with diverse variables (Kounadi et al., 2020).

Kinney et al. (2008) focus on the “when” and “where” of urban crime, identifying characteristics that could make places attractors, generators, or detractors of crime (Kinney et al., 2008; Ristea et al., 2020). Crime attractors are places in cities with characteristics that provide opportunities for criminals. Crime generators are activity nodes that attract a large number of people, leading to opportunistic crimes. Crime detractors are urban sectors that keep criminals away because they contain few attractions that are conducive to crime (Kinney et al., 2008). As previously mentioned, the built environment is clearly important when analyzing urban crime and its spatial distribution. Fitzgerald et al. (2004) identify places (e.g., hospitals, parks, liquor stores, bars, restaurants) that act as attractors or generators of crime, influencing the movement, behavior, and dynamics of criminal acts. In general, urban zones with bars and nightclubs may experience more criminal activity (Graham et al., 2012; Savard et al., 2019).

Temporal and spatial modeling supports a better understanding of crime as a complex, multidimensional phenomenon. Given that urban problems do not occur randomly in time and space, tools to model and predict crime provide strong empirical evidence of criminal behavior to prevent and counteract crime more effectively (Block & Block, 1995; Braga, 2005; Chainey & Ratcliffe, 2005; Fitzgerald et al., 2004). Grubesic and Mack (2008) mention that spatial–temporal analyses need to be linked to criminological theory and that one important challenge is the possible complexity of the space and time tests of crime. The spatial and temporal patterns of crime may vary depending on the type of crime analyzed (de Melo et al., 2017) or time/space scales (Andresen & Malleson, 2015), and there are several techniques that support the identification of these patterns, such as crime hotspots, crime exposure risks, ARIMA models or seasonal-trend decompositions (Yang et al., 2021).

The different fields of crime analysis (e.g., sociology, psychology, economics) converge to explain the possible causes of crime as a function of socioeconomic indicators such as level of education, ethnicity, income, unemployment, poverty, social exclusion, and wage inequality (Bogomolov et al., 2014; Buonanno & Montolio, 2005). In general, demographic, social, and economic factors can influence urban crime (Ackerman, 1998; Bechdolt, 1975; Bogomolov et al., 2014; Buonanno et al., 2009; Entorf & Spengler, 2000). For instance, population density may have an impact on crime (Battin & Crowl, 2017; Saini & Srivastava, 2019), more education is associated with lower rates of crime (Asante & Bartha, 2022; Boessen et al., 2023), and some criminal events could be a function of unemployment situations (Kapuscinski et al., 1998; Nordin & Almén, 2017).

Although the results are diverse and differ according to the socioeconomic or demographic variables analyzed, these factors undeniably play an important role in understanding urban crime and its varying prevalence in the city. Inequalities related to these factors, such as social marginalization, may make some individuals susceptible to committing illegal activities, triggering crimes in urban areas (Buonanno et al., 2009).

Based on environmental criminology theory, academics and public entities increasingly use crime prediction tools and econometric models for space–time analysis of crime to generate public policy based on empirical information (Ristea et al., 2020). This study adopts an ecology of crime perspective to explore the space–time dynamics of crime using the city of Quito, Ecuador, as a case study. It combines analysis of the influence of socioeconomic indicators on crime with spatial–temporal analysis of crime in the city, including the identification of spatial hotspots of different types of crime and possible variations in these hotspots during the day.

2 Methods

The city of Quito is part of the metropolitan district of Quito (MDQ), has a population of nearly three million, and is the capital city of Ecuador. The MDQ is divided into urban and rural territories known as parishes. The city of Quito included all 32 urban parishes in the MDQ. A parish is the smallest political-administrative spatial unit in Ecuador. Figure 1 shows the study area, which is composed of urban parishes of the MDQ.

Fig. 1
figure 1

Study area

Ecuador’s National Prosecution Office has provided databases of criminal events committed between 2014 and 2020. We examined the databases of 174, 365 criminal events identified in Quito in this timeframe. These criminal events include handgun abuse, sexual abuse, murder, material damage, organized crime, femicide, homicide, larceny, robbery, the sale of illegal drugs, and rape. Additionally, we geolocated bars, night clubs, and police units in the city. We then geographically aggregated the crime events identified at the parish level and classified them temporally in three ways: yearly, monthly, and daily, dividing the daily components into early morning (00:00–05:59), morning (06:00–11:59), afternoon (12:00–17:59), and night (18:00–23:59) periods. At the parish level, we considered the following demographic and socioeconomic indicators as possible factors explaining crime: population density, illiteracy, school attendance, unemployment, schooling, university education, and unsatisfied basic needs. These indicators were chosen based on previous research indicating that education, poverty, inequality, and other social, economic, and demographic factors can influence crime (Asante & Bartha, 2022; Boessen et al., 2023; Bogomolov et al., 2014; Buonanno & Montolio, 2005; Buonanno et al., 2009; Entorf & Spengler, 2000; Nordin & Almén, 2017).

Using these data, we first performed seasonality analyses using time-series decomposition, a seasonality plot, and a heatmap. Second, we calculated robust linear least squares regressions, taking as dependent variables the numbers for each type of crime and total number of crimes, and as independent variables the demographic and socioeconomic indicators, one variable of attraction of crime (density of bars and night clubs), and one variable of detractor of crime (density of police units). As previously mentioned, areas with bars and nightclubs can experience more criminal activity (Graham et al., 2012; Savard et al., 2019). For the regression models, variance inflation factors (VIF) were calculated to assess the multicollinearity of the independent variables. After evaluating multicollinearity, we chose the following independent variables: school attendance, unemployment, schooling, unsatisfied basic needs, density of police units, and density of bars and night clubs.

Third, we applied the Getis-Ord Gi* index to evaluate the spatial dependency of the crime types. The Getis-Ord Gi* statistic is preferred over other spatial autocorrelation metrics for several reasons, including the identification of features showing high levels of the variable of study, even if the value of the specific spatial unit is not different from the global mean (Braithwaite & Li, 2007).

The index was calculated using the following equation:

$$Gi^{*} = \frac{{\mathop \sum \nolimits_{j} w_{ij} x_{j} - \overline{x}W}}{{s\sqrt {\frac{{(n\mathop \sum \nolimits_{j} w_{ij}^{2} - W^{2} }}{n - 1}} }}$$

where \({x}_{i}\) is the value of observation i (location), \(\overline{x}\) is the average of the simple, s is the standard deviation \(w_{ij}\),equals 1 if i and j are neighbors, and W equals \(\mathop \sum \limits_{j} w_{ij}\).

Finally, we applied two models of crime prediction. The first model, the auto-regressive integrated moving average (ARIMA), is useful due to its simplicity and efficiency to capture data patterns for the identification of trends and seasonality. Furthermore, ARIMA model has better performance than other variations of this model, such as f-ARIMA model (Takahashi et al., 2000). ARIMA defines a time series based on time lags and errors of lagged predictions to create an autoregressive equation of a time series defined as follows (Subramaniam & Muthukumar, 2020):

$$y_{t} = c + \emptyset_{1} y_{t - 1} + \emptyset_{2} y_{t - 2} + \ldots + \emptyset_{p} y_{t - p} + \varepsilon_{t}$$

where \(\varepsilon_{t}\) corresponds to white noise, and \(y_{t}\) the lagged values act as predictors. White noise is a stationary time-series or stationary random process with zero autocorrelation. This corresponds to variations in the data that cannot be explained by the regression model (Moffat & Akpan, 2019).

The second applied model, the TBATS (Trigonometric seasonality, Box-Cox transformation, ARMA errors, Trend, and Seasonal components), is useful because it facilitates the inclusion of multiple seasonal components, incorporating nonlinear features present in the time series of real events (De Livera et al., 2011; Skorupa, 2019). Another advantage of TBATS is that it considers multiple nested or non-nested seasonal components to identify non-integer seasonality (De Livera et al., 2011). The TBATS model can be expressed as:

$$y_{t}^{\left( w \right)} = wx_{t - 1} + \varepsilon_{t}$$
$$x_{t} = Fx_{t - 1} + g \varepsilon_{t}$$

where, is a row vector, g is a column vector, F is a matrix, and \(x_{t}\) is the unobserved state vector at time t (De Livera et al., 2011).

3 Results

Table 1 shows the descriptive statistics of the demographic and socioeconomic indicators. There is a very low density of police units, while there is an average of two bars/night clubs per parish, with a high standard deviation. Thus, in one parish, there are 27 bars/night clubs. School attendance is high in the city. However, schooling (finishing the school formation) is very low. In Quito, the indicator unemployment is not high (5.26 ± 0.61). However, 22.81 ± 13.71of the population is living with at least one unsatisfied basic need. This indicates the existence of urban socioeconomic inequality.

Table 1 Descriptive statistics of demographic and socioeconomic indicators

Table 2 shows the statistics for the different types analyzed in this study. There are parishes where there is no handgun abuse, organized crime, or femicide. Sexual abuse is a more recurrent type of crime than is rape abuse. Murder (15.03 ± 10.18) was lower than homicide (28.16 ± 16.11) in the city. There are an average of 100 events per parish of illegal drugs sailing in Quito. The standard deviation of the material damage events indicated that this variable had a high dispersion. There was a parish with more than 3000 material damage events. Larcenies and robberies were the most common types of crime in the study area. Nevertheless, these indicators have highly dispersed values relative to the mean.

Table 2 Descriptive statistics of crime types

The most common types of crime in the study area were homicide, robbery, larceny, material damage, and sale of illegal drugs. Figure 2 depicts these five types of crimes in the study area. Robbery represented more than half (54.49%) of the crimes committed in Quito. The parishes with high rates of criminality are Mariscal Sucre (1329 crime events per 1000 inhabitants), Iñaquito (473 crime events per 1000 inhabitants), and Historical Center (266 crime events per 1000 inhabitants). Crime is generally concentrated in central parishes, which correspond to the city’s downtown and surrounding areas.

Fig. 2
figure 2

Number of events for most common crimes in the study area

Figure 3(a) shows the components of the time series, indicating trends and seasonal components as key aspects. The trend was linear, with a slight decrease in 2020, although it is important to note that the data obtained for 2020 only extended through August. We observe a marked seasonal component of crime, with striking decreases and increases in the number of criminal events. These variations may be caused by public holidays or other social activities, during which people are more mobile. December has a strong seasonal component, with high rates of crime possibly caused by Christmas, New Year’s Eve, and the celebration of the Spanish establishment of the city.

Fig. 3
figure 3

Seasonality of crime (number of events). a Time series decomposition, b Seasonality plot, c Heatmap

Figure 3(b) depicts monthly and yearly seasonality. Each line helps identify the time patterns. The lines for the months are generally stable, but we observe an increase in criminal activity from the last quarter onwards, confirming the strong seasonal component from August to December mentioned above. The lines for the years indicate a decrease in the trend in 2020 because the data analyzed only extend to August.

Examination of the boxplots shows that the dimensions of the boxes were determined by the distance of the interquartile range between the first and third quartiles. The segment (median) that divides the box into two parts indicates whether the sample distribution is symmetrical or asymmetrical or not. If the median is located at the center of the box, the criminal event data are distributed symmetrically. If the upper part of the box is longer, the data will be concentrated in the lower part of the distribution (positive skewness). The mean is usually smaller than the median (negative skewness). The seasonality plot confirmed the presence of a strong seasonal component in the data, both monthly and annually.

Figure 3(c) shows the months and years with the highest concentrations of criminal events. Visualizing the data matrix in this way helps identify the representative variables for each sample cluster and facilitates the identification of underlying changes that produce seasonal patterns. The heatmap enabled us to analyze critical points for the number of criminal events over years and months. The highest crime concentrations were observed in the second half of 2015.

Figure 4 shows the crime patterns throughout the day. Although the general pattern of crime events is the same for the parishes most affected by crime (e.g., Iñaquito and Mariscal Sucre), we also detected small changes in the number of these events within each time period. High-crime events tend to occur in the afternoon, between 12:00 and 17:59, as this period represents 31% of all crime events.

Fig. 4
figure 4

Crime events during the day. a Early morning, b morning, c Afternoon, d Night

Table 3 presents the results of the 12 robust linear least squares regressions. The first column indicates the dependent variables of the regressions (total crime and different types of crime) and coefficients of determination for each regression. The second column specifies the independent variables considered, and the remaining columns show the coefficients, standard errors, and p-values of the independent variables. Schooling and the density of bars and night clubs explain 59% of the variability in the total number of crimes. We found no significant variables that could explain handgun abuse. Unsatisfied basic needs and density of bars and night clubs were highly significant variables influencing sexual abuse and rape. Unemployment and schooling explain material damage at the 90% confidence level. Murder, femicide, and homicide were influenced by unsatisfied basic needs and density of bars and night clubs at 99% of confidence, whereas larceny and robbery were explained by schooling (90% of confidence for larceny and 95% of confidence for robbery) and density of bars and night clubs (99% of confidence). Density of bars and night clubs also explains up to 64% and 42% of variability in organized crime and sale of illegal drugs, respectively.

Table 3 Results of robust linear least squares regressions

Figure 5 depicts the results of the Getis-Ord Gi* calculations for the 11 types of crimes considered. The parish of Mariscal Sucre was shown to be a hotspot for nine types of crime: Itchimbia for eight, Iñaquito for seven, and Belisario Quevedo for five (Fig. 5). Overall, the central area of Quito (which includes the aforementioned parishes) is forming a hotspot for crimes such as sexual abuse, material damage, murder, organized crime, homicide, larceny, robbery, and sale of illegal drugs. This area is downtown and is characterized by a high presence of financial, entertainment, and shopping services. La Ecuatoriana, a southern parish, is a hotspot for suicide. Coldspots for five types of crime (firearm abuse, murder, femicide, homicide, and rape) were also located in the parishes of Cochapamba, Cotocollao, Rumipamba, La Concepción, Kennedy, Jipijapa, and San Isidro del Inca. These parishes are considered to have a higher socioeconomic status than those located south of the city and are highly residential.

Fig. 5
figure 5

Spatial autocorrelation by type of crime (Getis-Ord Gi)

Table 4 shows the ARIMA and TBATS aggregated results since 2020 (September) and projected to 2025. Both methods indicated a general tendency for crime to increase, although TBATS showed higher values. Figure 6 also shows that crime is expected to increase in the coming years.

Table 4 Prediction of criminal events
Fig. 6
figure 6

Tendency of crime (ARIMA and TBATS)

4 Discussion

Urban crime is a multidimensional phenomenon characterized by temporal and spatial variations. We identified seasonality in crime events using three plots of time series, and the obtained results indicated a marked seasonal component of crime with striking decreases and increases in the number of criminal events. These variations are more likely to be caused by public holidays or other social activities during which people are more mobile. For instance, in December, the city commemorates the Spanish establishment of Quito, and this commemoration is known as the longest-running festivity of the city, usually connected with preparations for Christmas. At this festival, the number of people accessing bars and night clubs has markedly increased compared to the rest of the year. Our results align with those of Linning et al. (2016), who found that the number of reported criminal events fluctuated with seasonal changes. The identified seasonal pattern may also depend on the built environment and type of crime (Andresen & Malleson, 2015). Furthermore, criminal acts fluctuate throughout the day. Haberman and Ratcliffe (2015) noted that street robbers attack at specific times. The “objective areas” that criminals target change with the time of the day because victims’ activities also change during the day. In Quito, the afternoon, between 12:00 and 17:59, was identified as the main day time frame when criminal offenses were committed. This pattern corresponds to the time when more people in the city mobilize to access urban services, such as restaurants, or return home.

We identified unemployment, schooling, unsatisfied basic needs, and the density of bars and nightclubs as factors influencing crime in the area studied. Arvanites and Defina (2006) and Hooghe et al. (2010) indicate that higher levels of unemployment create incentives for criminal events, and Hooghe et al. (2010) find that income, inequality, and unemployment are associated with high levels of crime, especially offences against property and violent crime. Our study also identifies an association between unemployment and material damage. Lower income (a consequence of unemployment) generally affects urban crime at different levels and scales (Hooghe et al., 2010; Hipp and Kane, 2017). We also detected significant associations between schooling (years of study) and total number of crimes, material damage, larceny, and robbery. This finding agrees with O’Flaherty and Sethi (2015), who found associations between crime perpetration and education level. However, the regression coefficients for the schooling variable were associated with higher years of study and a higher number of criminal events. This finding may indicate that parishes with populations with more years of study may be parishes with populations with higher income and, consequently, a population that may experience more criminal events. This insight is in line with previous research that found that, whereas wealth has a negative effect on crime in wealthier countries, in poorer countries, the effect is positive (Muroi & Baumann, 2009). The association between years of education and crime is complex. For instance, the probability of committing crime decreases with years of education, but more educated people can have more permissive attitudes towards specific criminal behaviors (Groot & van den Brink, 2010).

Unsatisfied basic needs can influence sexual abuse, rape, murder, femicide, and homicide. The index of unsatisfied basic needs is widely used as a measure of poverty in Latin America. Various studies have found a positive association between deprivation and crime (Edmark, 2005; Hooghe et al., 2010; Hope, 2001; Hope et al., 2001; Tseloni et al., 2002), arguing that inequality and social disorganization severely affect safety in poor neighborhoods and that people in affluent neighborhoods can also afford security measures and devices. Nevertheless, it is important to note that unsatisfied basic needs are not necessarily or always positively related to crime. For instance, Cabrera-Barona et al. (2019) found that unsatisfied basic needs were inversely associated with crime and observed that the most deprived parishes in the Metropolitan District of Quito were those with the least crime. These parishes are more suburban and rural, with a lower population density and lower presence of bars and night clubs. Therefore, these authors also conclude that these parishes discourage criminal offences and argue that poor areas should not be stigmatized automatically in terms of criminal events.

The density of bars and night clubs was the most significant variable for explaining crime in the city. This variable was found to be a significant factor explaining the total number of crimes, sexual abuse, murder, organized crime, femicide, homicide, larceny, robbery, sale of illegal drugs, and rape. This result was consistent with the findings of previous studies. For instance, Graham et al. (2012) identified “hotsposts” of aggressions in different spaces of barrooms, while Savard et al. (2019) found that violent crimes such as murder, are more likely to occur in bars. Bars and clubs have a permissive atmosphere that may contribute to aggressive actions (Graham & Homel, 2008). However, although bars and night clubs increase crime rates, criminal events may decrease depending on the management capacity of the bars´ owners (Lee et al., 2022).

Cabrera-Barona et al. (2019) and Dammert-Guardia and Estrella (2013) found that crime in Quito is concentrated in the city center, a sector with a high number of bars and night clubs. The parishes of Mariscal Sucre and Iñaquito, also identified as hotspots of crime, concentrate on most of the bars and night clubs of the city. These areas facilitated access to alcohol outlets. Ejiogu (2020) suggests that some business establishments can be considered attractors of offenders, such as liquor outlets, where robberies increased by 67%.

The findings of spatial autocorrelations show that seven parishes are hotspots for crime, accounting for 38% of the total crimes. These parishes represent a highly urbanized sector of the city, and the crime clusters obtained exemplify Sherman et al. (1989) argument that specific city locations have the highest concentration of criminality. Hooghe et al. (2010) also demonstrated that crime becomes more complex in urbanized zones. According to Cabrera-Barona et al. (2019), higher levels of crime in Quito correspond to urban zones with high population density, where anonymity may drive delinquency; however, there is no conclusive evidence of the effects of population density on crime (Battin & Crowl, 2017), although in developing countries, population density may lead to higher crime rates (Saini & Srivastava, 2019). Additionally, crime hotspots are located in the central areas of the city in parishes with diverse zones of commercial land use. It has been found that commercial land use is associated with more street crimes (Twinam, 2017).

The results of this study have several important implications. It highlights the significance of socioeconomic and demographic factors influencing crime and integrates perspectives of time and space to show that crime has specific spatial–temporal patterns. The identified hotspots have a strong temporal component that fluctuates by day, month, and time of day, showing that crime varies with variations in people’s daily routines. Despite the importance of these findings, this study encountered a significant challenge in selecting the appropriate unit of analysis. While the national prosecution office defined crime information at the individual level, the information was not geolocated at the individual level. Because, geographically, the only accessible information referred to the parishes in which the crimes were committed, we aggregated the data at this area level. We are aware that the phenomenon of crime cannot be expressed at the parish level only, and believe that future studies could assess the modifiable area unit problem (MAUP) for the obtained results, considering alternative subdivisions of the city. Additionally, a single study cannot examine all attractors and detractors of a crime. Therefore, we believe that it is important for future research to integrate additional crime attractors, such as ATMs, banks, schools, and stadiums. Further studies could also assess the impact of a city’s land use on crime. Notwithstanding, the obtained results can support local decision-makers and planners in their efforts to control crime in the study area. The spatial–temporal patterns of crime and the factors identified as influencing criminal offences could be considered indicators to support the design of strategies to effectively increase safety in critical areas of the city. The obtained results support the idea of conceiving integral crime prevention policies, in the sense of tackling urban socioeconomic inequalities. The expansion of accessibility to formal education for vulnerable population groups, employment prospects, and social assistance could be measures to prevent criminal offences. Additionally, the enforcement of police control outside bars and night clubs and the locational limitation of these facilities in specific areas of the city can reduce several types of criminal events. This study offers robust approaches and methods to expand the understanding of the spatial and temporal ecology of urban crime by considering socioeconomic indicators. Furthermore, studies of this kind in Latin America are practically nonexistent, and in this sense, our research could be considered an outstanding contribution to the field of crime analyses.