Title: Improves the Interpretation of the Standardized Precipitation Index Under Changing Climate Conditions
Version: 0.2.0
Description: Improves the interpretation of the Standardized Precipitation Index under changing climate conditions. The package uses the nonstationary approach proposed in Blain et al. (2022) <doi:10.1002/joc.7550> to detect trends in rainfall quantities and to quantify the effect of such trends on the probability of a drought event occurring.
License: MIT + file LICENSE
URL: https://github.com/gabrielblain/SPIChanges
BugReports: https://github.com/gabrielblain/SPIChanges/issues
Depends: R (≥ 3.5)
Imports: gamlss, gamlss.dist, lubridate, MuMIn, rlang, spsUtil, stats, brglm2, zoo
Suggests: archive, curl, doParallel, dplyr, foreach, ggplot2, grid, knitr, ncdf4, patchwork, RColorBrewer, rmarkdown, roxyglobals, sf, purrr, testthat (≥ 3.0.0), tidyr
VignetteBuilder: knitr
Config/roxyglobals/filename: globals.R
Config/roxyglobals/unique: FALSE
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
LazyData: true
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2025-06-06 11:20:34 UTC; Gabriel
Author: Gabriel Constantino Blain ORCID iD [aut, cre], Graciela R. Sobierajski ORCID iD [aut], Leticia L. Martins ORCID iD [aut], Adam H. Sparks ORCID iD [aut]
Maintainer: Gabriel Constantino Blain <gabriel.blain@sp.gov.br>
Repository: CRAN
Date/Publication: 2025-06-06 11:40:02 UTC

Daily Rainfall Amounts

Description

Daily rainfall amounts recorded in millimetre in Campinas state of Sao Paulo, Brazil.

Usage

CampinasRain

Format

CampinasRain

A dataframe with 2 columns and 16071 rows:

Date

Date

Rain

Daily rainfall amounts recorded in millimetre in Campinas state of Sao Paulo, Brazil

...

Source

https://psl.noaa.gov/


Changes in Drought Events in Brazil (1980-2024)

Description

This dataset provides the changes (in percentage) in Moderate to Extreme, Severe to Extreme, and Extreme Drought events across Brazil for the four seasons (Summer, Autumn, Winter, and Spring) over the period 1980–2024. The data were generated using the SPIChanges() function applied to rainfall data from NOAA PSL.

Usage

Map

Format

Map

A matrix with 2841 rows and 18 columns:

lon

Longitude in decimal degrees

lat

Latitude in decimal degrees

SummerModerate

Percentage change in moderate drought events in Summer

SummerSevere

Percentage change in severe drought events in Summer

SummerExtreme

Percentage change in extreme drought events in Summer

SummerModel

The selected gamma-based model in Summer

AutumnModerate

Percentage change in moderate drought events in Autumn

AutumnSevere

Percentage change in severe drought events in Autumn

AutumnExtreme

Percentage change in extreme drought events in Autumn

AutumnModel

The selected gamma-based model in Autumn

WinterModerate

Percentage change in moderate drought events in Winter

WinterSevere

Percentage change in severe drought events in Winter

WinterExtreme

Percentage change in extreme drought events in Winter

WinterModel

The selected gamma-based model in Winter

SpringModerate

Percentage change in moderate drought events in Spring

SpringSevere

Percentage change in severe drought events in Spring

SpringExtreme

Percentage change in extreme drought events in Spring

SpringModel

The selected gamma-based model in Spring

...

Source

Generated using the SPIChanges() function applied to rainfall data obtained from NOAA PSL (https://psl.noaa.gov/).


Daily Rainfall Amounts

Description

Daily rainfall data from Oxford-UK (Radcliffe Observatory). Covers the period from January 1827 to January 2020. Belongs to Burt, Stephen (2020). Daily meteorological data from the Radcliffe Observatory (now Radcliffe Meteorological Station), from January 1815: updated to January 2020. figshare. Dataset.

Usage

OxfordRain

Format

A data frame with 70523 rows and 1 column:

Rain

Precipitation in millimeters

Source

<doi.org/10.6084/m9.figshare.11956239.v1>


Detect trends and quantify their effect on the probability of SPI values occurring

Description

Detect trends and quantify their effect on the probability of SPI values occurring

Usage

SPIChanges(rain.at.TS, only.linear = "Yes")

Arguments

rain.at.TS

A 4-column matrix generated with TSaggreg(). No other objects are accepted.

  • 1st column is years (YYYY),

  • 2nd is the months (1 to 12),

  • 3rd is the quasiWeeks (1 to 4),

  • and 4th is the rainfall totals accumulated at a time scale.

only.linear

A character string value (Yes or No) defining if the function must consider only linear models (Yes) or linear and non-linear models (No). Default is Yes.

Details

The SPIChanges() function implements a nonstationary parametric approach to detect changes in precipitation patterns and assess their impact on the expected frequency of Standardized Precipitation Index (SPI) values. It evaluates 16 candidate models based on time-varying gamma distributions, which account for a broad range of linear and nonlinear changes in both the mean and dispersion of the precipitation series.

Model selection is performed using the second-order Akaike Information Criterion (AICc), and the selected model is used to compute the cumulative probability of each precipitation amount under changing climate conditions. These nonstationary probabilities are then compared with those from the original, stationary SPI algorithm to identify whether the frequency of drought events has increased or decreased over time.

For detailed explanations of the gamma-based models and the model selection procedure, please refer to the README and Vignettes included in the package.

Value

A list object with:

data.week

The Rainfall amounts, SPI, cumulative probability of the SPI values under the stationary approach, cumulative probability of the SPI values under the non-stationary approach, and the changes in the frequency of below zero SPI values caused by the changes in rainfall patterns.

model.selection

The generalized additive model that best fits the rainfall series

Changes.Freq.Drought

changes in the frequency of zero precipitation, moderate to extreme, severe to extreme and extreme drought events,as categorized by the SPI classification system, caused by the changes in rainfall patterns. Changes in the precipitation amounts associated describing normal conditions is also shown.

Statistics

Year to year changes in the expected frequency of moderate to extreme, severe to extreme and extreme drought events.

data.week

The Rainfall amounts, SPI, cumulative probability of the SPI values under the stationary approach, cumulative probability of the SPI values under the non-stationary approach, and the changes in the frequency of below zero SPI values caused by the changes in rainfall patterns.

model.selection

The generalized additive model that best fits the rainfall series

Changes.Freq.Drought

changes in the frequency of zero precipitation, moderate, severe and extreme drought events, as defined by the SPI classification system, caused by the changes in rainfall patterns. Changes in the precipitation amounts associated describing normal conditions is also shown.

Statistics

Year to year changes in the expected frequency of moderate, severe and extreme drought events.

Examples


rainTS4 <- rainTS4
Changes_SPI <- SPIChanges(rain.at.TS=rainTS4, only.linear = "yes")

Aggregates daily rainfall totals at quasi-week time scales

Description

Aggregates daily rainfall totals at quasi-week time scales

Usage

TSaggreg(daily.rain, start.date, TS = 4L)

Arguments

daily.rain

Vector, 1-column matrix or data frame with daily rainfall totals.

start.date

Date at which the aggregation should start. Preferred formats are “YYYY-MM-DD”, “YYYY/MM/DD” but most any valid date format should work.

TS

Time scale on the quasiWeek basis (integer values between 1 and 96). Default is 4, which corresponds to the monthly time scale.

Details

This package adopts a quasi-weekly time step, dividing each month into four fixed periods: days 1–7, 8–14, 15–21, and 22 through the end of the month. This approach ensures a consistent total of 48 quasi-weekly intervals per year, regardless of the selected aggregation time scale (TS). For instance, when TS = 4 (representing a one-month backward-looking window), the function computes cumulative precipitation totals over four consecutive quasi-weekly periods. This aggregation is repeated across all 48 periods of each year, generating a time series of aggregated precipitation values suitable for subsequent SPI estimation.

Value

A matrix with rainfall amounts aggregated at the time scale selected by the user

Examples


daily.rain <- CampinasRain[,2]
rainTS4 <- TSaggreg(daily.rain=daily.rain,start.date="1980-01-01",TS=4)

Coordinates for Entire Brazil

Description

This dataset provides coordinates for Brazil at a spatial resolution of 0.5 x 0.5 degrees.

Usage

lonlat

Format

lonlat

A matrix with 2841 rows and 2 columns:

lon

Longitude in decimal degrees

lat

Latitude in decimal degrees

...

Source

Data generated using information from the Instituto Brasileiro de Geografia e Estatística (IBGE). For more information, visit: https://www.ibge.gov.br/


Rainfall Aggregated at the 4-quasi week time scale

Description

Rainfall amounts aggregated using TSaggreg(). Campinas state of Sao Paulo, Brazil.

Usage

rainTS4

Format

rainTS4

A matrix with 4 columns and 576 rows:

Year

Year

Month

Month

quasiWeek

Four quasi-weekly periods in each month

rain.at.TS4

Rainfall amounts aggregated at TS equal to four

...

Source

https://psl.noaa.gov/