Skip to content

mammask/droughtR

Repository files navigation

droughtR

DOI

codecov

The goal of droughtR is to enable meteorological drought monitoring by generating non-stationary drought indices under various distributional assumptions (Normal, Gamma, Zero Inflated Gamma and Weibull). It computes the stationary (SPI) and the non-stationary (NSPI) Standardized Precipitation Indices using General Additive Models for Location Scale and Shape (GAMLSS).

Installation

# Install the development version on Github
devtools::install_github("mammask/droughtR")

Usage

Generate SPI and NSPI

The function computenspi creates stationary and non-stationary meteorological drought indices at different time scales. By default, droughtR uses the gamma distribution:

# Load droughtR library
library(droughtR)
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo

# Generate synthetic monthly rainfall data using the Gamma distribution
rain = dummyrainfall(startYear = 1950, endYear = 2010)

# Compute the non-stationary standardized precipitation index (NSPI) for scale 12 using GAMLSS
nonstatdrought = computenspi(x = rain, stationaryspi = FALSE, spiScale = 12, dist = 'gamma')
#> GAMLSS-RS iteration 1: Global Deviance = 3460.033 
#> GAMLSS-RS iteration 2: Global Deviance = 3460.018 
#> GAMLSS-RS iteration 3: Global Deviance = 3460.018

# Plot NSPI
plot(nonstatdrought)

# Compute the stationary standardized precipitation index (NSPI) for scale 12 using GAMLSS and the weibull distribution
statdrought = computenspi(x = rain, stationaryspi = TRUE, spiScale = 12, dist = 'weibull')
#> GAMLSS-RS iteration 1: Global Deviance = 3545.498 
#> GAMLSS-RS iteration 2: Global Deviance = 3539.194 
#> GAMLSS-RS iteration 3: Global Deviance = 3539.143 
#> GAMLSS-RS iteration 4: Global Deviance = 3539.143

# Plot SPI 
plot(statdrought)

About

An R package for non-stationary meteorological drought monitoring

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published