sbegueria / SPEI

An R package for computing the Standardized Precipitation-Evapotranspiration Index (SPEI), Penman-Monteith and other reference evapotranspiration, SPI, etc.
78 stars 34 forks source link

Problem in spei() when there are NA in the data #35

Closed sbegueria closed 2 years ago

sbegueria commented 2 years ago

As reported by email by a user:

Hi Santiago,

I’m using the SPEI R package for my research and I wanted to ask you about dealing with missing values.

I have a time series with quite a lot of missing values (see attached figure). The package seems to work fine when the scale is set to 1 (and na.rm=TRUE). However, I noticed for scales >1, the code replaces the missing values with some climatological value. Presumably the code then uses these values in the calculation as in my case, the code doesn’t produce any negative SPI values using scale=6. By definition, this shouldn’t really be possible.

If you have a fix to this problem, would you be able to kindly let me know?

Many thanks, Anna

SPI_examples
sbegueria commented 2 years ago

This has been solved in the new version of the spei() function, which is now under development (expected in release 1.8).