In the following code, i am trying to evaluate the parameters of a gumbel distribution using PyMC3.
The data is annual_maxima_1 and the method works for MLE but i could not make any conclusions regarding the results of PyMC3.
Any suggestions. ?? with the code below.
import numpy as np
from scipy.stats import gumbel_r
import pymc3 as pm
import arviz as az
#%% #1. Data
annual_maxima_1 = np.array([5.41,6.89,6.10,5.72,7.91,10.45])
#%%frequentistic statistics
#%using MLE methods for parameter estimation
#fitting the gumbel distribution
loc1, scale1 = gumbel_r.fit(annual_maxima_1)
mean, var, skew, kurt = gumbel_r.stats(loc=loc1, scale=scale1,moments=‘mvsk’)
#%%now doing bayesian using Pymc3
#%%
with pm.Model() as model:
# Define the prior of the parameter lambda.
mu = pm.Uniform(‘mu’)
beta=pm.Uniform(‘beta’)
You probably did not mean mu and beta to be pm.Uniform('mu', lower=0, upper=1) which are the default parameters if you just use pm.Uniform('mu'). If you want a non informative prior you should use pm.Flat, or increase the lower and upper bounds of pm.Uniform to include any plausible values.
thanks for the reply .
Thanks for pointing that out, i am considerably new to the PyMC3 environment/code/syntax but not to bayesian.
I can make two different analysis,
1-Non informative
2-with uniform distribution
Please check if the following code is correct for the two cases.
1-Non informative
mu = pm.Flat(‘mu’)
beta=pm.Flat(‘beta’)
2-with uniform distribution
mu = pm.Uniform(‘mu’, lower=0, upper=10)
beta=pm.Uniform(‘beta’, lower=0, upper=5)
I guess you got my original idea, i am i trying to fit distribution parameters(mu, beta) for Gumbel given data.
Feel free to make further suggestion, thanks for the reply .
I have a groundwater level, which apply force on the structure.
A lot of research indicates that maximum yearly water levels can be modelled as gumbel distribution.
I have some maximum values from last 6 years.
I want to fit these 6 or some more values/data to find the parameters of the underlining gumbel distribution.