Provincial Solar Production Forecasts and Spatial Clustering in China

This folder contains the code and data required to reproduce the figures and tables used in the paper.

FILES

01_generate_outputs_paper.R
Main R script. It estimates provincial forecasting models, selects the best model by validation RMSE, generates forecasts up to 2029, computes provincial production shares, and applies global Moran’s I and LISA cluster analysis.

dataset_filled.xlsx
Monthly provincial solar production data. Rows correspond to months and columns correspond to Chinese provinces. The column “Month” contains the date variable.

gadm41_CHN_shp.zip
GADM provincial shapefile for China, used to construct provincial maps and spatial weights.

outputs_paper/
Output folder generated by the script.


REQUIREMENTS

The analysis was conducted in R.

Required R packages:

readxl
dplyr
tidyr
lubridate
forecast
purrr
tibble
openxlsx
ggplot2
scales
forcats
sf
spdep
patchwork

Install with:

install.packages(c(
  "readxl", "dplyr", "tidyr", "lubridate", "forecast",
  "purrr", "tibble", "openxlsx", "ggplot2", "scales",
  "forcats", "sf", "spdep", "patchwork"
))


HOW TO REPRODUCE

1. Place the following files in the same folder:

   01_generate_outputs_paper.R
   dataset_filled.xlsx
   gadm41_CHN_shp.zip

2. Open R or RStudio.

3. Set the working directory to the project folder.

4. Run:

   source("01_generate_outputs_paper.R")


EXPECTED OUTPUTS

The script creates the folder outputs_paper/ and generates:

fig1_forecast_metrics_heatmap_ranked.png
fig2_observed_forecast_best_highlighted.png
fig3_lisa_hot_cold_2017_2021_2025_2029.png
fig4_moran_combined_single_panel_2017_2021_2025_2029.png
table1_expected_growth_by_province.xlsx
table2_hotspots_coldspots_comparison.xlsx


NOTES

The script:
1. Reads monthly data
2. Fits SARIMA, ETS, Harmonic, NNAR, STLM, STL_AR
3. Validates on 2025
4. Selects best model by RMSE
5. Forecasts to 2029
6. Computes shares
7. Builds spatial weights
8. Computes Moran’s I and LISA
9. Generates figures and tables


IMPORTANT

Remove setwd() before sharing.

Check GADM license before redistribution.


LICENSE

Code: suggested MIT license
Data: depends on original source
