https://github.com/climateimpactlab/energy-code-release-2020
Supplemental material for "Estimating a Social Cost of Carbon for Global Energy Consumption" (Rode et al., 2021) https://doi.org/10.1038/s41586-021-03883-8.
https://github.com/climateimpactlab/energy-code-release-2020
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 4 DOI reference(s) in README -
○Academic publication links
-
✓Committers with academic emails
7 of 12 committers (58.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.7%) to scientific vocabulary
Keywords
Repository
Supplemental material for "Estimating a Social Cost of Carbon for Global Energy Consumption" (Rode et al., 2021) https://doi.org/10.1038/s41586-021-03883-8.
Basic Info
Statistics
- Stars: 8
- Watchers: 13
- Forks: 5
- Open Issues: 7
- Releases: 0
Topics
Metadata Files
README.md
About
This repo contains the code and instructions for producing the results in: Rode, A., Carleton, T., Delgado, M. et al. Estimating a social cost of carbon for global energy consumption. Nature 598, 308–314 (2021). https://doi.org/10.1038/s41586-021-03883-8
Requirements For Using Code In This Repo
You need to have
python,Stata, andRprogramming capabilities, or at least environments to run code in these languages, on your computer.We use
condato managepythonenrivonments, so we recommend installingcondaif you haven't already done so following these instructions.
Setup
Clone the following repos to a chosen directory, which we'll call
yourREPOfrom now onwards, with the following commands:cd <yourREPO> git clone https://github.com/ClimateImpactLab/energy-code-release-2020.gitInstall the
condaenvironment included in this repo by running the following commands under the root of this repo:
cd <yourREPO>/energy-code-release-2020
conda env create -f energy_env_py3.yaml
Try activating the environment: ``` conda activate energyenvpy3
``
Please remember that you will need to activate this environment whenever you run python scripts in this repo, including thepip install -e .` commands in the following section.
Also, you need to install Jupyter for the scc calculation code ``` conda install -c conda-forge jupyterlab
```
- (You can skip this step if you do not want to run the impact projections on your own. This does not affect your ability of running other scripts, like regression or plotting code.) Clone
impact-calculations,open-estimateandimpact-commonintoyourREPOand install using the following commands (Note: You'll need to activate theenergy_env_py3environment to install the repos):
```
cd
git clone https://github.com/ClimateImpactLab/open-estimate.git cd open-estimate pip install -e . cd ..
git clone https://github.com/ClimateImpactLab/impact-common.git cd impact-common pip install -e . cd .. ```
Install the R packages needed using the following command from the root of this repo:
cd <yourREPO>/energy-code-release-2020 Rscript install_R_packages.RDownload data from
https://doi.org/10.5281/zenodo.5099834and unzip it somewhere on your machine with 50GB+ space. Let's call this locationyourDATA.Set up a few environmental variables so that all the code runs smoothly.
On Mac, you can do this by appending the following lines to your ~/.bash_profile.
First, do: ``` nano ~/.bash_profile
```
Then, point the variable DATA in the yourDATA dierctory in the downloaded data, and do the same for OUTPUT. Point the REPO variable to yourREPO path used above containing this repo and other repos by adding the following lines to .bash_profile:
```
export REPO=
``
Save and exit.
Then, runsource ~/.bash_profile` to load the changes we just made.
On Windows or other operation systems, please search how to add environmental variables.
- This repo is tested with Stata/SE, and currently using the
stata-secommand to run stata scripts. If you're using other versionsof stata, please mass replace all occurences ofstata-se -bin this repo withstata-mp -borstata -baccording to the version of your stata. If you're promptedcommand not foundwhen trying to runstatacommands from the console, installstata(console)for your machine according to stata official documentation that is available online.
One source that should work is section C.4.2 of https://www.stata.com/manuals16/gsm.pdf.
- Setup for the whole repo is done, thanks for your patience! Now please follow the
READMEs in each subdirectory to run each part of the analysis. In general, each directory will come with a.shbash script which you can use./path_to_bash_script.shto run scripts in that subdirectory. If you encounter the permission denied error, usechmod +x path_to_bash_script.shto make it runnable.
The Social Cost of Global Energy Consumption Due to Climate Change
The analysis in the paper proceeds in five steps.
- Historical data on energy consumption and climate are cleaned and merged, along with other covariates needed in our analysis (population and income).
- Econometric analysis is conducted to establish the energy-temperature empirical relationship.
- This relationship is used to project future impacts of climate change using an ensemble of climate models
- Note: this step is exceptionally computationally intensive, and while we share all the code needed for producing all outputs in ther paper, releasing all the data is currently not possible due to the large size of the data, so you will not be able to run everything.
- These impacts are translated into empirical “damage functions” relating monetized damages to warming
- Damage functions are used to compute an energy-only partial social cost of carbon.
This master readme outlines the process for each step, and each analysis step has it’s own readme and set of scripts in a subdirectory.
Description of folders
0_make_dataset - Code for constructing the dataset used to estimate all models described and displayed in the paper
1_analysis - Code for estimating and plotting all econometric models present in the paper
2_projection - Code for projection the impact of climate change to 2300
3_post_projection - Code for producing figures for the paper
4_misc - Code for producing additional figures and numbers for the paper
projection_inputs - Files needed to run projections
Step 1 - Historical Energy Consumption and Climate Dataset Construction
Data construction is a multi-faceted process. We clean and merge data on energy consumption from the International Energy Agency's (IEA) World Energy Balances dataset, historical climate data from the Global Meterological Forcing Dataset (GMFD), and income and population data from the IEA.
In Part A, we construct data on final consumption of electricity and other fuels, covering 146 countries annually over the period 1971 to 2010.
In Part B, we construct data on historical climate to align with the geographic and temporal definitions used in the energy final consumption dataset.
In Part C, we clean data on population and income of each country-year in our data.
In Part D, we clean and merge together data produced in each of the previous parts, and output an intermediate merged dataset.
In Part E, we prepare merged data for econometric analysis.
Part 1.A - Final Consumption Energy Data
- Data on energy consumption were obtained from the International Energy Agency's (IEA) World Energy Balances dataset.
- This dataset is not public, and not provided in this repository.
- From this raw data, we construct a country-year-product level panel dataset (where product is either electricity or other_energy).
- Due to data quality concerns, we incorporate information on data consistency and quality from the IEA's documentation into this dataset.
- Details of this can be found in Appendix Section A.1, and in the 0makedataset/coded_issues folder of this repo.
- This allows us to determine which data should be dropped, to contruct a set of fixed effects and FGLS weights to help deal with data quality concerns, and assemble climate data that reflects the geographic and temporal definitions used to report energy consumption data.
Part 1.B - Historical Climate Data
- We take Historical Climata Data on daily average temperature and precipitation from the Global Meteorological Forcing Dataset v1 (GMFD) dataset.
- The raw GMFD data are at the 0.25 x 0.25 degree gridded resolution. We link climate and energy con-
sumption data by aggregating gridded daily temperature data to the country-year level
using a procedure detailed in Appendix A.2.4 that preserves nonlinearity in the energy
consumption-temperature relationship.
- This step is highly computationally intensive, and the code for this step is not currently provided in this repo.
- In addition to temperature and precipitation measures, we also calculate other climate measures, such as cooling and heating degree days.
- We then clean these data, so that they match the observations present in our energy consumption data.
- More documentation of the cleaning process can be found in 0makedataset/climate
Part 1.C - Population and income data
- We obtain historical values of country-level annual income per capita from within the International Energy Agency's World Energy Balances dataset, which in turn sources these data from the World Bank.
- Cleaning steps undertaken on these variables can be found in 0makedataset/popandincome
Part 1.D - Merge energy final consumption, historical climate, population and income data
- As the final part of our dataset construction, we merge all of the data together.
- Codes used in this step can be found in 0makedataset/merged
Part 1.E - Clean merged data for econometric analysis
- Motivated by tests that showed that our outcome variable has a unit root, we construct first differenced versions of our variables for use in later econometric analysis.
- To nonlinearly model income heterogeneity in the energy-temperature response, we construct an income spline variable. We decide on knot location based on in sample income deciles.
- Lastly to plot 3 x 3 arrays displaying the interacted model (Methods Equation 1), we save a dataset with information on average income and climate in different terciles of the in sample data.
Outputs of Step 1
- Step 1 produces datasets ready to run regressions on, and datasets used in later plotting analysis. These can be found in
yourDATA. Specifically,- Part 1.D produces
<yourDATA>/DATA/regression/IEA_Merged_long_GMFD.do-- an intermediate dataset used to construct the final analysis dataset - Part 1.E produces:
<yourDATA>/regression/GMFD_*_regsort.dta-- the analysis dataset used inStep 2<yourDATA>/regression/break_data_*.dta-- a dataset used for plotting 3 x 3 arrays
- Part 1.D produces
- Within Step 1, we produce two figures that are used in the paper:
- Figure Appendix A.1:
fig_Appendix-A1_ITA_other_fuels_time_series_regimes.pdf- This figure is used to visualise the persistent shocks present in energy consumption.
- Figure Appendix A.2:
fig_Appendix-A2_Unit_Root_Tests_p_val_hists_*.pdf- These figures are used to visualise the distribution of p-values for unit root tests for within regime energy consumption.
- Figure Appendix A.1:
Step 2 - Econometric Analysis to Establish Energy-Temperature Empirical Relationship
This step implements analysis to recover the emprical relationship between temperature and energy consumption. In this step, we take the cleaned data produced in step 1, run regressions and then plot the resulting outputs.
We run three kinds of regressions in this section:
1. Uninteracted global regressions (Appendix Equation C.1)
* These regressions recover the global population weighted average response of energy consumption to temperature variation.
* Code for these regressions can be found in 1analysis/uninteractedregression
* This code outputs:
* ster files for both the first stage and the FGLS regression: FD_global_TINV_clim.ster and FD_FGLS_global_TINV_clim.ster, respectively
* Appendix Figure C1: fig_Appendix-B1_product_overlay_TINV_clim_global.pdf
2. Decile regressions (Appendix Equation C.3)
* These regressions are run in order to understand how the sensitivity of energy consumption to climate change modulates with income levels.
* Code for these regressions can be found in 1analysis/decileregression
* This code outputs:
* ster files for both the first stage and the FGLS regression: FD_FGLS_income_decile_TINV_clim.ster and FD_FGLS_income_decile_TINV_clim.ster, respectively
* Figure 1A: fig_1A_product_overlay_income_decile_TINV_clim.pdf
3. Interacted regressions (Appendix Equations C.4, I.1)
* In these regressions, we model heterogeneity in the energy-climate relationship, by interacting our models with income and climate covariates.
* Code for these regressions can be found in 1analysis/interactedregression
* This code outputs:
* Ster files for the first stage and the FGLS regression for the main (TINV_clim), the excluding imputed data (TINVclimEX), and temporal trend (TINVclimlininter) models:
* FD_inter_*.ster and FD_FGLS_inter_*.ster
* The following paper and appendix figures:
* Figures 1C: fig_1C_*_interacted_TINV_clim*.pdf
* Appendix Figures I2: fig_Appendix-G2_*_interacted_main_model_TINV_clim_overlay_model_EX*.pdf
* Appendix Figures I3A: fig_Appendix-G3A_ME_time_TINV_clim_lininter_*.pdf
* Appendix Figures I3B: fig_Appendix-G3B_*_interacted_main_model_TINV_clim_overlay_model_lininter.pdf
Step 3 - Project Future Impacts of Climate Change
In this stage of our analysis, we take the coefficients identified in Step 2, and use them to project future impacts on energy consumption due to climate change.
Running code for in this step is highly computationally intensive. Therefore, we are including the inputs from our analysis that would allow a user to run this step and code to run an example projection for one climate and socileconomic scenario, but we are also providing the outputs of this step that are required for further analysis as stand-alone .csv files.
Step 4 - Estimate Empirical Damage Function
In this stage, we take the projected future impacts found in step 3, and use them to construct an empirical damage function.
As part of this process, we first plot a selection of the projection system outputs, in order to help us understand the spatial and temporal patterns implied by our projections. Codes for this part of our analysis are contained in 3postprojection/1visualiseimpacts.
- These codes output take in outputs extracted from the projection system outputs. See readme in Step 3 for more details.
- They produce:
- Figure 2A:
fig_2A_*_impacts_map.png. These maps show the spatial distribution of the projected impacts of climate change on energy consumption by fuel types, in the year 2099. We also show the response functions associated with selected impact regions, both historically and in our 2099 projection (fig_2A_city_response_functions_2015_and_2099.pdf). - Figure 2B:
fig_2B_*_consumption_compared_to_2099_impact_bars.pdf, which shows how projected impacts for certain countries compare to their current consumption. - Figure 2C:
fig_2C_*_time_series.pdf, which shows aggregated global time series of our projected impacts by fuel type and RCP, with uncertainty. - Figure 3
/fig_3/.: Figures in this folder present visualisations of monetized damages, combined across fuel types. We present a map of the damages, to highlight the spatial distribution, with visualisations of uncertainty for selected impact regions (Figure 3A). We also show an aggregated time series showing total projected damages by year as percent of global gdp (Figure 3B). The damage functions in Figure 3C are produced by code in damage function estimation. - Appendix figures including
- Appendix Figure C3:
/fig_Appendix-C3_sample_overlap_present_future/. - Appendix Figure D1:
fig_Extended_Data_fig_5_global_total_energy_timeseries_all-prices-rcp*.pdf - Appendix Figure H1:
fig_Appendix-H1_SSP3-high_rcp85-total-energy-price014-damages_by_inc_decile.pdf - Appendix Figure I1:
fig_Appendix-G1_Slow_adapt-global_*_timeseries_impact-pc_CCSM4-SSP3-high.pdf - Appendix Figure I3.C:
fig_Appendix-G3_lininter-global_*_timeseries_impact-pc_SSP3-high-rcp85.pdf
- Appendix Figure C3:
- Figure 2A:
We then use the global damages implied by our projections to construct damage functions. Code for estimating these damage functions is contained in 3postprojection/2damagefunction_estimation.
- This code plots visualisations of our damage functions in the year 2099 for electricity, other fuels, and total energy priced using our price014 price scenario, that are shown in the paper as:
- Figure 3C:
fig_3C_damage_function_*_2099_SSP3.pdf - The code also outputs damage function coefficients for each price scenario, and quantile regression coefficients.
- Appendix Figure E1:
fig_Appendix-E1_total_energy_damage_function_evolution_SSP3-price014.pdf
- Figure 3C:
- This code plots visualisations of our damage functions in the year 2099 for electricity, other fuels, and total energy priced using our price014 price scenario, that are shown in the paper as:
Step 5 - Compute Energy-Only Partial Social Cost of Carbon
In the final step of the analysis, we use the empirically derived damage function to calculate an energy-only, partial social cost of carbon.
Code for this step is contained in 3postprojection/3_SCC. This code takes in the damage function coefficients generated in Step 4, and outputs SCC values.
This code outputs all SCC values used in the tables in the paper.
We are planning to add code that computes the uncertainty of these SCC values, but that is not currently in this repo.
Owner
- Name: Climate Impact Lab
- Login: ClimateImpactLab
- Kind: organization
- Email: info@impactlab.org
- Website: https://impactlab.org
- Twitter: impact_lab
- Repositories: 77
- Profile: https://github.com/ClimateImpactLab
A team of scientists, economists and engineers measuring the real-world costs of climate change.
GitHub Events
Total
- Fork event: 1
Last Year
- Fork event: 1
Committers
Last synced: about 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Ruixue Lui | l****e@s****u | 226 |
| Ruixue Li | r****i@E****l | 221 |
| Ruixue Li | l****e@u****u | 198 |
| Maya Norman | m****n@u****u | 119 |
| TomBearpark | 4****k | 106 |
| “Your | t****k@g****m | 105 |
| Ruixue Lui | l****e@b****u | 45 |
| Tom Bearpark | t****k@s****u | 14 |
| aarode | 3****e | 14 |
| Ashwin | a****e@u****u | 10 |
| Brewster Malevich | b****h@r****m | 1 |
| Tom Bearpark | t****k@b****u | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: about 2 years ago
All Time
- Total issues: 9
- Total pull requests: 10
- Average time to close issues: 18 days
- Average time to close pull requests: about 2 months
- Total issue authors: 1
- Total pull request authors: 3
- Average comments per issue: 0.89
- Average comments per pull request: 0.9
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: 18 days
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- TomBearpark (9)
Pull Request Authors
- ruixue-li (7)
- TomBearpark (2)
- davidrzhdu (1)