Skeptic priors and climate consensus
This repository contains code and data for McDermott (2021), “Skeptic priors and climate consensus”.
Abstract: How much evidence would it take to convince climate skeptics that they are wrong? I explore this question within an empirical Bayesian framework. I consider a group of stylised skeptics and examine how these individuals rationally update their beliefs in the face of ongoing climate change. I find that available evidence in the form of instrumental climate data tends to overwhelm all but the most extreme priors. Most skeptics form updated beliefs about climate sensitivity that correspond closely to estimates from the scientific literature. However, belief convergence is a non-linear function of prior strength and it becomes increasingly difficult to convince the remaining pool of dissenters. I discuss the necessary conditions for consensus formation under Bayesian learning and show that apparent deviations from the Bayesian ideal can still be accommodated within the same conceptual framework. I argue that a generalized Bayesian model provides a bridge between competing theories of climate skepticism as a social phenomenon.
Click on the green “Code” button above to clone or download the repo to your local computer. Alternately, click on the “fork” button at the very top right of the page to create an independent copy of the repo within your own GitHub account.
I use Make to automate the entire project. Assuming that you have installed Make and have met all of the other dependencies — see below — the TL;DR version for reproducing everything is:
## Run these commands in the shell git clone firstname.lastname@example.org:grantmcdermott/skeptic-priors.git cd skeptic-priors make
You can also limit the build to subsections of the project by passing Make a relevant meta target, e.g.
make datawill construct the dataset
make mainwill run the main analysis
make sensitivitywill run all of the sensitivity analyses
make paperwill build the paper PDF and SM
See the Makefile to get a sense of the options. The associated DAG is here (warning: it’s complicated).
While the entire project can be reproduced via a single call to
users must first satisfy various software dependencies. There are two
Step 1. Install R and R libraries
The majority of the analysis is conducted in the R programming environment. R is free, open-source and available for download here. The code has been tested against R version 4.0.2.
Once R is successfully set up on your system, you will need to install a number of external R libraries. I have used renv to snapshot the project’s R environment. To install all of the necessary R libraries, simply open R at the project root (e.g. by clicking on the .Rproj file) and run the following commands:
## Run these commands in R # renv::init() ## Only necessary if you didn't clone/open the repo as an RStudio project renv::restore(confirm = FALSE)
Step 2. Install CmdStan
The workhorse Bayesian regressions for this project are passed from R to CmdStan. This enables the Bayesian MCMC computation to complete much, much faster than it would otherwise. While R and CmdStan are two separate programs, the easiest way to install the latter is from the former. Assuming that you have completed Step 1 above, run the following line from your R console:
## Run this command in R cmdstanr::install_cmdstan(version = "2.25.0", cores = 2)
Step 3: Install Julia and Julia libraries
While most of the analysis is conducted in R, I use Julia (version 1.5.0) for the social cost of carbon calculations. Julia too is free, open-source and available for download here.
This section of code relies primarily on the
package, which is itself part of the Mimi
integrated assessment models in Julia. You will first need to register
the Mimi family of models with your Julia installation before installing
the necessary packages. Simply open up a Julia terminal at the root
level of the project (i.e. where the
Project.toml file is located) and
type in the following:
## Run these commands in Julia using Pkg ## Or hit "]" to enter the Pkg REPL directly Pkg.Registry.add("General") ## Likely redundant, but just in case Pkg.Registry.add(RegistrySpec(url = "https://github.com/mimiframework/MimiRegistry.git")) Pkg.activate(".") Pkg.instantiate() Pkg.precompile() ## Optional exit() ## Optional
The above code chunk will activate and then instantiate the project’s Julia environment, pulling in all of the necessary package versions.
Step 4. Optional(ish)
I use a tiny bit of Python code to extract some IDL ‘save’ data as part of the raw data prep process. Assuming that you have cloned my repo as-is and did not delete any of the data files, Make will automatically skip this section and the Python requirement will be moot. Failing that, however, you will need SciPy’s File IO module. Regular Python users will almost certainly have SciPy installed on their system already. If not, you can install it yourself, e.g. with PyPi or Conda. I strongly recommend that R users go through reticulate (see here). FWIW, I am using Python 3.8.5 and SciPy 1.5.1 at the time of writing.
extrafontpackage is used to embed Fira Sans fonts in the figures. Please note that the Fira Sans font family must be installed separately on your system and also requires some minor setup before R recognizes it (instructions here). However, you can also skip this setup if you want; R’s default Arial fonts will be used if Fira Sans is unavailable.
For those of you who don’t feel like configuring a manual setup, I also provide a Dockerfile that will automatically bundle all of the dependencies and copy across the project files. To build the Docker image locally:
## Run these commands in the shell # cd skeptic-priors ## Only if you aren't already in the project root docker build --tag skeptic:1.0.0 .
This will take a couple of minutes to pull in all of the necessary R and Julia packages, compile CmdStan etc. But, thereafter, the now-built container will be ready and waiting for immediate deployment whenever you want. Run it with:
docker run -it --rm skeptic:1.0.0
You should see something like:
You should now be able to run all of the regular Make commands on the
make paper, etc.), run the individual R scripts (in
R/ subdir), or generally explore as you wish.
To stop the container, just type
Aside 1: Running
make in the Docker container will generate a
bunch of warning messages to the effect of “warning: overriding recipe
for target ‘&’”. This is because the Ubuntu OS on the container is
running an older version of Make (version 4.2 vs 4.3). It’s a bit
annoying, but should be harmless.
Aside 2: If you don’t want to work with (ephemeral) project files that were copied over to the container during the build process, but would rather mount the local version of the project (i.e. the files on your computer that you cloned from GitHub) as an external volume, you are obviously free to do so.
If you are totally unfamiliar with Docker and want to know more, I have a brief tutorial with additional resources here.
The code has been refactored to run all the Bayesian computation through CmdStan. This has yielded considerable speed gains, to the point that the entire analysis can be completed in under 30 minutes on my Dell Precision 5530 laptop.1 The table below provides a detailed performance record for the different model runs. Note that I am excluding the data preparation and paper production steps, but each of these only takes a few seconds.
|Run||File||Time (sec)||Cores used||RAM||OS||Architecture|
||29.69||12||31||Arch Linux||x86_64-pc-linux-gnu (64-bit)|
||163.82||12||31||Arch Linux||x86_64-pc-linux-gnu (64-bit)|
||497.80||12||31||Arch Linux||x86_64-pc-linux-gnu (64-bit)|
|Alternative GMST series (sensitivity)||
||6.62||12||31||Arch Linux||x86_64-pc-linux-gnu (64-bit)|
|Anthrogenic forcings separate (sensitivity)||
||8.11||12||31||Arch Linux||x86_64-pc-linux-gnu (64-bit)|
|Adjusted forcings efficacies (sensitivity)||
||461.60||12||31||Arch Linux||x86_64-pc-linux-gnu (64-bit)|
|Measurement error in forcings (sensitivity)||
||442.32||12||31||Arch Linux||x86_64-pc-linux-gnu (64-bit)|
|Measurement error in GMST (sensitivity)||
||7.41||12||31||Arch Linux||x86_64-pc-linux-gnu (64-bit)|
If you have any trouble running the code, or find any errors, please file an issue on this repo and I’ll look into it.
The software code contained within this repository is made available under the MIT license. The data and figures are made available under the Creative Commons Attribution 4.0 license.
1 Previous versions of the code took a whole
day to complete on a cloud server. So you’ll understand my being pleased
by this improvement.