% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drought.R
\name{ck_spei}
\alias{ck_spei}
\title{Standardized Precipitation-Evapotranspiration Index (SPEI)}
\usage{
ck_spei(precip, pet, dates, scale = 3, distribution = c("log-logistic", "gev"))
}
\arguments{
\item{precip}{Numeric vector of daily precipitation (mm).}

\item{pet}{Numeric vector of daily potential evapotranspiration (mm).}

\item{dates}{Date vector of the same length as \code{precip} and \code{pet}.}

\item{scale}{Integer. Accumulation period in months (default 3).}

\item{distribution}{Character. Either \code{"log-logistic"} (default,
Vicente-Serrano et al. 2010) or \code{"gev"} (Generalised Extreme
Value, fitted by L-moments; preferred for water-balance series
with heavy upper or lower tails).}
}
\value{
A data frame with columns \code{period}, \code{value}, \code{index}, and \code{unit}.
}
\description{
Compute the SPEI by fitting a log-logistic distribution to the monthly
climatic water balance (precipitation minus potential evapotranspiration)
accumulated over a rolling window.
}
\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)
pet <- rep(3, length(dates))
ck_spei(precip, pet, dates, scale = 3)
}
\references{
Vicente-Serrano, S. M., Begueria, S., & Lopez-Moreno, J. I.
(2010). A multiscalar drought index sensitive to global warming: the
Standardized Precipitation Evapotranspiration Index. \emph{Journal of Climate},
23(7), 1696-1718.
}
