Maximum Likelihood Estimation on High Order Statistics
In this notebook, we perform an analysis of time series data using the xtremes library. We utilize various estimators and statistical methods provided by the library to analyze and visualize the data.
The following variables are used in this notebook:
PWM: A
PWM_estimatorsobject used for Probability Weighted Moments estimation.MLE: A
ML_estimatorsobject used for Maximum Likelihood estimation.
[1]:
import xtremes as xx
import xtremes.topt as hos
[2]:
TS = hos.TimeSeries(n=1000, modelparams=(0.5,0.1,0.1))
TS.simulate(rep=200)
TS.get_blockmaxima(block_size=10)
Probability Weighted Moments (PWM) Estimation
In this section, we perform Probability Weighted Moments (PWM) estimation on the time series data. The PWM_estimators object is used for this purpose. Below are the steps involved:
Initialization:
python PWM = hos.PWM_estimators(TS)We initialize thePWM_estimatorsobject with the time series dataTS.PWM Estimation:
python PWM.get_PWM_estimation()This method computes the PWM estimates for the given time series data.Statistics Calculation:
python PWM.get_statistics(gamma_true=0)This method calculates the statistics based on the PWM estimates. Here,gamma_trueis the true value of the shape parameter used for comparison.Confidence Intervals:
python PWM.get_CIs()This method computes the confidence intervals for the PWM estimates.View Statistics:
python PWM.statisticsThis attribute holds the computed statistics, which can be accessed for further analysis or visualization.
[3]:
PWM = hos.PWM_estimators(TS)
PWM.get_PWM_estimation()
PWM.get_statistics(gamma_true=0.5)
PWM.get_CIs()
PWM.statistics
[3]:
{'gamma_mean': np.float64(0.47088517659996376),
'gamma_variance': np.float64(0.016709443122544267),
'gamma_bias': np.float64(0.029187884552301573),
'gamma_mse': np.float64(0.017561375727182752),
'mu_mean': np.float64(0.5376701999751607),
'mu_variance': np.float64(0.0016648680442634886),
'sigma_mean': np.float64(0.31970439731541317),
'sigma_variance': np.float64(0.002098583464247386),
'gamma_CI': array([0.26048308, 0.7876679 ]),
'mu_CI': array([0.47036141, 0.63408314]),
'sigma_CI': array([0.24961966, 0.41783512])}
Plotting the distribution of the optained estimators together with a symmetrical CI is as easy as:
[4]:
PWM.plot()
The same works analogously for MLE. We use the PWM estimators as an initial guess for otimization. Instead of symmetrical CIs (default) we can also plot CIs with minimal width
[5]:
MLE = hos.ML_estimators(TS)
MLE.get_ML_estimation(PWM_estimators= PWM)
MLE.get_statistics(gamma_true=0)
MLE.get_CIs(method='minimal_width')
MLE.plot()
/home/docs/checkouts/readthedocs.org/user_builds/xtremes/envs/latest/lib/python3.10/site-packages/scipy/optimize/_optimize.py:836: RuntimeWarning: invalid value encountered in subtract
np.max(np.abs(fsim[0] - fsim[1:])) <= fatol):
Maximum Likelihood Estimation (MLE) with Frechet Distribution
In this section, we perform Maximum Likelihood Estimation (MLE) using the Frechet distribution on the time series data. The Frechet_ML_estimators object is used for this purpose. Below are the steps involved:
Initialization:
python MLE = hos.Frechet_ML_estimators(TS)We initialize theFrechet_ML_estimatorsobject with the time series dataTS.MLE Estimation:
python MLE.get_ML_estimation(PWM_estimators= PWM)This method computes the MLE estimates for the given time series data using the PWM estimators as initial guesses for optimization.Statistics Calculation:
python MLE.get_statistics(alpha_true=0)This method calculates the statistics based on the MLE estimates. Here,alpha_trueis the true value of the shape parameter used for comparison.Confidence Intervals:
python MLE.get_CIs()This method computes the confidence intervals for the MLE estimates.View Statistics:
python MLE.plot()This method plots the distribution of the obtained estimators together with the confidence intervals.
Difference between Frechet and GEV Distributions
The key difference between using the Frechet distribution and the Generalized Extreme Value (GEV) distribution lies in the type of tail behavior they model:
Frechet Distribution: This distribution is used to model data with heavy tails. It is a special case of the GEV distribution with a positive shape parameter. The Frechet distribution is particularly useful for modeling extreme values that follow a power-law decay.
GEV Distribution: The GEV distribution is a more general form that encompasses three types of distributions based on the shape parameter: Gumbel (light tails), Frechet (heavy tails), and Weibull (bounded tails). The GEV distribution provides more flexibility in modeling different types of extreme value behavior.
By using the Frechet_ML_estimators, we specifically focus on modeling heavy-tailed data, which is suitable for certain types of extreme value analysis.
[6]:
MLE = hos.Frechet_ML_estimators(TS)
MLE.get_ML_estimation(PWM_estimators= PWM)
MLE.get_statistics(alpha_true=0)
MLE.get_CIs()
MLE.plot()