A utility for Bayesian trend regression with a variety of statistical models
Project description
ClimTrends
ClimTrends
is a python package aimed at making it easy to calculate linear
trends in a variety of statistical modesl. The current implementation
includes:
- Normal Distribution - trend in mean
- Poisson Distribution - trend in mean
- Exponential Distribution - trend in mean
- Gamma Distribution - trend in mean and standard deviation
- GEV Distribution - trend in mean
The module utilizes datetime
-like objects as the input time value, which
makes it easy to interoperate with data from
netCDF4 and
xarray. All models use a Bayesian
framework (using the emcee package) and assume
a uniform prior on all model parameters. This module is object-oriented and
designed to be easily extendable for regressions of other distributions. To do
so, one needs to sub-class the ClimTrendModel
class and implement a few
required routines; see TrendNormalModel.py
or other Trend*Model.py
files
for examples.
Getting started
# dates - a set of input dates
# data - corresponding data from those dates
import climtrends
import numpy as np
# initialize the MCMC model
linear_model = climtrends.TrendNormalModel(dates, data)
# run the sampler
linear_model.run_mcmc_sampler(num_samples = 1000)
# get samples of the slopes
slopes = linear_model.get_mean_trend_samples()
# get the 5th and 95th percentil slopes
slopes_5 = np.percentile(slopes, 5)
slopes_95 = np.percentile(slopes, 95)
Known Issues
- The install process is not finalized yet; a setup.py needs to be written.
- The model assumes that input data are vectors; things will likely break if not.
- Probably other issues exist. This code is tested and is verified to work in some base cases, but it is still in alpha stage and has not been tested across a range of settings.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for climtrends-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9ca72466f7a88edc33307a693885c0783d8ef75f3087529b9a8c400d27904ce |
|
MD5 | a3a703057d2c86329e6d40fdbd059750 |
|
BLAKE2b-256 | 52244e5e298b0fa130cb122aff9c9b0892c1c587b64d941be55807da41709b97 |