# Readability Formulas for Elementary School Texts in Mexican Spanish
## 3 Methodology
### Readability Formula Based on Linear Regression  
This section presents the initial readability formula proposed in this study, developed using a linear regression approach. The objective is to develop a transparent, interpretable model that maps textual features to elementary grade-level difficulty, in a manner consistent with traditional readability metrics. Emphasis is placed on maintaining simplicity, enabling practical application in educational settings, and facilitating direct comparison \begin{table}
\begin{tabular}{l l l} \hline \hline
**Readability Scale** & **Mexican Elementary Grade Levels** & **Readability Levels** \\ \hline
100 & 1 st grade & Very easy \\
80 & 2 nd grade & Easy \\
60 & 3 rd grade & Relatively easy \\
40 & 4 th grade & Standard \\
20 & 5 th grade & Relatively difficult \\
0 & 6 th grade & Difficult \\ \textless{}0 & 7 th grade or higher & Very difficult \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Adapted readability levels based on the point-based scale proposed in this work. with established formulas, which are predominantly linear combinations, occasionally involving ratios of features. To align with the simplicity of widely used readability formulas (see Section 2), conventional features based on counts of syllables, words, and sentences to assess text readability were considered. These features were extracted using the NLTK library, along with supplementary Python modules, which enabled the tokenization of texts into syllables, words, and sentences while adhering to Spanish grammatical conventions. The analyzed features include the total number of words (\(W\)), letters (\(L\)), sentences (\(S\)), syllables (\(Y\)), polysyllabic words (\(P\)), average sentence length (\(ASL=W/S\)), average syllables per word (\(ASW=Y/W\)), and average letters per word (\(x_{L}=L/W\)). These features were initially selected to ensure consistency with established readability formulas and to maintain interpretability, facilitating comparison across methods. To explore the relationships among these variables, a correlation matrix heatmap was generated, as shown in Figure 1. This visualization highlights a strong linear correlation among \(W\), \(L\), \(S\), \(Y\), and \(P\), which are naturally interrelated due to the structure of written language. Interestingly, \(ASL\) exhibits the highest linear correlation with the grade level. Building on these insights, new combinations and interaction terms among variables were introduced, including polynomial features to capture nonlinear relationships, to identify the most effective subset of variables. This involved fitting separate regression models for all possible combinations of variables and selecting the subset that minimized the mean squared error (MSE). Although the computational time complexity of ordinary least squares (OLS) regression is \(O(up^{2}+p^{3})\), where \(n\) is the number of observations and \(p\) the number of variables [31], the exhaustive nature of the subset selection process increases exponentially with the number of variables. However, given the relatively limited number of features considered in this study, this approach remained computationally feasible. In line with the hierarchical principle, all main effects associated with any interaction terms were retained during the selection process. Following feature selection, a series of linear regression models were then developed and evaluated based on their MSE, using the proposed point-based scale. These models were trained using only 60% of the corpus, in accordance with the division outlined in Section 4. The models were fitted using OLS, with data manipulation and regression performed via Python libraries such as pandas, scikit-learn, and statsmodels. Figure 1: Correlation matrix heatmap of the textual features. The heatmap uses a diverging colormap: red tones represent positive correlations (up to 1), blue tones represent negative correlations (down to \(-1\)), and white indicates no correlation (0). Deeper color intensity reflects stronger correlation values.