# Regional Geomagnetic Field Modeling Based on Associated Legendre Polynomials
## 3 Data and Modeling Results
### Regional Geomagnetic Anomaly Field Model Construction
Thus, the 83 rd degree was selected as the optimal truncation level of the R\(-\)ALPOLM in this study, and post-processing of the predicted outliers was performed on this basis to enhance the performance of the model. Traditional approaches to handling boundary effects typically involve adding boundary data points to control errors, thereby enhancing the fitting degree of the model and overcoming boundary issues. However, when constructing a model, measured data are considered the most reliable. Artificial interpolation--which involves generating synthetic  
Figure 3: Distribution of outliers in the R\(-\)ALPOLM at different degrees, with ‘x’ symbols representing outliers: (**a**) Distribution of 85 th degree model outliers. (**b**) Distribution of 104 th degree model outliers. Figure 2: Determination of the optimal truncation level for the R\(-\)ALPOLM: (**a**) Relationship between the number of outliers and RMSE with truncation level. (**b**) Determination of the optimal truncation level for the R\(-\)ALPOLM. data based on measured values for use as training data--can introduce unnecessary errors. These errors vary depending on the distribution density of the measured data, leading to a certain level of error during the initial stages of model construction. The data presented in Table 2 indicate the overall RMSE after removing the prediction outliers. The results indicate that the overall prediction accuracy of the model remained high after excluding the predicted outliers, and the RMSE decreased with increasing truncation level. Furthermore, through the selection of an appropriate truncation level, the number of prediction outliers can be limited to a smaller proportion of the total number of checkpoints. Consequently, including significant predicted outliers in the evaluation of model accuracy to determine the truncation level is not ideal, as it does not accurately reflect the prediction performance of higher-degree models. In light of this, this study does not focus on the original observations when addressing boundary effects but, instead, employs a strategy of post-processing the abnormal predicted values at the boundaries based on the model to enhance the overall prediction performance. This approach aims to reduce the negative impacts of boundary effects on model performance through optimizing the prediction mechanism within the model to achieve more accurate prediction results. Outlier detection was performed using the box plot method, which visualizes the distribution of raw geomagnetic data by dividing the dataset into four equal parts based on three quartiles: the lower quartile (Q1), the median (Q2), and the upper quartile (Q3). Specifically, Q1 separates the lowest 25% of the data, Q2 (the median) divides the data into two equal halves, and Q3 marks the boundary below which 75% of the data falls. This division effectively partitions the dataset into four distinct segments, each representing 25% of the data, ordered from the smallest to largest values. The difference between the upper and lower quartiles is known as the Interquartile Range (IQR). Values greater than the upper quartile by 1.5 times the IQR or smaller than the lower quartile by 1.5 times the IQR are typically classified as outliers when detecting predicted outliers using the box-and-line plot method. This method is highly robust as the IQR is less affected by outliers. The moving average is a widely used statistical technique in data analysis and time series forecasting. Its primary purpose is to minimize randomness by smoothing data to better extract trend features. For regional geomagnetic data, which typically exhibit continuity, outlier prediction can be performed by applying the moving average method to smooth the predicted data values of surrounding points (N points of radius d). This approach enables the re-prediction of outliers. To address predicted outliers in a dataset \(\{M_{i}|1,2,\ldots m\}\), the following steps can be taken:  
Step 1: Compute the upper quartile \(Q_{3}\) and the lower quartile \(Q_{1}\).