School Failure in the Region of Madrid (Spain): An Approximation through Diagnostic Assessment in 2019

: Education is considered to be one of the main factors of development, economic growth and social progress. No country can achieve sustainable economic development without substantial investment in human capital. In Spain, school failure represents one of the main problems in the educational system, with potentially dramatic consequences for the basic competences required in the labour market and job instability, with the risk of economic and social exclusion. In this paper, we aim to identify the factors that deﬁne the risk of school failure in Madrid (Spain) by applying logit models. In this process we use a deﬁnition of school failure risk which relates to the probability of scoring below level 2 in the evaluation of competences (diagnostic assessment), and we use grade retention as a proxy of school failure. The variables included in the model cover several areas, such as personal, family and school characteristics. The results show that it is important that the policies to strengthen the educational system begin with early childhood education, as educational delay symptoms are detected, and it is necessary to intensify efforts towards personalized assistance to help identify potential learning problems, especially in those groups in the worst socioeconomic situations, which are most at risk of school failure.


Introduction
The significant consequences of school failure and school dropout, both at the individual and societal levels, have generated extensive academic literature and political, economic and social interest at both the national and international levels. International organisations, such as the United Nations in its Sustainable Development Goals-SDG-4, defend education as an enabler of upward socioeconomic mobility and an engine for the reduction of inequalities, with consequences for society: inequalities inhibit economic growth, fuel instability and intolerance, and drive fragmentation by deepening social gaps [1]. Target 4.1 of SDG-4 is to ensure that by 2030 "all girls and boys complete free, equitable and quality primary and secondary education leading to relevant and effective learning outcomes" [2]. The non-completion of compulsory education is linked to the phenomena of school failure and dropout.
Although there is no consensus in the specialised literature on the consideration of school failure, "it can be used both to refer to the results of an individual and to those of the educational system that educates them" [3]. Its conceptualisation and measurement is adapted to different levels and agents of the education system: pupils (the personal micro-level), schools (institutional meso-level) or the region (macro-level).
School failure (and early dropout) is usually centred at the secondary stage; low academic performance in previous educational stages may be the origin and cause of later failure and dropout. Therefore, competency and diagnostic tests carried out during the primary and secondary stages are essential to identify the pupils with the lowest levels of competences, with these being those with the greatest basic difficulties in educational development, and therefore potential school failure and drop-out pupils. The identification of pupils with the lowest levels of competences, and their weight in the classroom, are factors to be taken into account when designing educational policies against school failure. Performance in key competences is one of the indicators of Objective 2 of the Europe 2020 strategy, and the European Council established that the percentage of fifteen-yearold pupils with low performance in reading, mathematics and science should be less than 15% in 2020. The consequences at an individual level for people with low skill levels include greater complications in their labour market insertion: jobs with lower qualifications and pay, with less stability, and when they lose their jobs, they have longer unemployment periods until they find the next one [4]. The country-level consequences of high levels of educational failure are associated with lower long-term economic growth and increased social polarisation [5]; high levels of educational attainment, however, can have a broad positive impact that will last for generations to come, enabling the sustainability of societies [1].
The Programme for International Student Assessment (PISA) tests use "PISA failure" as an indicator of failure for the group of pupils who do not reach level 2 skills. In PISA 2018, Spain had 25% of pupils below level 2 in mathematics proficiency, compared to 22% in the EU and 24% in the OECD. These values are far from reaching the Europe 2020 target, for which the threshold was set at 15%. In Spain, regional analysis shows important differences. In the region of Madrid, the position is slightly below the Spanish average, at 23%, which is between the EU and OECD levels. In relation to scientific competence, Spain matches the OECD average at 22%, and the region of Madrid improves on the national figure and matches the EU average, at 21% [6]. In addition, Madrid is the case study of interest, because it is the third Spanish region with regard to the number of students enrolled in secondary education, after Andalusia and Catalonia, and it has the highest diversity in school ownership.
In this research, the aim is to identify the factors of school failure in relation to the proficiency levels determined by diagnostic tests in the specific case of the region of Madrid (Spain). The regional diagnostic tests were carried out following the model of the PISA tests, and therefore the PISA failure indicator can be transferred to consider pupils at risk of failure when they have a competency level below 2 in these diagnostic tests. The use of these diagnostic tests in the region of Madrid has a fundamental advantage when compared with the PISA tests, because it is not a sample of pupils and schools, but of the population, as the tests have a census nature.
In order to achieve this objective, firstly, the concept of school failure and its determinants are reviewed theoretically, and a literature review is included which analyses failure, and its causes and consequences. Secondly, we construct the database that allows us to analyse school failure through the diagnostic tests of the region of Madrid for the fourth year of compulsory secondary education in 2019; we define the failure indicator, equivalent to that of PISA; and we choose the explanatory variables that will be tested as potential causes. For this purpose, an econometric methodology was chosen to estimate the probability models and to determine the variables that favour or disadvantage these pupils. Repetition and the socioeconomic level of the pupil are the key variables in the risk of failure. The results of this research provide guidance to education policy makers to design measures that reduce school failure and favour the present and future sustainability of the education system and society.

Conceptualization
At a macro level, school failure focuses on a region or country, and it is normally international institutions and organisations that develop the measurement methodologies, which are then carried out autonomously and harmonised by each area for international comparison. The OECD [7], for example, considers school failure during the compulsory education stage to be those pupils whose academic performance is significantly below the average (arithmetic mean) for their age group, i.e., pupils with low academic performance; the process of failure continues after finishing compulsory schooling, referring to pupils who drop out of school at that time, which is considered educational abandonment; and finally, during the working stage, those who do not achieve adequate preparation to develop their professional life [8].
The European Union [9] counts school failure as the proportion of young people who have not completed compulsory education in each country. The measurement of this concept has some methodological limitations, as well as not having a uniform definition for international comparison [8]. Spain associates the school failure rate with the failure to complete secondary education, and this characteristic is determined by national legislation, but it is not the same for the rest of the European countries.
Lacasa [10] conducted an in-depth review of the different definitions and ways of calculation used in Spain since 2000 [10]. The first of these is based on the Ministry of Education and Science, which measures school failure as the percentage of pupils who do not obtain the qualification certifying successful completion of compulsory education [4]. The basis on which it is usually calculated is the number of pupils enrolled in the last year of compulsory education, and this indicator is defined as direct failure. Secondly, the Ministry of Education and Science calculates the gross graduation rate as the percentage between the number of pupils who have obtained the Compulsory Secondary Education (ESO in Spanish) diploma and the number of people who are 15 years old on 1 January of the year in which the indicator being measured ends; from this value, gross failure is defined as the percentage who do not graduate (100%-the gross graduation rate). In this measurement, early leavers are taken into account, but the number of repeaters in each year and other demographic problems that may vary the size of the cohorts and directly influence the calculation of the indicator are not considered.
A third way of measuring school failure from the data provided by the Labour Force Survey (LFS) is the LFS failure or school dropout rate, which is calculated as the percentage of 20-24 year-olds who did not obtain the compulsory education qualification. School dropout is therefore an indicator of school failure, as is early school leaving. This definition is used at an international level, and the European Union included it in the 2020 objectives, specifically indicating that it should be below 10% for the EU, and 15% for Spain, which started from higher values than the rest.
At both a macro and school level, tests on competencies (PISA, PIRLS and TIMSS at an international level, and diagnostic tests at a national and regional level) are particularly relevant. According to the OECD, and as it appears in different research [4,11], it is considered that a pupil does not have the minimum knowledge required if they obtain a score in the competency tests below level 2 (levels 1 (1a and 1b) and <1, from a maximum evaluation of 5); using this measurement, we speak of PISA school failure, counting this percentage of pupils in a classroom or educational centre.
The importance of using measurements of failure related to proficiency levels is well documented in the literature. Several studies [4,[12][13][14][15] show that reaching level 1 or lower reduces the probability of a pupil completing compulsory education. These authors point out, for the case of Spain, that pupils who do not reach PISA level 2 in the science test lack sufficient science skills to participate actively in everyday life or work situations related to science or technology, and reading skills may not lead to future success but, without them, there is an increased risk of encountering barriers to employment, reduced financial security and a worse social situation.
PISA failure is transferable to the national diagnostic tests conducted in Spain in each region. These tests, differentiated by subjects equivalent to those of PISA, have scales relating to proficiency levels, and it is possible to define and calculate school failure in an equivalent way in the regional diagnostic tests. The competency tests provide information on individual pupils, and they can compare their results with the average of their class, their school, and even their autonomous region and country. The average value of their competences should be a positive element for the evaluation and continuing improvement of pupils' academic progress.
School failure is not a matter inherent to the pupil himself; thus, an interpretative framework is needed to help explain and understand all of the variables. This framework is the so-called "intersectionality" [16] that determines the different factors and systems that influence school failure by considering the interdependence, interaction and intersection between them [17]. The potential factors include the sectoral structure of the area, the ease of finding a job without higher education, the level of income, state investment, the importance of human capital and the unemployment rate, as well as other factors innate to the pupil that are more difficult to act upon [18].

Factors of the School Failure
There are elements internal and external to the education system that affect school failure, and they can act with greater potency when pupils have prior conditions that hinder their academic development. Therefore, it is essential to identify pupils who are at risk of failure at an early stage, so that interventions can be established to minimise dropout rates [19].
The process of school failure and dropout has been extensively analysed in the academic literature, which has focused mainly on the detection of factors that can be considered to be direct causes of failure and subsequent dropout. These factors have a temporal dimension which generally corresponds to the moment in time when the failure indicators are calculated; however, determinants are also found for which the temporal dimension is prior to failure. The latter can be considered as leading factors, because they influence failure, but information on them is available prior to the failure, allowing for early intervention.
Among these factors is the earlier-stage suitability rate [10,20]. The suitability rate is the percentage of pupils of the considered age who are enrolled in the course that corresponds to their age [20]. Both the suitability rate and its complementary measurement, the repetition rate, are leading factors of school failure. Repeating a year can be considered to be a predictor of dropout [6,19,21,22].
Another leading factor that is related to failure and dropout is absenteeism. When pupils accumulate unjustified absences, their academic performance suffers [4,5,23]; the repetition of extended absences over time reduces the pace of learning, and signs of a possible school delay begin to appear, which, if not solved in time, would lead to subsequent dropout [24]. Fernández-Enguita [21] points out that the average number of unexcused absences is very high among early school leavers, which can be considered an indication of the relationship between both variables. Absenteeism, therefore, has negative effects on academic outcomes, in addition to other negative effects on socioemotional learning outcomes (self-efficacy, self-management and growth mindset), and causes a reduction in the social and educational engagement of the absentee [23].
The important consequences of school failure and dropout, both at an individual and society-wide level, have led to the creation of extensive literature on these phenomena. The classification of variables that are potential factors of school failure and drop-out differs according to the research. In this report, they will be grouped according to Romero and Hernández [25], who separate them by the type of cause, dimension and scope (Table 1). This classification, considering exogenous factors, as opposed to endogenous factors, has its origin externally, or by virtue of external roots, such that it can facilitate the work of designing the strategies and policies of the different agents involved in the process of school failure and dropout.

Endogenous Variables
Among the personal factors that have an impact on school failure and dropout are motivation, self-concept and self-esteem, academic results in early stages, the suitability or repetition of years before secondary school [26], a high level of absenteeism, study habits, the birth month of the pupil, and attendance at nursery school, among others [27]. The relational dimension refers to the pupil's socio-familial support network, and it brings together both issues related to family characteristics and others that have more to do with the influence exerted by the pupil's peer group [25].
Some family variables that increase the risk of school failure and dropout are belonging to a first-generation immigrant household, parents having a low socio-professional status, and the family having scarce educational resources [27].
The most analysed factor to assess families is their socioeconomic status [5,28], as well as the study conditions at home and family relationships [28]. The literature presents the positive effect of home educational resources on academic performance, as they denote a cultural environment and facilitate the pupil's learning process [29]. However, high incomes are not always related to greater educational resources [30,31], because it depends not only on the investment made by families but also on the use made of these resources.
Another variable to consider is the educational level of the pupil's parents, which is highly correlated with their employment situation [21,[30][31][32], as well as the parents' school failure [10]. This may be due to difficulty in supporting them in their studies, as well as having lower academic expectations of their children and being uninvolved with the school [33].
In recent years, one of the most important family factors for failure has been the origin of the family. In order to capture the impact of this factor, the language spoken at home is taken into account in addition to the family background [29], as well as the generational level. As pupils adapt to the country's education system-and if they are not first-generation pupils-their risk of school failure decreases [4,5,30,31].

Exogenous Variables
Among the structural causes of the education system, we can find the ESO qualification model, the encyclopaedic structure of the curriculum, the academicist approach to ESO [21], the grade culture that generates high rates of year repetition [34] and the lack of predistributive investment in support and reinforcement programmes from primary school onwards [35,36]. The socioeconomic level of families has been diminishing in its effect on academic performance over the years, among other things, due to the increase in educational and social policies to prevent an academic gap between pupils with different economic levels [5].
Within the characteristics of the schools, one of the most important variables is tenure. In general, it is observed that pupils in private and charter schools have a lower risk of school failure than pupils in state schools. However, when the analysis is corrected for family characteristics, the differences by the type of school do not hold, so some authors attribute these differences to the characteristics of their pupils. According to these authors, private schools obtain better results not because they offer a better-quality service, but because the pupils who attend these schools are more easily "educable" [27,37,38].
On the other hand, the characteristics of pupils' peers are considered to be highly relevant in terms of their influence on school failure. The results show significant empirical evidence that the socioeconomic and family characteristics of peers have a clear indirect effect on pupils [39][40][41]. This effect is due to the continuous interaction of pupils with their classroom and school peers, i.e., the "peer effect". In PISA studies, this effect is assessed at a school level, but not at a classroom level [4].
Some variables related to school resources and their use (the provision of computer equipment, time devoted to reading) also have an impact on the risk of school failure, although the results are not conclusive [40].
At a school level, the school autonomy, policies for grouping pupils according to their academic performance, and school philosophy in the admission of pupils are also considered as relevant factors [4,5]. Data on these variables are scarce, so their effect on failure is inconclusive. There are few studies on the grouping of pupils into levels, and it has been observed that it produces a polarisation of academic results: it improves the results of good pupils and worsens those of pupils with poorer performance [4,22,42].
In relation to schools' human resources, there is no consensus on their impact on school failure and dropout [43]. Focusing on assessment, Roldán and Cabrales [44] highlight the existence of a grade-oriented model, instead of learning as the ultimate goal, which may explain the high repetition rates, and therefore school failure. In addition to assessment systems, aspects such as methodological strategies, attention to diversity and tutoring have been under-evaluated in the literature, among other things, due to the lack of objective data. The existence of a boring, de-motivating and disengaging school climate may be caused by a lack of pedagogical renewal on the part of the teachers. This gap should be a clear line of analysis because the development of new areas of knowledge in education, such as neurodidactics and neurolearning, can help us to find new ways to improve personalised performance and, therefore, to reduce failure and dropout.
As for the structural factors related to the social and work environment, we can talk about the characteristics of the social environment-such as poverty, dangerousness, vandalism, rurality, alcoholism, a low cultural level, and dependence on social protection systems-that make school success very difficult for its protagonists [25]. On the other hand, the economic cycle and the economic structure of regions can have a pull effect on early school leaving [20].

Database
The Organic Law 8/2013 for the Improvement in Educational Quality (LOMCE in Spanish-Ley Orgánica para laMejora de la Calidad Educativa) established the obligation of all of the Autonomous Regions to carry out individualised external assessment tests in three academic years: the third and sixth years of Primary Education, and the fourth year of Secondary Education. The central government establishes the general characteristics, while the regions draw up their own tests, following the general guidelines of the central government, although they can modify some characteristics, such as their census, the sample's nature, or the application dates.
The Madrid Region carried out its own external assessment test called the Prueba de Conocimientos y Destrezas Indispensables-CDI (Essential Knowledge and Skills Test) from 2005 to 2015. This test was designed to test the level of knowledge of the pupils. From 2016, the application of the LOMCE established new evaluations at the regional level that were more oriented to the evaluation of the competencies of the pupils. Specifically, for the fourth year of secondary school, the LOMCE diagnostic assessments evaluate the degree of acquisition of linguistic competence (including foreign languages), mathematical competence, and history and geography competence. These are the four compulsory core subjects of the course. The fourth ESO syllabus differentiates between two mathematics subjects: (1) Mathematics oriented to Academic Education, aimed at achieving the necessary competences to study the Baccalaureate; and (2) Mathematics oriented to Applied Education, aimed at achieving the necessary competences to study Vocational Education and Training. Most pupils enrol in Academic Mathematics, and the tests are different, with the Academic Mathematics test being more demanding.
Most regions carry out a sample test in a small number of schools; however, the Madrid Region is one of the few regions that carry out this test in a census form for all its pupils. Therefore, this work contributes additional value to the literature, with the use of a new and more complete database of the Madrid Region. Furthermore, the Madrid Region is one of the few regions that have openly offered the anonymised results of these tests to any researchers who have requested them, and therefore several articles have emerged based on the databases of the external census evaluations of the Region of Madrid [45][46][47].
The database consists of two types of information, evaluation results and context questionnaires. These tests are inspired by the proficiency tests conducted in major international assessments such as PISA, PIRLS and TIMSS. The results of the competency tests are based on Item Response Theory (IRT), a model which is appropriate for large-scale educational assessments. Specifically, the Rasch model is used, a logistic model of a parameter where the level of a pupil's trait depends on his or her level of ability and the difficulty of the items. In order to transform the difficulty parameter, the methodology used in the PISA assessment is followed, with an average distribution of 500 and a standard deviation of 100. This provides a score for each pupil, and their level of performance, from 1 to 6. Following the PISA methodology, the failure indicator comprises pupils who score below level 2 in each competency.
On the other hand, the database has numerous context variables that are obtained with the following questionnaires: a family context questionnaire filled in by the parents of the pupils, a school context questionnaire carried out by the director, and a questionnaire for the teachers who teach the subjects evaluated. These surveys make it possible to analyse the differences in the results due to the social and family environment of the pupils, the school environment, and the type of teaching. The combination of the academic results and these questionnaires makes it possible to obtain a wide range of information about the pupils under study, and their personal, family and educational environment. One of the contributions of this study is to be able to incorporate numerous variables of different elements that affect school failure. The following section describes these variables. -Early education: 1 for pupils entering pre-primary education before the age of 3 (first cycle of pre-primary education), 2 if they enter at the age of 3 to start the second cycle of pre-primary education, and 3 if they enter later.

Variables of Interest
-Repetition: 1 if the pupil has repeated 1 or more years, and 0 if the pupil has never repeated a year.
-Homework: the weekly time spent by the pupil on school work (study or homework) outside of school hours, with a value of 1 if this is less than 3 hours, 2 from 3 to 6 hours, etc., up to 8 if this is more than 21 hours.
-Absence: the number of full days that the pupil has missed during the term without justification, with 1 being less than 2 days, 2 being between 2 and 4, 3 being between 4 and 6, and 4 being more than 6 days.
-Immigrant: the pupil's country of birth is used as a proxy for immigrant status, with a value of 1 if they were born outside Spain, and 0 if they were born in Spain.
-ESCS-Economic, Social and Cultural Status (PISA), which is calculated with three variables related to family background: the parents' highest level of education, the parents' highest occupational status, and the material and cultural possessions at home (books, digital devices, computer, internet, press). Positive values indicate above-average status; negative values indicate below-average status.
-Peers' ESCS: this measures the difference between the pupil's ESCS and the school's ESCS by subtracting each pupil's ESCS from the school's ESCS. Positive values indicate that the pupil attends a school with students who, on average, have a higher ESCS than the pupil, and negative values indicate that the ESCS of their peers is lower than that of the student.
2. Characteristics of the School and School Environment -State: 1 if it is state owned and 2 if it is private.
-Bilingual: 1 if the pupil attends a school that is bilingual in the year being assessed, and 0 if the student's school is not part of a bilingual programme.
-Pupils in school: the number of pupils in the school, to measure the size of the school.
-Pupils per class: the average number of pupils per class.
-Lack of funding: The headteacher's response in the questionnaire to the lack of budget and resources as a factor limiting the effectiveness of his or her management, to which he or she answers 1 (not at all), 2 (very little), 3 (to some extent), and 4 (very much).
-Teachers with seniority: the percentage of teachers out of the total who have been at the school for 5 or more years.
-Bad teaching conditions: the average of the head teacher's answers to 7 questions on whether the shortage of good teachers, their ability to teach pupils with special educational needs, the shortage of teaching materials, technological devices, internet connection, teaching software, library, support staff and administrative staff is a disadvantage for the school's educational work, with 1 being no disadvantage, 2 being a slight disadvantage, 3 being moderate and 4 being a serious disadvantage.
-Conflictive families: the average of the head teacher's answers to 4 questions on whether families represent a problem for the school due to their lack of collaboration, their criticism and opposition to school rules, or their lack of respect for teachers and other families, with 1 being not a problem, 2 being a slight problem, 3 being moderate, and 4 being serious.
The descriptive statistics for all of these variables are presented in Table 2.

Methodological Approach
The departure point of the study is a descriptive analysis conducted to identify factors explaining the likelihood of student failure at school. In order to do this, firstly, an OLS regression was carried out with all of the dependent variables on the results of the different competences assessed. This made it possible to establish the variables that most influence these results. Secondly, the averages of the variables of the whole sample were compared with the averages of the pupils who were lagging behind in each subject, and with the averages of the repeaters. The averages of pupils in Academic Mathematics and Applied Mathematics were also compared in order to analyse the difference between these two subjects. Finally, a logit regression model was used to further study the differences in the probability that a pupil has among the lowest levels of competences in the different areas assessed in the diagnostic tests, or among the year repeaters. Thus, the regression equation to be estimated is as follows, where P is the probability of school failure, X is a vector of independent or control variables, and β is a vector of coefficients to be estimated. Moreover, F(X'β) is the cumulative distribution function of the logistic function, so that In the different specifications of the model, the dependent variable is always a dichotomous variable, which takes a value of one if the pupil is at low proficiency levels (2 or lower) or has repeated one or more years. The estimated coefficients using logit models cannot be directly interpreted as the magnitude of the change in the outcome probability that is associated with a one one-unit change in the corresponding independent variable; thus, they only represent the direction of the relationship between the dependent variable and the independent variables. Therefore, the sign of the coefficients indicates the direction of the change in the likelihood or probability of school failure. In order to allow for a better interpretation of the results, we calculated the odds ratio, i.e., the marginal effect of each estimated coefficient. The difference between 1 and the odds ratio indicates the discrete change in the probability (in percentage points) of school failure, as the independent variable changes by 1 unit, holding all of the other variables at their average. Table 3 shows a first OLS regression on the study variables (Equations (1) and (2)). This regression allows us to detect which variables have a general influence on the results of the different subjects. Our results confirm the direction and intensity of the relationship between the factors and the school failure found in the previous literature. The personal characteristics of the pupils are those that most affect their results. Thus, gender has a significant effect, both statistically and in terms of magnitude, on the results in each subject, with female pupils obtaining better results in the language proficiency subjects (Spanish and English), while male pupils obtain better results in Mathematics and Geography and History. This is in line with previous research that points to the greater predisposition of females towards language skills, and males towards mathematics and science skills [48][49][50][51]. The pupil's birth quarter-i.e., the relative age of the students in their class-affects their academic performance, which decreases the younger they are. This result is common in the literature, which finds that a low relative age of pupils in a class has negative effects on their performance [52][53][54][55][56]. As is found in the literature [53,57,58], early attendance in primary education positively influences outcomes, as the later the pupil starts education, the worse the outcomes, although the magnitude of the effect is not very large. Finally, repetition is the variable with the most important influence on outcomes. In addition to its statistical significance, the magnitude of its influence is around 50% of the standard deviation, and in English the influence is even larger. This result is in line with the previous literature, which determined the repetition rate as a leading factor of the failure rate (see Section 2.2). The subject Applied Mathematics behaves relatively differently from the rest in several of the variables, which will be discussed below.

Results
The previous variables relate to the most personal characteristics of the pupil, which cannot be changed, including attendance at early education, which-although it depends on the parents' choice-once it has taken place in the past, cannot be changed in the present, and the same applies to repetition, which is a definitive and immutable characteristic of the pupil once it has taken place.
On the other hand, the following two variables are related to the present attitude of pupils in their education. For instance, doing schoolwork outside school hours has a positive effect on academic results, although its magnitude is not very large. This result is also verified by the PISA data for Spain [6]. The other variable, unexcused absences from school, has a negative effect, and its magnitude is significant (see references in Section 2.2).
The characteristics of pupils' families are analysed with two variables. The first is immigration, which has a significant (both statistically and in magnitude) and negative effect on academic results, especially in the basic subjects of Spanish language and mathematics. However, this effect does not occur in the subject of English, probably because pupils from other countries have a better foreign language proficiency compared to the rest of the subjects. ESCS is the variable that, in addition to being statistically significant, has the largest magnitude of influence on pupils' results, together with repetition, i.e., between 30 and 50 per cent of the standard deviation. As explained above, this variable combines the social, cultural and economic characteristics of the student's family. These characteristics are presented as being key to their academic results. Finally, the individual ESCS level compared to that of the school allows us to analyse whether differences in the socioeconomic levels of a pupil compared to that of their peers affect academic performance. The results show a significant effect, both statistically and in terms of magnitude, indicating that if the student is in a school with pupils with a higher ESCS than his or her own, the effect on his or her individual results improves, with an even greater effect in English. On the other hand, if the average ESCS of the pupils in the school is lower (negative) than that of the individual student, his or her results worsen. The previous variable "peers' ESCS" is a combination of the pupil's family situation and the school's characteristics. Other characteristics of the school may also influence the pupil's outcome, although their influence is mixed. The most significant in magnitude is the state or private nature of the school, as academic results are lower in state schools. Bilingual schools have an ambiguous effect, as results in English are much better, which is to be expected, but results in Geography and History-a subject taught in English in schools belonging to the bilingual programme-are worse, while the subjects taught in Spanish in the bilingual programme (Spanish language and Mathematics) are not statistically significant. This is explained by the fact that when Geography and History are taught in English, pupils have more difficulties in acquiring the skills of this subject because it is not taught in their mother tongue, and because the teachers who teach it are not strictly bilingual either, as they are Spanish teachers with a CEFR C1 level [45,46,59,60]. Of the remaining variables, those related to teachers stand out. Teacher seniority has a positive effect on the results in all of the subjects except English. In contrast, bad teaching conditions have a negative effect on the Spanish language subject, but not on the other subjects. Finally, the lack of family involvement has a negative effect on academic results, although only the Spanish language results are significant.
The above effects are not necessarily the same for pupils who are lagging behind or repeaters. One of the aims of this research is to test the effects on the pupils who are lagging behind in order to see where educational policies that seek to improve their results have the greatest impact. First, we compared the average values of the competences assessed for both groups of pupils: more successful and less successful students (Table 4). It was found that the differences between the two groups are significant, both from a statistical point of view and in terms of the difference between the scores, which is between 150 and 200 points (between 1.5-and 2-times the standard deviation of these variables). We also analysed the averages of all of the variables of the less successful students and repeaters in relation to the total number of pupils in the sample (Table 5). This reflects the differences between these pupils and the total, as well as the effect this might have on academic results. Firstly, the gender composition of the less successful students confirmed their influence on academic results, with more female pupils lagging behind in Mathematics and Geography and History, and more male pupils lagging in Spanish and English. The significant effect of repetition on academic results was also confirmed, with repetition levels increasing markedly among the pupils who lagged behind, e.g., by up to 65 per cent in Mathematics. The positive effect of homework completion and the negative effect of unexcused absences and immigrant status were also confirmed by the slight percentage change in these variables among the less successful students. Once again, ESCS was the most decisive variable, together with repetition, as compared to a zero average ESCS for all pupils (it was zero by definition of the variable); the less successful students had, on average, a significantly lower ESCS. The birth quarter and attendance in pre-primary education, although slightly higher for less successful students, had a small difference. Finally, the above effects of less successful students were intensified for repeaters.
Interestingly, the variable Peers' ESCS measures the difference between the pupil's ESCS and that of the school. Although the OLS regression showed that, if the student is in a school with pupils with a higher ESCS than their own, the effect on their individual results improves, the comparison of averages shows that the less successful students and repeaters have, on average, a higher Peers' ESCS than the total number of pupils. The rest of the school-related variables do not significantly affect less-successful students, except for being a state school, where more less successful students and repeaters are concentrated than average. Only the lack of budget and family conflict show slightly different averages than the total number of students. Before applying the logistic regression, it is necessary to analyse the difference between the subjects Academic Mathematics and Applied Mathematics. In the last years of ESO, pupils choose between different optional subjects that make them tend towards science or humanities, as in later stages (Baccalaureate, Vocational Training and University). But within the compulsory core subjects (which are the four that are also externally assessed, and which are discussed in this article), Mathematics has two options: one is Academic Mathematics, which are chosen by the majority of pupils (88% according to the data shown in Table 1) and which deals with a greater amount of contents and is more demanding, and Applied Mathematics, which is more basic and less demanding, and which emphasises the practical application of the contents of the course, as opposed to an in-depth study of the theoretical aspects. The academic courses provide access to the Baccalaureate, while the applied courses provide access to Intermediate Vocational Training. Table 6 shows the averages of the pupils in both subjects, and that of the total number of students. The results are as expected; there are more male pupils than female ones in applied mathematics, they attended early childhood education later, they do much less schoolwork at home, they have more unexcused absences, there are more immigrants than in the total average of pupils, their ESCS level is much lower, and they have a lower ESCS than the average of their school. Regarding the school, there are more pupils in applied mathematics in state schools and in smaller schools. A lack of funding is slightly associated with having more students in applied mathematics, as is having families who are not very involved with the school. The results of pupils who enrol in applied mathematics are significantly lower than those who choose academic mathematics, and students in applied mathematics have the highest percentage of pupils who fall behind and do not reach level 2 in the tested subjects. The results of the logistic regression (Table 7) contain the odds ratio, which allows us to see the probability that a pupil belongs to the group of less successful students in each subject if the variable changes by one unit, assuming that the rest of the variable remains constant in its average In the case of dichotomous variables, the odds ratio applies to the whole variable. For example, in the variable Female, the odds ratio indicates the probability of being in the group of less able students by virtue of being a female student. It is calculated by subtracting 1 from the odds ratio, such that if it is negative, it means that the probability decreases (or increases for the opposite of the discrete variable, in this case, being male), and if it is positive, the probability increases. Thus, if you are a female pupil, the probability of being in the group of less-able students in academic mathematics increases by 85 per cent, while the probability in Spanish language is negative, −27.7 per cent, indicating that this is the probability of a male pupil being in that group. The results confirm much of what has been analysed in the previous tables. Two variables of the pupils' personal characteristics have the greatest influence on the probability of being a less successful student. The first is being a repeater, which more than doubles the probability of falling behind. The other is the ESCS, the increase of which by one unit (which in this variable is equivalent to its standard deviation) decreases the probability of being a less successful student by around −40% in all subjects except English, with a higher probability of −71.2%, and with −59.3% being the probability of being a repeater.
As in the previous analyses, the influence of school characteristics on academic results is smaller than that of the student characteristics. Thus, the probability of being a less able student or repeating only increases if the school is a state one (between 35% and 60%), if the school is underfunded (although only in two subjects: English, 13.6%, and Academic Mathematics, 7.5%), or if the families are not very involved in the school (also only in two subjects, with Spanish language being 13.8% more likely, and geography and history being 9.3%). For the rest of the variables, the differences are not statistically significant, or if they are, their magnitude is not significant. Other personal characteristics also influence the probability of being a less successful student or repeater, although to a lesser extent. For instance, a female pupil is more likely to be in the group of less successful students in the subjects of mathematics and history, while the probability is lower in language subjects. Repetition is also less likely (−27.9%) for female pupils. The birth quarter does not affect the probability of being in the group of less successful students, although it does affect repetition, as being born in a later quarter increases the probability of repeating by 13.8%. The same happens with early education attendance; it does not influence the probability of being in the group of less successful students, but it does influence repetition. Doing schoolwork at home has a negative influence on the probability of being in the less-successful students group by up to −10% depending on the subject, while in repetition the probability rises to −18.4%. Unexcused absences increase the probability of being in the group of pupils who are lagging behind by 10 to 20 per cent, a probability that rises to 46 per cent in repetition. Immigrants have a probability of being in the group of less successful students of from 10 to 50 per cent, depending on the subject, while the probability of repeating a grade for an immigrant rises to 80.4 per cent.
Most of the variables analysed have a similar effect in all subjects, except for the two specific ones we have already explained: being female, because some subjects are better for female pupils and others for male pupils, and being bilingual, which reflects the different influence of subjects taught in English or Spanish. However, there are two subjects that behave somewhat differently and deserve specific analysis. The first is English language. In addition to having a better result in bilingual schools, which is to be expected, it also has a different behaviour in three other variables: repeaters, immigrants and ESCS. The probability of being a less successful student is much higher in English than in the rest of the subjects for repeaters and immigrants. This reflects a lower interest in this subject compared to the other compulsory core subjects. Perhaps repeaters and immigrants think that English is less important than the classic subjects of Spanish language, mathematics, and geography and history. On the other hand, the higher ESCS means that the probability of being a less successful student in English is lower (28.8%) than in the rest of the subjects (around 60%). This may reflect the fact that social, economic and cultural background has a greater effect on the classical subjects, while English language competence can be acquired in other ways (songs, films, the Internet) where ESCS does not have as much influence. Another explanation may lie in the bilingual programme itself, which improves the English proficiency of Madrid pupils even when their socioeconomic status is lower.
Finally, regarding the choice that pupils have to make between academic and applied mathematics, the fact that most students choose academic mathematics, even though it is more demanding, may mean that if a pupil chooses applied mathematics, it is in itself a way of being in a group of less-successful students. For this reason, the results of pupils who are lagging behind in applied mathematics are very insignificant. For all of these reasons, we performed a logistic analysis using enrolment in applied mathematics as the dependent variable (the last column of Table 5). The results are very similar to those of the pupils lagging behind in the rest of the subjects, both in the variables that do not have a significant effect and in many that do. Thus, the student's gender and personal effort, measured through the variables of schoolwork and absence, have a similar effect on the probability of choosing applied mathematics as on the probability of being a less successful student in the rest of the core subjects. The effect also has the same sign, although with a lower probability, for immigrants and ESCS. All of these similarities mean that choosing to enrol in applied mathematics can be seen as being similar to being in the group of pupils lagging behind in the other subjects.
However, there are also differences in other variables, namely three. One is that the probability of choosing applied mathematics is curiously not influenced by being in a state or private school, unlike in the rest of the subjects, although it should be remembered that being in a state school does increase the probability of being among the pupils lagging behind in applied mathematics by 50% (as occurs with the rest of the less successful students in the other subjects). The second variable with a differential behaviour is the lack of budget, which was not significant in all of the variables of the less successful students (it is not significant in Spanish language, in applied mathematics, or in geography and history), and in addition to being statistically significant, the probability of being behind in applied mathematics due to a lack of budget is higher (23.5%) than in the other subjects, and even than in the repeaters. The third variable is repetition. As seen above, being a repeater is the factor that makes it most likely to be in the group of pupils who are lagging behind. But this probability is much higher for pupils enrolled in applied mathematics, at 878%, which is more than double the highest probability for the other subjects (367% in English).

Discussion and Conclusions
School failure represents one of the main problems in the Spanish educational system. This work analyses school failure in Madrid, one of the most important regions in Spain. The statistical analysis uses the LOMCE diagnostic assessment, which is a very interesting database because it is a recent (2019) census of all students, and because it combines an assessment of competencies with context questionnaires that make it possible to obtain a wide range of information about the pupils under study, and their personal, family and educational environment, including numerous variables of different elements that affect school failure. With this database, the conclusions of our study of the Madrid region can be extrapolated to all of Spain.
Thus, this work identifies the factors in belonging to the school failure risk group, which causes a reduction in academic performance and, ultimately, repetition. The repetition rate has been shown to be a leading factor of the school failure rate. The reduction of the repetition rate in compulsory education is still a pending issue in the Spanish education system. Although the repetition rate has been falling in recent years, it is still at a high level when compared to Western countries. In Spain, the 2018 PISA data indicated that the repetition rate was 28.7% (in Madrid, 29.9%) compared to the OECD average of 11.4%. High repetition rates represent a major problem for the education system as a whole and for the pupils concerned, because as the econometric analysis for the Region of Madrid has shown, they have a higher probability of failure, "with what it means in terms of loss of quality employment opportunities for their future, without ruling out the risk of social exclusion" [6]. Our work confirms this fact: the probability of a student being in the group of those lagging behind in competences doubles when they have had previous experience of repetition. This work presents the novelty of focusing the analysis not on all students but on the less-successful ones. Its results are further evidence for the discussion on whether or not it is acceptable for pupils to repeat, and it opens the way to seeking new educational policies that reinforce student development during the course, in order to reduce high repetition rates.
There is no consensus in the literature on whether student repetition is a positive or negative factor. In our work we show that repeating has a negative effect, and we advocate for less use of repetition. In this sense, an example of alternative policies that seek to reduce repetition is included in the latest Spanish education law [61], and the Curricular Diversification Programmes, which allow the curriculum to be modified from the third year of compulsory secondary education, for pupils who are not in a position to progress to the third year, and whose aim is to enable them to obtain the Compulsory Secondary Education Graduate Certificate. However, this should not be the only alternative, because the evidence in the literature already offers other options, such as reinforcement in school support, tutoring, and more flexible programmes adapted to each individual level, etc. In this sense, measures aimed at pupils and others aimed at families should be considered, because, as our work shows, the involvement of families can reduce the risk of failure.
The socioeconomic status of families is crucial to the risk of pupils falling behind in the skills analysed. Pupils who are in families with lower socioeconomic status (as measured by the ESCS) are 40% more likely to be in the group of pupils with lower proficiency levels. Evidently, government policies (both at a national and regional level) that support families with economic measures (lunch and transport grants, free books and extracurricular activities, etc.) will favour the reduction of the failure rate of pupils. Related to the socioeconomic level of students is the level of school segregation, a key element for the diversity of policies. There are successful examples of policies at the international level in this regard; for example, in the United Kingdom, the Pupil Premium programme, established in 2011, provided an unconditional transfer to a school based on the number of disadvantaged pupils, and the evaluation of this programme led to a reduction in school segregation [44,62], with the consequences on the failure rate that this has.
A final relevant issue focuses on schools, their ownership and their level of financial and human resources. Our research shows a differential behaviour in state and under-resourced schools, where a higher percentage of pupils lag behind. Although some authors consider that private schools obtain better results because the pupils who attend these schools are more easily "educable" [27,37,38], our results show that the difference between state and private schools is not only a matter of ownership, and may hide other aspects that are detrimental to the possibility of reaching adequate levels of competence. One example is the abrupt transition from primary to compulsory secondary education. The change of school has always been a problem in education [21]. In the specific case of the transition from primary to secondary school, the pupil goes from depending on one main teacher (tutor), with whom they had a global relationship-academic and affective -to depending on almost a dozen teachers, each one dedicated to their own subject and with their own criteria, which is difficult to coordinate. This transition in private schools is less abrupt, firstly because there is not usually a change of school, and because pupils know the teachers at both stages. In addition, private schools have much better control over attendance and absenteeism, as well as over discipline problems [21]. Finally, the allocation of secondary education to the state sector has led to the introduction in most of Spain, and in the region of Madrid in particular, of the so-called continuous school day, which concentrates class attendance in the morning before lunch, leading to an intensification of pupils' workload [21] and greater difficulty for the students concerned.