ck_spi: Standardized Precipitation Index (SPI)

View source: R/drought.R

ck_spiR Documentation

Standardized Precipitation Index (SPI)

Description

Compute the SPI by fitting a parametric distribution to rolling monthly precipitation accumulations and transforming to standard normal deviates. Two distributions are supported: the two-parameter gamma (default; WMO-1090 standard) and the three-parameter Pearson III. The Pearson III tail is heavier and is preferred in arid regions where the wet-day distribution is highly skewed (Stagge et al. 2015).

Usage

ck_spi(precip, dates, scale = 3, distribution = c("gamma", "pearsonIII"))

Arguments

precip

Numeric vector of daily precipitation (mm).

dates

Date vector of the same length as precip.

scale

Integer. Accumulation period in months (default 3).

distribution

Character. Either "gamma" (default) or "pearsonIII".

Value

A data frame with columns period, value, index, and unit.

References

McKee, T. B., Doesken, N. J., & Kleist, J. (1993). The relationship of drought frequency and duration to time scales.

Stagge, J. H., Tallaksen, L. M., Gudmundsson, L., Van Loon, A. F., & Stahl, K. (2015). Candidate distributions for climatological drought indices (SPI and SPEI). International Journal of Climatology, 35(13), 4027-4040. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1002/joc.4267")}.

Examples

dates <- seq(as.Date("2020-01-01"), as.Date("2023-12-31"), by = "day")
set.seed(42)
precip <- rgamma(length(dates), shape = 0.5, rate = 0.1)
ck_spi(precip, dates, scale = 3)

climatekit documentation built on May 9, 2026, 5:08 p.m.