kikocorreoso / scikit-extremes

scikit-extremes is a basic statistical package to perform univariate extreme value calculations using Python
MIT License
41 stars 10 forks source link

return level plot values #3

Closed grace-tay closed 6 years ago

grace-tay commented 6 years ago

Using the plot_return_values() function, I am able to get a great plot but is there a way to obtain the values for the confidence interval, like values for the orange and green dashed lines at a specific return period (25,50,100 years in my case)? I can get the mid with ppf() but am looking for max and min return levels.

kikocorreoso commented 6 years ago

Hi @grace-tay

I suppose you are using the classes in skextremes.models.classic. The base class in that module calculates the confidence interval for the period values between 0.1 and 500 (T = _np.arange(0.1, 500.1, 0.1)). The results of the confidence interval for this periods are used to plot the confidence interval. These values are stored in two attributes of the model named _ci_Tu and _ci_Td (for the confidence interval above and below, respectively). For instance:

import skextremes as ske
import matplotlib.pyplot as plt

data = ske.datasets.portpirie()
sea_levels = data.fields.sea_level

model = ske.models.classic.GEV(sea_levels, fit_method = 'mle', ci = 0.05,
                               ci_method = 'delta')

print(model._ci_Tu)
print(model._ci_Tu.shape)
print(model._ci_Td)
print(model._ci_Td.shape)

Will show the following output::

[       nan        nan        nan ... 5.47128789 5.47134886 5.4714098 ] 
(5000,)
[       nan        nan        nan ... 4.39293365 4.39293079 4.39292793]
(5000,)

So for T=500 years the confidence interval would be between (4.39292793, 5.4714098).

Have a look here (depending the way you chose to calculate the confidence interval):

I hope it helps.

Please, if this answers your doubt close the issue. If not just continue the conversation below :smiley: