calculate_params: Calculation of the parameters of a selected probability...

View source: R/SPI_SPEI_at_specific_day.R

calculate_paramsR Documentation

Calculation of the parameters of a selected probability distribution for all days (SPI and SPEI).

Description

Calculation of the parameters of a selected probability distribution for all days (SPI and SPEI).

Usage

calculate_params(
  Prod_data,
  scale,
  ref_start = NULL,
  ref_end = NULL,
  distribution,
  fit = "ub-pwm",
  package = "SCI",
  temporal_scale = "daily"
)

Arguments

Prod_data

”SpatRaster' object that contains spatially-distributed daily precipitation data that will be used to calculate the accumulations according a selected scale. This 'SpatRaster' must include the time that corresponds to the dates of the respective layers. They can be set with the function time of the terra package.

scale

Integer value that represents the time scale at which the SPI will be computed.

ref_start

optional value that represents the starting point of the reference period used for computing the index. The date should be introduced as '%Y-%m'. For example: "1989-02". The default is NULL, which indicates that the first layer in the 'SpatRaster' will be used as starting point.

ref_end

Optional value that represents the ending point of the reference period used for computing the index. The date should be introduced as '%Y-%m'. For example: "1989-02". The default is NULL, which indicates that the last layer in the 'SpatRaster' will be used as ending point.

distribution

Optional value indicating the name of the distribution function to be used for calculating the parameters (one of 'log-Logistic', 'Gamma' and 'PearsonIII').

fit

Optional value indicating the name of the method used for computing the distribution function parameters (one of 'ub-pwm', 'pp-pwm' and 'max-lik'). Defaults to 'ub-pwm'.

package

Either 'SCI' or 'SPEI'. Should the SCI or SPEI package be used in the implementation?

Value

This function returns the fit parameters of the selected distribution for all days. Please note that this function actively excludes the 29th of February for consistency reasons. The dates of the return 'SpatRaster' represent the days for the calculated parameters. The last year in the computation is used in the dates (in case that ref_end exist, that year is used).


obaezvil/SpatIndex documentation built on Aug. 9, 2024, 3:42 p.m.