The Standardized Precipitation Drought Evapotranspiration Index (SPEI) requires a Di term of the difference between precipitation and potential evapotranspiration (PET) on a weekly or monthly basis. I have Di for my 17-year time series, where each day of the time series represents ~1,000,000 30x30 meter squares in a city.
The formula for SPEI is attached and is straightforward. This should be easy to calculate in Matlab. W is -2ln(P), and P is 1-F(x). I don't understand how to calculate F(x). I read that to calculate F(x) I could fit the log-logistic distribution to the Di time series, but when I tried in Matlab this didn't work due to negative values (which are common since Di is Precipitation-PET).
Since the whole purpose of the math I attached is to standardize Di, would it be appropriate for me to detrend the time series and then to find the z-score? I could do that very quickly.
Any input on how to calculate F(x) would be appreciated.
http://spei.csic.es/home.html