Skip to content

mathause/dist_cov

Repository files navigation

Distributions with covariates

DOI

Authors: Mathias Hauser1, Dominik Schumacher1, Sonia I. Seneviratne1

1Institute for Atmospheric and Climate Science, Department of Environmental Systems Science, ETH Zurich, Zurich, Switzerland

Conditional distributions with covariates

⚠️ Warning: this package does currently not have any tests.

Approach

We use distributions where one (or more) parameter is dependent on a covariate - e.g. the global mean temperature ($T_{glob}$). for the normal distribution model the mean ($\mu$) and standard deviation ($\sigma$) as follows:

$\mu' = \beta_0 + \beta_1 * T_{glob}$

$\sigma' = \sigma$

As no such distribution is available in python we adapt distributions in scipy (e.g. scipy.stats.norm).

Markov chain Monte Carlo (MCMC) sampler

The parameter uncertainty is estimated with emcee - an MCMC sampler - see dist_cov.sample.run_mcmc. Also check it's website for a good overview. Of course any other MCMCM sampler can be used as well.

I usually describe this as follows: "We calculate uncertainties in a Bayesian setting and use a Markov Chain MonteCarlo (MCMC) sampler that is affine-transformation invariant (Goodman & Weare, 2010; Foreman-Mackey et al., 2013) to estimate the parameters of the distributions. Starting from non-informative* priors, the converged posterior distributions (50,000** non-independent samples) give an estimate of the parameteruncertainty.

* Not all priors are non-informative (i.e. when setting a constrain in dist_cov.distributions.gev_cov)!

** This is n_walker * production in dist_cov.sample.run_mcmc

Installation

Dependencies

dist_cov depends on the python packages emcee, numpy, and scipy. To run the examples corner.py, matplotlib, and xarray are required as well.

Install development version

dist_cov is not available from pypi or conda-forge, therefore it needs to be installed using pip directly from github.

pip install git+https://github.com/mathause/dist_cov

To run the examples also install:

pip install corner matplotlib xarray

Install latest released version

Go to the newest release on github, copy the URL of the *.tar.gz source file at the botton and then use pip to install it (i.e., pip install ...).

Documentation

Documentation is sparse, but check the examples.

Citing dist_cov

Please cite Hauser et al. (2017) or 10.5281/zenodo.7922001 if you are using dist_cov.

If you use emcee also consider citing Foreman-Mackey et al. (2013) and/ or Goodman & Weare (2010).

History

This code was originally developed for Hauser et al. (2017) based on the approach described in Coles (2001; Chapter 3). It has been employed in several rapid attribution studies under the auspices of the world weather attribution group, namely:

  • Siberian heatwave of 2020 (Ciavarella et al., 2020 and Ciavarella et al., 2021)
  • Western North American heat wave of 2021 (Philip et al., 2021 and Philip et al., 2022)
  • Indian heat wave of 2022 (Zachariah, et al., 2022 and Zachariah et al., in review)
  • UK heatwave of 2022 (Zachariah et al. 2022)
  • Northern Hemisphere droughts of 2022 (Schumacher et al., 2022 and Schumacher et al., in review)

It further builds the starting point for modelling extremes in MESMER-X (Quilcaille et al., 2022).

Changelog

See CHANGELOG.md.

License

This project is published under a MIT license.

References

  • Ciavarella, A., Cotterill, D., Stott, P., ... Hauser, M., et al. Prolonged Siberian heat of 2020 almost impossible without human influence. Climatic Change 166, 9 (2021). https://doi.org/10.1007/s10584-021-03052-w
  • Coles, S. (2001), An Introduction to Statistical Modeling of Extreme Values, vol. 208, Springer, London.
  • Foreman-Mackey, D., Hogg, D. W., Lang, D., & Goodman, J. (2013). emcee: The MCMC hammer.Publications of the Astronomical Society ofthe Pacific,125, 306–312. https://doi.org/10.1086/67006
  • Goodman, J., & Weare, J. (2010). Ensemble samplers with affine invariance.Communications in Applied Mathematics and ComputationalScience,5(1), 65–80. https://doi.org/10.2140/camcos.2010.5.6
  • Hauser, M., Gudmundsson, L., Orth, R., Jézéquel, A., Haustein, K., Vautard, R., van Oldenborgh, G.J., Wilcox, L. and Seneviratne, S.I. (2017), Methods and Model Dependency of Extreme Event Attribution: The 2015 European Drought. Earth's Future, 5: 1034-1043. https://doi.org/10.1002/2017EF000612
  • Philip, S. Y., Kew, S. F., van Oldenborgh, G. J., Anslow, F. S., Seneviratne, S. I., Vautard, R., Coumou, D., Ebi, K. L., Arrighi, J., Singh, R., van Aalst, M., Pereira Marghidan, C., Wehner, M., Yang, W., Li, S., Schumacher, D. L., Hauser, M., Bonnet, R., Luu, L. N., Lehner, F., Gillett, N., Tradowsky, J. S., Vecchi, G. A., Rodell, C., Stull, R. B., Howard, R., and Otto, F. E. L.: Rapid attribution analysis of the extraordinary heat wave on the Pacific coast of the US and Canada in June 2021, Earth Syst. Dynam., 13, 1689–1713, https://doi.org/10.5194/esd-13-1689-2022, 2022.
  • Quilcaille, Y., Gudmundsson, L., Beusch, L., Hauser, M., & Seneviratne, S. I. (2022). Showcasing MESMER-X: Spatially resolved emulation of annual maximum temperatures of Earth System Models. Geophysical Research Letters, 49, e2022GL099012. https://doi.org/10.1029/2022GL099012

About

conditional distributions with covariates

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages