A Proposal of Spatial Measurement of Peer Effect through Socioeconomic Indices and Unsatisfied Basic Needs

: This paper investigates peer effects in the academic achievement of Costa Rican students. Two measures of peer effects are used: (1) a measure of a schools’ average socioeconomic status and (2) a measure of unsatisfied basic needs at district level. The estimation of a three ‐ level hierarchical model allows us to deal with selection bias and unobserved heterogeneity. Results show that socioeconomic peer effect, both at school and district levels, positively and significantly correlates with academic achievement. An increase in one standard deviation in the socioeconomic index has the same effect on academic achievement as an additional year of schooling; two years if the improvement occurs in the index of unsatisfied basic needs. These results are robust for mathematics, reading and science. Results from quantile regression reveal that students with high academic achievement take greater advantages from studying in schools with higher socioeconomic status (mathematics and reading). Meanwhile, students with low academic achievement are the most affected by studying in poorer districts (mathematics and science).These results show the strong feedback between educational and social inequity and constitute a good example of how poverty traps can persist in developing countries.


Introduction
Peer effects have important consequences in terms of educational equity, as they can perpetuate social differences. If the students' results are conditioned by the socioeconomic environment of the schools, and students that attend schools with lower socioeconomic status get lower educational achievements, this can create a poverty trap, in which poverty persists.
The influence of the peer effect on student achievement has been studied since Coleman (1968) published their well-known report "Equality of Educational Opportunity" on the determinants of educational performance. Since then, a growing number of empirical studies have analyzed the consequences of the peer effects in education (see Vigdor and Ludwig 2010;and Paloyo 2020 for a detailed review). This literature has in common the difficulties of defining the peer effect, the scarce availability of data, and the methodological problems, as endogeneity, that make the impact of the peer effect uncertain (Murnane 1981;Manski 1993;Izaguirre and Di Capua 2020).
The objective of this study is to provide new ways to measure the peer effects and estimate its impact on academic performance in Costa Rica; a country that belongs to a region, Latin America, where these studies are scarce. In fact, as far as we know, there are no previous empirical studies that have focused on the study of peer effects in Costa Rica. Beside this, the existing studies in Latin America are based on national sources, such as SAEB (Firpo et al. 2015) or GERES (Marotta 2017), or regional datasets as TERCE (Izaguirre and Di Capua 2020). To the best of our knowledge, there are no regional studies that use the international dataset provided by the Programme for International Student Assessment (PISA), carried out by the Organization for Cooperation and Development. This makes it difficult to compare the results between a large international sample of countries. At the same time, it limits the design of the empirical models since the surveys used do not offer the methodological possibilities of PISA. The use of this international survey in the present analysis allows us to work with more control variables and to facilitate international comparisons.
We propose two indicators to measure the peer effect: (1) The level of economic, social and cultural status (ESCS) by schools; traditional in literature but not previously used in Latin America studies.
(2) A district poverty index, calculated through unsatisfied basic needs in terms of hygiene, education, consumption or housing. This constitutes a novelty in the literature on the measurement of peer effects.
To carry out the empirical analysis, we use the data that PISA offers on the academic performance of Costa Rican students in 2012. We chose this year because it allows us to also have socioeconomic data, which we will merge with the PISA database. In 2012, geolocalized information of the schools participating in PISA in Costa Rica is available and this information is crucial for our methodological proposal.
The results show that the peer effect, measured through the economic, social and cultural status in the schools, is positively and significantly correlated with the academic performance of the students. That is, those students who study in schools where their peers have a higher economic, social and cultural level, obtain better academic results. Regarding the peer effect measured through the poverty index, we find that studying in schools located in the poorest districts -where there are unsatisfied basic needs-is negatively correlated with academic results. The results are robust for mathematics, reading and science.
This evidence has important implications on the design of educational and economic policies. The situation risks students in the poorest districts and schools falling into a poverty trap. In this sense, our results provide information on the possible social consequences of poverty perpetuation, and courses of action to promote educational equity and social mobility. Poverty reduction is a clear and measurable goal that has to be tackled in order to spur learning achievement.
The rest of the article is organized as follows. The second section reviews the existing literature on the peer effect. The third section presents the data used in the analysis. The fourth explains the methodology. The fifth presents the results. The sixth compares the results with those of other works. The seventh includes the conclusions, extensions and recommendations in terms of educational policy.

Literature Review
The impact of peer effect on academic performance has been widely studied in the literature, especially in developed countries, where we find greater availability of data (Ammermueller and Pischke 2009). The composition of the classes according to gender or ethnicity, the abilities of the classmates and their socioeconomic level are the characteristics most used to measure the peer effect. Most of the studies conclude that the peer effect is an important determinant of academic performance (Sacerdote 2011;Carrell et al. 2018;Paloyo 2020).
The first articles that analyzed the peer effect focused on the impact that the composition of the classes had on the performance of the students. In these cases, the effect has been measured mainly through gender or ethnic differences. Empirical evidence has shown that a higher percentage of girls in classes benefits students' academic performance, by reducing the level of violence and distraction (Lavy and Schlosser 2011). Regarding ethnicity, the results are more ambiguous. Hanushek et al. (2003) conclude that a higher percentage of African American students affects performance. However, Diette and Uwaifo Oyelere (2017) defend that it would be language problems, and not the presence of immigrants per se, which produces negative effects on the academic performance of native-born students. Summers and Wolfe (1977) take ethnic differences into account, but their study is also pioneering by introducing the measurement of the peer effect through the ability of peers (scores in standard evaluations). Their study for Philadelphia reveals that surrounding themselves with higher-achieving peers especially benefits disadvantaged students. This approach has been applied more times since then. Hoxby (2000) stands out for being one of the articles that estimates the greatest impact of the peer effect on academic performance. Hanushek et al. (2003) propose to use the ability of classmates from two previous courses as a measure to avoid problems of reverse causality-the student's academic performance affects the rest of the classmates and vice versa, overestimating the results.
One of the variables most used in the literature to measure the peer effect is the socioeconomic status (SES) of peers. The findings of Coleman (1968) on the importance of socioeconomic status as a determinant of the academic performance of American students, provoked a large wave of research that decided to measure the peer effect through this characteristic. According to the meta-analysis of Sirin (2005), the main components of socioeconomic status are: family income, education, parental occupation and household resources. In this line, Schneeweis and Winter-Ebmer (2007) measure the peer effect of Austrian students through the maximum parental occupation index. Rangvid (2003) uses the average per class of years of maternal education for Denmark as a measure. Both authors use the indices that PISA provides and obtain a positive relationship with academic performance. Another proxy used in the literature to measure the peer effect is to elaborate socioeconomic indicators that combine various dimensions of the family situation. Our study agrees with Raitano and Vona (2013) in using the level of economic, social and cultural status offered by the PISA program to measure the peer effect. This indicator is one of the most complete capturing the student's socioeconomic level.
Finally, it should be noted that the relationship between peer effect and academic performance occurs through two channels: schools and districts-the latter represents a more recent trend line. The school has been the most used context in educational production functions (Rangvid 2003;Raitano and Vona 2013). A growing number of studies have demonstrated that school socioeconomic economic status is significantly related to academic achievement (Pop-Eleches and Urquiola 2013;Angrist et al. 2016;Xuan et al. 2019) The characteristics of the district where the school is located-unemployment, poverty, health, crime, education, etc.-can also affect the academic performance of students and well-being (Del Valle and Fernández 2014;Billings et al. 2014 Gimenez andGimenez et al. 2021). Students do not interact only in schools. The districts where the schools are located also constitute areas of special interest given that students spend many hours developing extracurricular activities and sharing in leisure ). However, despite confirming this last relationship, Vigdor and Ludwig (2010) or Carlson and Cowen (2015) find that the impact of schools on the academic performance of students in the United States is greater than that of districts.
In the case of Latin America, the empirical studies related to peer effect are both more recent and scarce, but results point in the same direction: socioeconomic characteristics on student, school and neighborhood are determinants of academic achievement and can explain a high variability of differences in school performance.
Most of the studies on peer effect have analyzed the impact of family and school socioeconomic level on academic performance. Breton and Canavire-Bacarreza (2016) estimate the effect of socioeconomic characteristics on student scores in seven Latin American countries and Scandinavia and find that the half of the difference is explained by Latin American parents lower average educational and socioeconomic characteristics. These results are also corroborated by Castro-Aristizabal et al. (2017). The authors using results from the 8 Latin American countries in PISA 2012, find that the differences in individual and characteristics explain the greater proportion of the gaps in performance. Other studies have focused on the socioeconomic characteristics of schools, and in particular, the differences between public and private schools. In this line, Somers et al. (2004) analyze if private schools are really more effective than public schools at improving student outcomes ("private school effect") in Latin American countries. Based on UNESCO data for 10 countries, the authors find that differences in achievement between private and public schools are only partly explained by better socioeconomic status of private school students and much more by peer-group characteristics. Castro-Aristizabal et al. (2017) using PISA 2012 data for 8 Latin American countries also find that the differences between private and public schools are mainly explained by individual and family characteristics. Sakellariou (2017) also points out the importance of accounting for peer effects when evaluating school effectiveness between private and public schools.
There is little empirical research that explicitly analyses the measure of peer effect in Latin America. In the case of Chile, McEwan (2003), uses data from the Ministry of Chile on the academic performance in the Spanish language subject and the family characteristics of his eighth-year students. The author measures the peer effect through the years of mother's education and finds that peer effect improves the academic performance of students. Additionally, for Chile, Canales and Webb (2018) examine the detrimental effects of high ethnic composition schools on differences between nonindigenous and indigenous students. Using national test score data, they find that school composition with respect to the socioeconomic background and indigenous status of students matters for academic achievement. For Brazil, Marotta (2017) measures the peer effect through the ability of peers, based on data from the Longitudinal Study of the Generation of Schools of 2005 "GERES". Comparing the performance of students at the beginning and at the end of the first year, the author concludes that students learn more by surrounding themselves with peers with a higher academic level. Based on TERCE data set, Izaguirre and Di Capua (2020) assesses peer group influence on academic performance of primary school students in Latin America and the Caribbean. The authors find the existence of endogenous peer effects, but their magnitude and significance depend on subject and school type.
This paper contributes to the literature on peer effects offering further empirical evidence on a Latin American country, one of the world regions where there is a relative shortage of literature on the peer effect and academic achievement in comparison with developed countries. Our research provides some key contributions to the literature on the peer effect in Latin America. First, as far as we know, this is the first application based on PISA data to measure the impact of the peer effect on academic performance. The literature in the field has explicitly recognized the difficulty of estimating peer effects because of the existence of omitted variable bias problem and data limitation (Izaguirre and Di Capua 2020). The combination of the PISA dataset with local socioeconomic data and the use of an index of unsatisfied basic needs as a measure of district poverty offers a conceptual and methodological improvement to previous evidence. Moreover, we have not found any literature that measures the peer effect in Costa Rica, which makes our research the first to estimate it.

Empirical Study, Data and Descriptive Statistics
Our empirical study analyses peer effects on student achievement through a socioeconomic index at school and district level in Costa Rica, which is a novelty.
Costa Rica is suitable for our empirical analysis. Costa Rica is one of the countries in the region with more accurate statistics, both with regard to the variety of the information collected and in the methodological quality of its elaboration. We focus on the year 2012 for two reasons. First, in that year the PISA survey was carried out (the project collects information every 3 years). Second, for that year, there is information on the index of unsatisfied basic needs in Costa Rica. These types of poverty studies represent a great technical complexity for statistical offices and are not frequent. At the time of this study, 2012 is the last year for which the index was developed. Tables A1 and A2 in Appendix A offer a description of the variables and their sources as well as the summary statistics.
Unlike previous literature that relies on national or local level examinations, our research work uses the PISA dataset. This international evaluation, implemented by the OECD in 2000, examines the results of 15-year-old students in three areas, mathematics, reading and science every three years. Costa Rica has participated in this program since 2009.
The PISA dataset has some technical advantages. Besides the estimates of students' skills, PISA collects data on the student, family and school factors that helps to explain differences in performance. Consequently, the results of PISA have a high degree of validity and reliability and enable international comparisons (OECD 2013a).
Of course, like other programs that attempt to measure the performance of students, PISA is not immune to some problems of a technical nature. For example, the presence of missing observations, which stem from the fact that students and directors leave questions unanswered, can be a major problem when working with PISA. Some authors propose to eliminate those observations that do not reach a pre-established minimum level of responses. In our sample, the missing observations are 4.5% (Table 1). Although this percentage is low, eliminating those observations with at least one blank answer would mean losing 48% of the sample size (from 4602 to 2381 observations). For this reason, it is essential to use a method that allows us to deal with the loss of observations without reducing the sample. Following Gimenez et al. (2018) and , we use the hotdeck procedure, specifically, the Bayesian bootstrap method of Rubin and Schenker (1986) implemented in Stata by Mander and Clayton (2007). This hotdeck procedure replaces each of the missing values with the most similar values from the observed cases, maintaining the total sample. To measure the peer effect on the academic performance of students, we propose to use socioeconomic status by schools and poverty by districts (473 in the country). The level of economic, social and cultural status (ESCS) index provided by PISA was constructed using the three variables related to family background: parents' highest level of education, parents' highest occupational status, and home possessions-including books in the home (OECD 2014a). The ESCS index is therefore calculated at the school level and the variables that allow it to be calculated are student-level variables. Consequently, although there is an association between the socioeconomic level of each student and that of the school, we move at different levels.
The poverty index that we will use has been prepared by the National Geographic Institute and the National Institute of Statistics and Censuses of Costa Rica. The latter is measured through an index of unsatisfied basic needs in housing, education, hygiene and consumption. Combining the PISA data with district socioeconomic information represents an important novelty in the literature on the peer effect. This is possible thanks to the fact that we have information on the geolocation of the schools that participate in the PISA program. This information has been provided by the Ministry of Education and the Estado de la Educación of Costa Rica (the last, a well-known think tank on education).
In Figures 1 and 2 we observe the relationship between the academic performance of the students and the two measures of the peer effect that we use. For simplicity, we show this relationship for mathematics, but the conclusions are the same for reading and science subjects. The relationships found a coincide with our hypotheses: we hope that the socioeconomic level of the schools and the district development (less poverty and unsatisfied basic needs) positively influence school results. Figure 1 shows the mean score for each socioeconomic level (ESCS) by school. As a school's ESCS rate increases, students score higher. Figure 2 shows the poverty index by districts. There is a negative association between the poverty index and the academic performance of students.

Model and Methodology: Elaboration of the Educational Production Function
The educational production function establishes the relationship between the student's outcomes (output), and a set of student, family and school characteristics (inputs) (Deutsch et al. 2013). The literature tends to measure student performance by their scores on standard assessments. In the production function that we use, we add the input of the peer effect, which is the key variable in our study.
To obtain unbiased estimators of this effect, we use Hierarchical Linear Models or Multilevel models (HLM), commonly applied to PISA data.
This technique takes into account the nested structure of educational data set. Observations are grouped into clusters that maintain a hierarchical structure (Woltman et al. 2012). Thus, in the education sector we can consider several levels (students, classes, schools and location of schools) that interact with each other and influence school results. Most of the literature that analyses educational production functions with PISA data uses multilevel models at two levels (students and schools). In our case, we will include a third level-the geolocation of the school-when we work with district information. Fernández-Gutiérrez et al. (2020) estimate a linear hierarchical model at three levels (student, school and region) where, unlike our study, its third level refers to the Spanish Autonomous Communities. The multilevel model makes it possible to deal with unobserved heterogeneity, one of the common problems in the field.
The three-level model that we use can be expressed as: , (2) In Equation (1), is the academic performance of student enrolled in school in district . In each edition, PISA emphasizes a specific area and, in 2012, the focus was on mathematics. As an additional check, we replicate our main analysis with reading and science. and are two vectors that collect characteristics at the individual and school level, respectively. Finally, captures the peer effect. In Equation (2), and are the respective deviation of the schools' and the districts' mean from the overall mean ( ). They are assumed to be normally distributed with mean 0 and uncorrelated with . Control for school and district effects should mitigate any bias from differences that are correlated with test scores. The chosen control variables can be considered standard in educational production functions.  and Gimenez et al. (2018), in the case of Costa Rica, or Hanushek et al. (2013), which use a large sample of countries participating in PISA, make use of a similar model. Among the individual characteristics, we include gender, age and country of birth. The literature indicates that while boys score better than girls in mathematics, girls outperform boys in reading. Science scores are neutral (OECD 2013b). Age can play in favor of emotional and intellectual development and immigrant status could affect performance due to various factors, including linguistic.
Regarding family variables, we use parental education (in years), their occupation and the number of books at home, as proxies of the socioeconomic and cultural level. They are correlated to a higher level of academic performance. Among the school characteristics, we include school size (number of students enrolled at the school), school ownership, the proportion of public funding, school location, the proportion of certified teachers, the shortage of teacher in the respective area and the level of autonomy. All of them are factors that influence academic performance through available resources, their possibilities of use and the level of autonomy in their management.

Empirical Results
The empirical results found are shown below. Estimates of the peer effect in the educational production function were carried out for the three areas: mathematics (Table  2) reading (Table 3) and science (Table 4). Note: The estimates with plausible values of the PISA scores are made using PV Stata module developed by Macdonald (2014). Regressions weighted by students' sampling probability. Robust standard errors adjusted for clustering at school and district level are in parentheses. *** ρ < 0.01, ** ρ < 0.05, * ρ < 0.1.  Column (1) presents the results of the model with the control variables at two levels: students and schools. The results are consistent with previous evidence. We observe that boys score better in mathematics and science while girls do better in reading. Immigrant status is not significant. Age is significantly and positively correlated with mathematic scores, but it is not significant in reading and science. The number of books at home, parental education-except for science-and occupational status have a positive and significant relationship with academic performance. Regarding the characteristics of the school, the autonomy of the school is the only one that has a significant and positive relationship with academic performance in the three areas. The lack of significance of most school resources and characteristics is consistent with the PISA literature and has also been found by Gimenez et al. (2018) in the case of Costa Rica. As they authors point out, this must not be interpreted as meaning that schooling does not affect cognitive abilities. The little variability between school inputs may condition the statistical association found (OECD 2014b).
Column (2) of the three tables includes, in addition to the base model with the control variables, the peer effect measured through the ESCS by schools. The level of economic, social and cultural status is positively and significantly correlated with academic performance in mathematics, reading and science. The increase in one standard deviation of the peer effect, measured through the ESCS by schools, is associated with an increase of 44.05 points (43.61 * 1.01) in the academic performance in mathematics according to the PISA scale. This is comparable to 1.07 years of schooling (41 points are equivalent to one academic year). Furthermore, the PISA index is standardized so that the value for the OECD mean are zero and their standard deviation one. In turn, the mean score of the total number of students has been standardized to 500 and its standard deviation 100. It is equivalent to say that increasing the ESCS per school by one standard deviation increases academic performance in mathematics by 0.44 standard deviations. In reading and science, the results are 41.58 and 38.98 points, respectively.
It should be noted that the effect of the control variables when introducing the level of ESCS by school remains the same as in column (1) except for one. By introducing the peer effect, private schools have a negative and significant coefficient in mathematics, reading and science. This result is consistent with a previous study that Fernández and Del Valle (2013) carried out for Costa Rica. According to the authors, the gap in academic performance between private and public schools is not due so much to differences in the education provided as to socioeconomic conditions. However, the heterogeneity of results in the literature requires further research in this line of work (Zimmer and Toma 2000;Somers et al. 2004;Castro-Aristizabal et al. 2018).
Column (3) of the three tables shows the estimate at three levels, including districts. The results obtained do not vary respect to estimations at two levels (students and districts) presented to those in column (1). In column (4) we introduce the peer effect measured through the poverty index (unsatisfied basic needs) by districts. Again, the effect of the control variables when introducing the level of ESCS by school remains the same as in column (3) in the three areas. Significances are kept and the size of coefficients are similar.
With respect to our variable of study, we find that studying in schools located in districts with at least one unsatisfied basic need is negatively and significantly correlated with academic performance in mathematics, reading and science. An increase in one standard deviation of the poverty index would be accompanied by a reduction of 85.90 points (85.05 * 1.01) in the mathematics scores (the equivalent of 2.09 years of schooling). In reading and science, these results are 113.31 and 96.87 points, respectively.
Finally, we apply the quantile regression technique on the distribution of scores of the three subjects to check if these results are homogeneous throughout the distribution of scores per student. We estimate the peer effects for the 25% of students with the best and worst scores. Table 5 presents the estimates at two levels in the case of ESCS by schools and at three levels when we measured it using the poverty index by districts. Studying in schools located in districts with unsatisfied basic needs is negatively and significantly correlated with academic achievement, in mathematics and science, in the case of 25% of students with the worst performance. While studying in schools where peers have a higher level of economic, social and cultural status is positively and significantly correlated with school results, in mathematics and reading, in the case of 25% of students with better performance.

Discussion
The results found in the case of the variables included in the educational production function are consistent with those generally obtained in the empirical literature (OECD 2013b). As expected, there is a gender gap in student achievement. In Latin America, Suarez-Enciso et al. (2016) find that boys from third to sixth grade in Paraguay score more in mathematics while girls do in reading. Cervini et al. (2015) point out that the cognitive gap between boys and girls in sixteen Latin American countries remains even after controlling for socioeconomic level. Regarding school characteristics, our model confirms the importance that school autonomy has on academic performance (Machin and Vernoit 2011). This result should not be interpreted as a lack of relationship between school characteristics and academic performance. Rather, it is that school characteristics lose significance once family characteristics and the peer effect are controlled for (Coleman 1968;Hanushek 1989).
We found that higher socioeconomic status per school correlates with higher academic performance. Our results are in line with the literature (Sirin 2005). In Latin America, McEwan (2003) using data from the Chilean Ministry, finds that for each standard deviation that increased the years of maternal education, academic performance increased 0.27 standard deviations. Using data from PISA 2006 for a set of OECD countries, Raitano and Vona (2013) find that increasing the mean of the ESCS index by one standard deviation increases science performance by 25 points according to the PISA scale. The meta-analysis by Van Ewijk and Sleegers (2010) shows that, on average, academic performance increases by 0.32 standard deviations for each standard deviation that socioeconomic status increases. As we can see, the relationship that we detect is slightly higher than that obtained by the rest of the literature. The differences in the sample of countries, in the variables used to measure socioeconomic status, and the multilevel model used (which allows controlling for unobserved heterogeneity and reducing estimation biases) affect the breadth of the size that we have estimated.
We have not found any literature that uses a district poverty index in the manner proposed in this study to measure the peer effect. Therefore, it is not feasible to compare the peer effect size that we have obtained. However, we can find articles that confirm the negative relationship that exists between the poverty index and academic performance. Vigdor and Ludwig (2010) have found that the poverty level of the school district affects the academic performance of students. For China, Brown and Park (2002) or Knight et al. (2010 find that children from poorer households obtain lower test scores and are more likely to drop out of school. Finally, Gimenez et al. (2018) measure the impact of the social development of the district where the school is located on the performance of students in Costa Rica. To do this, they use an index made up of four components: health, economy, education and voter turnout. They find that students will perform better academically the greater the social development of the school district.
The results obtained on the peer effect once the quantile regression was applied, show that an environment with a higher socioeconomic level will be more beneficial, especially for the more advanced students, who will be able to get more out of it. However, other authors such as Schneeweis and Winter-Ebmer (2007) or Rangvid (2003) find that surrounding themselves with peers with a higher socioeconomic level benefits students with lower performance. We must bear in mind that these authors use a sample of developed countries (Austria the first work and Denmark the second) whose characteristics of the educational sector, levels of development and PISA results are very different from those of Costa Rican students.

Conclusions, Extensions and Recommendations in Terms of Educational Policy
Peer effects have important consequences in terms of educational equity. Students that attend the poorest schools, obtain lower educational achievements and might fall into a poverty trap that makes poverty persistent. The objective of this study was to expose this situation by estimating the link between peer effects and academic achievement of the students of Costa Rica. Two novel measures of peer effects were used: (1) a measure of schools' average socioeconomic status and (2) a measure of unsatisfied basic needs at district level.
Our results revealed how socioeconomic inequality contributes to the perpetuation of social gaps from generation to generation. Socioeconomic status of families determines the type of school that students attend and, therefore, the quality of education they receive. The hierarchical linear model, estimated at three levels, shows the importance that the peer effect, measured through socioeconomic characteristics and unsatisfied basic needs, has as a determinant of academic performance. Specifically, we find that an improvement in one standard deviation of the socioeconomic level of the schools would be equivalent to an additional year of education, two in the case of an improvement in the index of unsatisfied basic needs. These results are robust in mathematics, reading, and science. Low socioeconomic status and poverty affect particularly students with the greatest learning disabilities.
From these results, it is clear that an educational policy must be comprehensive and inclusive. That is, a policy that promotes economic equity is a policy that improves educational equity. Policy recommendations go beyond improving traditional school resources. In countries with high income inequality, policies should be implemented to reduce economic and social gaps, as well as the level of poverty. Policies should pay special attention to the population with fewer resources and cover at least their basic needs (the right to decent housing, access to education or a greater job offer that increases their purchasing power, among others). Increasing public spending on education to obtain higher school performance will be insufficient if it is not accompanied by policies that aim to improve services and infrastructure at the local level.
Conditions in the poorest districts are difficult to change in the short term, but there are several educational policies that have been adopted in Costa Rica in recent years that can improve the educational results of the vulnerable students. The Ministry of Education has developed a teacher allocation policy that seeks to encourage more experienced teachers to teach in schools situated in the most disadvantaged districts (Lentini 2019). This constitutes a good instrument to fight poverty traps. Preventing children from leaving school early, often motivated by poverty, is identified as another key instrument . We highlight the implementation of two specific programs in Costa Rica: AVANCEMOS and PROEDUCA. The first, in charge of the Mixed Institute of Social Assistance since 2006, grants transfers to students in situations of extreme poverty, conditioning the transfers to the permanence or reintegration of the student in the secondary education system. The second, launched in 2011 and funded by the Ministry of Education and the European Union, seeks to reduce student dropout in secondary education through different actions to support students, teachers, principals and the educational community in general.
All these policies must be seen as an investment to spur social well-being. Given that education contributes decisively to economic growth (Hanushek 2013), through positive externalities in technology adoption (Gimenez 2006;Barcenilla et al. 2019), innovation (López-Pueyo et al. 2018) and entrepreneurship (Van der Sluis et al. 2008), the investments made will be fully recovered in the future.
Although this article focuses on Costa Rica, the applied methodology can be extended to the analysis of other countries. Specifically, there are two lines of future research that emerge from this article. First, the scarce literature on peer effects in the region, as well as the great economic inequality among the population, encourages further research on the peer effect measured through unsatisfied basic needs. A second extension of this work could be to carry out a multi-country study. This is the first study on peer effects in Latin America that proposes to use PISA as a data source, which will allow comparisons with other studies that benefit from the analytical potential of PISA. Furthermore, our methodology is suitable for comparison between developed and developing regions, by incorporating an index common to the more than the 70 countries participating in PISA.  School's community location Refers to the community in which the school is located, such as a village, hamlet or rural area (fewer than 3000 people), a small town (3000 to about 15,000 people), a town (15,000 to about 100,000 people), a city (100,000 to about 1,000,000 people), close to the center of a city with over 1,000,000 people or elsewhere in a city with over 1,000,000 people.

PISA 2012
Proportion of fully certified teachers. Proportion of fully certified teachers. PISA 2012

Shortage of mathematics teachers
Variable built from the question "Shortage of mathematics teachers". The question used a fourpint scale distinguish the answer categories: "Not at all", "Very little", "To some extent" and "A lot".

PISA 2012
Shortage of reading teachers Variable built from the question "Shortage of reading teachers". The question used a four-point scale distinguish the answer categories: "Not at all", "Very little", "To some extent" and "A lot".

PISA 2012
Shortage of science teachers Variable built from the question "Shortage of sicence teachers". The question used a four-point scale distinguish the answer categories: "Not at all", "Very little", "To some extent" and "A lot".

PISA 2012
School Autonomy Index of school responsibility for resource allocation. Higher scores indicate higher levels of school autonomy.

PISA 2012
Economic Social Cultural Status (ESCS) Index of economic, social and cultural status consisting of three sub-components, the highest parental occupation, the highest parental education expressed as years of schooling and the index of home possessions. Higher scores indicate higher levels of economic social cultural status.

District characteristics
Poverty index (unsatisfied basic needs) Percentage of households having at least one unsatisfied basic need (in shelter, hygiene, education or consumption). Higher scores indicate higher levels of poverty.

NGI and NISC 2011
Note: NGI is National Geographic Institute and NISC is National Institute of Statistics and Censuses.