Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore alternative fitting procedure for SPEI #1477

Closed
1 task done
coxipi opened this issue Sep 12, 2023 · 2 comments
Closed
1 task done

Explore alternative fitting procedure for SPEI #1477

coxipi opened this issue Sep 12, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@coxipi
Copy link
Contributor

coxipi commented Sep 12, 2023

Generic Issue

Currently, SPEI relies on an offset to shift the water budget to positive values for zero-bounded statistical distributions. The offset was currently hardcoded as in the monocongo/climate_indices library : 1mm/d.

This can be insufficient, as seen in #1474 where a greater shift was needed.

There was already some plan to let this offset parameter available to user as an argument in SPEI function #1311.

scipy has a parameter loc that could be used to remove the arbitrariness of the offset used. However, if a certain loc is computed, I'm not sure how things will go (there might be NaNs in the final output SPEI) for a dataset with smaller (negative) values of the water budget outside of the calibration period.

The R library has a SPEI function, as far as I can tell, there is not an offset parameter in this case. I will explore alternative ways to get SPEI values

Code of Conduct

  • I agree to follow this project's Code of Conduct
@coxipi coxipi self-assigned this Sep 12, 2023
@Zeitsperre Zeitsperre added this to the v0.49.0 milestone Feb 13, 2024
@Zeitsperre Zeitsperre added the enhancement New feature or request label Feb 13, 2024
@coxipi
Copy link
Contributor Author

coxipi commented Feb 15, 2024

Just to confirm: loc is indeed used to generalize the support of the distribution from [0,∞] to [loc, ∞]

https://stackoverflow.com/questions/68948202/negative-observations-for-scipy-stats-gamma-fit

The paper introducing SPEI uses the three-parameter distribution of log-logistic (the two-parameter version only has support on positive values, where loc is the third parameter ). I think we should just go with this way of proceeding unless I find important issues (only one I can think of is: what happens when min(all data) < loc < min(calibration data) , I should check this.

RondeauG added a commit to hydrologie/xhydro that referenced this issue May 14, 2024
<!-- Please ensure the PR fulfills the following requirements! -->
<!-- If this is your first PR, make sure to add your details to the
AUTHORS.rst! -->
### Pull Request Checklist:
- [x] This PR addresses an already opened issue (for bug fixes /
features)
  - This PR fixes #xyz
- [x] (If applicable) Documentation has been added / updated (for bug
fixes / features).
- [x] (If applicable) Tests have been added.
- [x] CHANGES.rst has been updated (with summary of main changes).
- [x] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added.

### What kind of change does this PR introduce?

* Tests for the GIS module were too strict.
* Changes were made in `xclim v0.49.0` with how the `gamma` and `fisk`
distributions were initiated in `xclim`, which changed the fitting
results and parametric quantiles. It just so happened that we
arbitrarily used the `gamma` for our tests. To be backwards-compatible,
those tests were changed to the `gumbel_r`.

### Does this PR introduce a breaking change?

- No.

### Other information:
Changes to the `gamma` distribution:
Ouranosinc/xclim#1477
Ouranosinc/xclim#1720
@coxipi
Copy link
Contributor Author

coxipi commented Jun 11, 2024

closing, this has been dealt with in #1720

@coxipi coxipi closed this as completed Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants