Abstract The anticipation of carbon emissions stemming from community electricity usage stands as a pivotal field of study. Such analysis holds the potential to furnish communities with informed pathways towards crafting viable carbon reduction strategies, thereby contributing significantly to the overarching goals of carbon peaking and eventual neutrality. The intricacies of carbon emissions from community electricity consumption are manifold, entangled with variables like energy consumption patterns, energy mix, and carbon emission coefficients. Hence, the imperative lies in crafting a predictive framework adept at holistically integrating these variables to enhance prognostic precision and reliability. Within this research, we propose a dynamic carbon emission factor regression model. This model is uniquely poised to capture real-time shifts influenced by changes in energy structure and policy landscapes, thereby amplifying predictive sensitivity. Leveraging the Particle Swarm Optimization (PSO) algorithm, we synchronously optimize the autoregressive terms (p) of the Autoregressive Integrated Moving Average (ARIMA) model and the moving average terms (q) of the MA model to attain a globally optimal solution. Crucially, this approach obviates the need for manual intervention and arbitrary parameter selection. In contrast to conventional optimization methodologies, our paper advances the PSO’s weight calculation mechanism. By assigning greater weight values during the initial iterations, the algorithm maintains robust global search capabilities. Subsequently, the inertia weight diminishes progressively throughout the iteration process, fostering precise local exploration.