Population and sample
The National Survey of Student’s Drug Use (Encuesta Nacional de Consumo de Drogas en Estudiantes—ENCODE) is a national survey of urban and rural schools in Mexico, selected using stratified clustered random sampling. In 2014, ENCODE’s target population included middle (12–14 years of age) and high school students (15–17 years of age) from all the country. Strata were formed by school level (middle and high school), state (all 32 Mexican States) and nine cities (Acapulco, Tijuana and Ciudad Juarez, among others) that were of special interest. The sample frame was formed by public and private schools: 34,733 middle and 12,841 high schools, excluding those from towns with more than 60% indigenous population and some specialized schools (e.g. for migrants).
In every school, classrooms were randomly selected by systematic sampling with random start according to the average number of students per class in each level . All students in the classroom answered the questionnaire. It was not possible to conduct the survey in 61 of the selected classrooms due to safety issues in several municipalities. The response rate was 89.4%.
Data were weighted based on selection probabilities and subsequently adjusted for distribution of students by grade within each stratum. The ENCODE sample consists of 114,364 students (57,402 from middle school and 56,962 from high school). Academic performance indicators were asked only to a 25% random subsample. Hence, the sample size used for all analyses was n = 28,519; 14,435 middle school and 14,084 high school students.
Data were obtained from a self-administered questionnaire which was standardized, validated and administered in previous surveys . The questionnaire consists of a main section, answered by all participants (sociodemographic information, substance use, antisocial behavior, social environment, among others) and four extra questionnaires that were applied only to a random sample of a quarter of the students each. For this paper we analyzed the sections of sociodemographic characteristics, suicide attempts and academic performance, which were included in one of the random samples.
Lifetime suicide attempt
Based on González-Forteza’s “Parasuicide Indicator Data Sheet” (PIDS) , students where coded as suicide attempters if they: (1) responded positively to the question: “Have you ever injured, cut, poisoned or harmed yourself in order to take your life?” and, (2) gave valid answers to follow-up questions about: age at the only (or last) attempt, the motive, method and indicators of seriousness  and, (3) confirmed that they tried to “[…]hurt yourself on purpose in order to take your life?”.
For the present study, we created four variables of academic performance which have also been used in previous research [16,17,18]: (1) age inconsistency with grade level, students who reported being 2 or more years older than the expected age and year level that they were studying during the survey; (2) Not being a student in the last year, students who reported that did not attend school the previous year; (3) Perceived academic performance, which was measured with the question: “In general, how do you consider your academic performance in school?” with four possible answers: very good, good, regular and bad; (4) Number of failed courses, divided into four categories: none, one, two, and three or more.
The sociodemographic characteristics considered included sex, age, having a job most of the previous year and if it was full or part time, speaking an indigenous language, size of the locality where the student has lived most of his/her life (big, medium or small city, small town/rural community), family constellation (living with: both parents, both parents but one is a surrogate, single mother (or surrogate), single father (or surrogate) or others), mother’s (or surrogate’s) education level and father’s (or surrogate's) education level.
The school characteristics considered were the school shift (morning, afternoon and other, such as full time or extra time) and school grade (in Mexico, 7th, 8th and 9th grades are equivalents to the three grades of middle school and 10th, 11th and 12th to the three grades of high school, even though in México middle and high school are divided separately into 3 grades each).
The bivariate analysis consisted of frequencies and percentages for contingency tables with categorical variables. Comparisons between categories were conducted using the Chi square Pearson statistic, corrected for by the survey design. Statistical significance was assessed with the p value less than 0.05. Multiple logistic regression models were performed, with attempted suicide as the dependent variable, each academic performance as the main independent variable and sociodemographic characteristics and school characteristics as covariates. In the final models for either middle or high school, only variables with p < 0.20 in the bivariate models were entered as covariates. Further pairwise comparisons for significant variables with three or more categories were performed using Stata’s test command.
All statistical analyses were stratified by school level, in order to estimate associations for students in middle and high school separately. Data were analyzed in Stata version 13.1  using the module for analysis of complex surveys svy, which corrects standard errors through the Taylor series method , based on the sample design, weighting and clustering of observations.