I understand that you are encountering a warning while using the “gpfit” function to calculate the return period. The issue arises when the shape parameter “K” of the Generalized Pareto distribution is estimated to be less than “-1/2”, which can lead to unreliable confidence intervals and standard errors.
The warning typically occurs when the input data contains small values or when the initial parameter estimates are poor. To resolve this, I recommend the following:
- Ensure that your input data is positive and adheres to the assumptions of the Generalized Pareto distribution. Negative or zero values can cause the fitting process to fail.
- You can manually provide initial estimates for the shape and scale parameters when calling the “gpfit” function, which may help the algorithm converge to a more reliable solution.
Here is a sample code that addresses the issue:
params = gpfit(data, 0.5, 0.5);
warning('Shape parameter K is less than -1/2, which may lead to unreliable results.');
returnPeriod = 1 / (1 - (1 - 1e-3)^(1/K));
disp(['Return period: ', num2str(returnPeriod)]);
This approach should resolve the warning you are seeing. By filtering out non-positive values and adjusting the initial parameters, you should get more reliable estimates.
For more information on the “gpfit” function and the Generalized Pareto distribution, please refer to the following documentation:
I hope this helps!