**Background:** Rice is the staple food for approximately 160 million people in Bangladesh, and the rice subsector contributes about 4.5% to the national GDP. Accurate forecasting of rice production is critical for food security, administrative planning, and economic stability. While traditional time series models like ARIMA have been widely used for agricultural forecasting, machine learning methods such as eXtreme Gradient Boosting (XGBoost) have shown promise in recent years. This study aimed to compare the predictive accuracy of ARIMA and XGBoost models for annual rice production in Bangladesh and to forecast production for the next 10 years using the better-performing model.
**Methods:** Annual rice production data from 1961 to 2020 (60 years) were obtained from FAOSTAT. The data were split into training (90%) and test (10%) sets. The ARIMA model was developed using the 'auto.arima' function in R, with model selection based on the lowest Corrected Akaike Information Criterion (AICc). Stationarity was assessed using the Augmented Dickey Fuller (ADF) test, and Box-Cox transformation was applied to stabilize variance. The XGBoost model was built using the 'forecastxgb' package, with tuning parameters adjusted iteratively. Up to eight time-lagged variables were used as input features. Model performance was evaluated using four error metrics: mean absolute error (MAE), mean percentage error (MPE), root mean square error (RMSE), and mean absolute percentage error (MAPE).
**Key Results:** The ADF test confirmed the data were non-stationary at level (p-value = 0.57) but became stationary after first-order differencing (p-value = 0.01). The optimal ARIMA model was ARIMA(0,1,1) with drift (AICc = 201.54), where the drift parameter (0.62942, p < 0.001) indicated a significant upward trend. For the training set, the ARIMA model achieved MAE = 1,109,886, MPE = -0.30%, RMSE = 1,496,325, and MAPE = 4.55%. The XGBoost model showed higher training errors: MAE = 2,817,876, MPE = -5.91%, RMSE = 3,209,634, and MAPE = 10.39%. However, on the test set, the XGBoost model outperformed ARIMA across all metrics: MAE = 2,779,742 (vs. 3,755,137 for ARIMA), MPE = -5.39% (vs. -7.23%), RMSE = 3,195,985 (vs. 4,093,961), and MAPE = 5.38% (vs. 7.23%). Feature importance analysis revealed that lag 5 of the training data contributed most to the XGBoost model's predictions. Based on the superior test set performance, the XGBoost model was used to forecast annual rice production for 2021–2030, predicting values ranging from 57,850,318 tons in 2021 to 82,256,944 tons in 2030.
**Clinical Implications:** This study is not a clinical investigation. However, the findings have significant implications for public health and nutrition policy in Bangladesh, where rice provides two-thirds of caloric intake and half of protein intake. Accurate production forecasts can inform food security planning, import/export decisions, and price stabilization policies that directly affect the nutritional status of 160 million people. The demonstrated superiority of XGBoost over ARIMA suggests that machine learning approaches should be adopted by government agencies and development practitioners for agricultural forecasting. The predicted increase in rice production over the next decade may help alleviate food insecurity, though the study did not account for climate variables (temperature, rainfall) or economic factors that could affect actual production outcomes.