License: | GPL (≥ 3) |
Title: | (Precipitation) Frequency Analysis and Variability with L-Moments from 'lmom' |
Type: | Package |
Description: | It is an extension of 'lmom' R package: 'pel...()','cdf...()',qua...()' function families are lumped and called from one function per each family respectively in order to create robust automatic tools to fit data with different probability distributions and then to estimate probability values and return periods. The implemented functions are able to manage time series with constant and/or missing values without stopping the execution with error messages. The package also contains tools to calculate several indices based on variability (e.g. 'SPI' , Standardized Precipitation Index, see https://climatedataguide.ucar.edu/climate-data/standardized-precipitation-index-spi and http://spei.csic.es/) for multiple time series or spatially gridded values. |
Version: | 0.6.7 |
Date: | 2025-08-01 |
Repository: | CRAN |
Depends: | R(≥ 3.0.1),lmom,stringr |
Suggests: | SPEI |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-08-25 06:54:09 UTC; ecor |
Date/Publication: | 2025-08-25 07:50:08 UTC |
Author: | Emanuele Cordano |
Maintainer: | Emanuele Cordano <emanuele.cordano@gmail.com> |
Generic function for cdf...
: probability distribution fitting with L-Moments.
Description
These functions compute value(s) of cumulated probability or SPI-like (normal standardize) index from a sample or time series of x
.
Usage
cdf(
para,
x,
probability_distribution_attrname = "probability_distrib",
indices = NULL,
return.as.spi = FALSE,
spi.scale = NA,
distrib = NA,
...
)
spi.cdf(x, para, ...)
cdf.spi(x, para, ...)
Arguments
x , para , ... |
L-moments and further parameters for |
probability_distribution_attrname |
attribute name for probability distribution |
indices |
vector of string working as factors or indices, e g. the month names or similar. It must be of the same length of |
return.as.spi |
logical parameter. Default is |
spi.scale |
integer value or |
distrib |
character string indicating the probability distribution, it can be used in case |
Value
A vector of cumulated probability value(s) or SPI-like Gaussianized values. It is a list of vectors in case of several probability parametric distribution functions (i.e. para
is a list and length(para)>1
).
See Also
pel
,cdfexp
,cdfgam
,cdfgev
,cdfglo
,
cdfgpa
,cdfgno
,cdfgum
,cdfkap
,cdfln3
,cdfnor
,cdfpe3
,cdfwak
,cdfwei
Examples
# Sample L-moments of Ozone from the airquality data
data(airquality)
lmom <- samlmu(airquality$Ozone,nmom=6)
distrib <- c("exp","gam","gev","glo","gpa","gno","gum","kap",
"ln3","nor","pe3","wak","wei")
para_list <- pel(distrib=distrib,lmom=lmom)
cdf_list <- cdf(para=para_list,x=airquality$Ozone)
cdf_gam <- cdf(para=para_list$gam,x=airquality$Ozone)
cdf_gam2 <- cdf(para=para_list$gam,x=airquality$Ozone,distrib="gam")
if (any(cdf_gam!=cdf_gam2,na.rm=TRUE)) stop("Any possible errors after 0.6.3 package updates!")
## Comparison with the SPI/SPEI algorithms: 'SPEI::spi' ('SPEI' package)
if (requireNamespace("SPEI",quietly = TRUE)) {
library(SPEI)
data(wichita)
distrib_wichita <- 'pe3'
spi.scale <- 1
month_wichita <- sprintf("M%02d",wichita$MONTH)
para_whichita <- pel(x=wichita$PRCP,indices=month_wichita,distrib=distrib_wichita,
spi.scale=spi.scale)
spi_wichita <- spi.cdf(x=wichita$PRCP,indices=month_wichita,para=para_whichita,
spi.scale=spi.scale)
spi_wichita_speipkg <- spi(data=wichita$PRCP,distrib='PearsonIII',scale=spi.scale)
difference <- spi_wichita-spi_wichita_speipkg$fitted
}
Generic function for pel...
Description
Generic function for pel...
: probability distribution fitting with L-Moments
Usage
pel(
distrib = c("exp", "gam", "gev", "glo", "gpa", "gno", "gum", "kap", "ln3", "nor",
"pe3", "wak", "wei"),
lmom = NULL,
probability_distribution_attrname = "probability_distrib",
x = NULL,
nmom = 5,
sort.data = TRUE,
ratios = sort.data,
trim = 0,
indices = NULL,
spi.scale = NA,
correction = NULL,
...
)
pel_x(x, ...)
pel_lmom(lmom, ...)
Arguments
distrib |
character string indicating the probability distribution to fit |
lmom , ... |
L-moments and further parameters for |
probability_distribution_attrname |
attribute name for probability distribution |
x |
vector containg sample. It is utiled to calculete L-moments in case |
nmom , sort.data , ratios , trim |
arguments for |
indices |
optional index or tag character vector of the same length of |
spi.scale |
integer value or |
correction |
numeric value correction for the 3rd (and higher) L-moment estimation. Default is |
Details
pel_x
and pel_lmom
are wrapper functions of pel
whose first argument is x
or lmom
respectively.
Value
A numeric vector containing the parameters of the selected probability distribution. It is a list in case of selection of several probability distributions (i.e. length(distrib)>1
).
See Also
pel...
,pelexp
,pelgam
,pelgev
,pelglo
,pelgpa
,
pelgno
,pelgum
,pelkap
,pelln3
,pelnor
,
Examples
# Sample L-moments of Ozone from the airquality data
data(airquality)
lmom <- samlmu(airquality$Ozone,nmom=6)
distrib <- "gev"
# Fit a GEV distribution
out_gev <- pel(distrib=distrib,lmom=lmom)
distrib <- c("exp","gam","gev","glo","gpa","gno","gum","kap","ln3",
"nor","pe3","wak","wei")
out_list <- pel(distrib=distrib,lmom=lmom)
Generic function for qua...
: probabilily distribution fitting with L-Moments
Description
Generic function for qua...
: probabilily distribution fitting with L-Moments
Usage
qua(
para,
f,
probability_distribution_attrname = "probability_distrib",
distrib = NA,
...
)
Arguments
f , para , ... |
L-moments and further parameters for |
probability_distribution_attrname |
attribute name for probability distribution |
distrib |
character string indicating the probability distribution, it can be used in case |
Value
A vector of quantiles. It is a list of vectors of quantiles in case of several probability parametric distribution functions (i.e. para
is a list and length(para)>1
).
See Also
pel
,quaexp
,quagam
,quagev
,quaglo
,quagpa
,quagno
,quagum
,
quakap
,qualn3
,quanor
,quape3
,
quawak
,quawei
Examples
# Sample L-moments of Ozone from the airquality data
data(airquality)
lmom <- samlmu(airquality$Ozone,nmom=6)
distrib <- c("exp","gam","gev","glo","gpa","gno","gum","kap","ln3","nor",
"pe3","wak","wei")
para_list <- pel(distrib=distrib,lmom=lmom)
f <- (1:10)/10
qua_list <- qua(para=para_list,f=f)
qua_gam <- qua(para=para_list$gam,f=f)
qua_gam2 <- qua(para=as.vector(para_list$gam),f=f,distrib="gam")
if (any(qua_gam!=qua_gam2,na.rm=TRUE)) stop("Any possible errors after 0.6.3 package updates!")