Clayton and Gumbel Copula Error
Working with Gumbel and Clayton Copula with weather dataset produces the following error for some set of variables.
Clayton Error
ValueError Traceback (most recent call last)
~\Anaconda3\envs\copulas_env\lib\site-packages\copulas\bivariate\base.py in fit(self, X) 182 raise ValueError("Constant column.") 183 raise ValueError("Unable to compute tau.") --> 184 self._compute_theta() 185 186 def to_dict(self):
~\Anaconda3\envs\copulas_env\lib\site-packages\copulas\bivariate\base.py in _compute_theta(self) 163 """Compute theta, validate it and assign it to self.""" 164 self.theta = self.compute_theta() --> 165 self.check_theta() 166 167 def fit(self, X):
~\Anaconda3\envs\copulas_env\lib\site-packages\copulas\bivariate\base.py in check_theta(self) 126 if (not lower <= self.theta <= upper) or (self.theta in self.invalid_thetas): 127 message = 'The computed theta value {} is out of limits for the given {} copula.' --> 128 raise ValueError(message.format(self.theta, self.copula_type.name)) 129 130 def check_fit(self):
ValueError: The computed theta value -0.6795841166551324 is out of limits for the given CLAYTON copula
Gumbel Copula
ValueError Traceback (most recent call last)
~\Anaconda3\envs\copulas_env\lib\site-packages\copulas\bivariate\base.py in fit(self, X) 182 raise ValueError("Constant column.") 183 raise ValueError("Unable to compute tau.") --> 184 self._compute_theta() 185 186 def to_dict(self):
~\Anaconda3\envs\copulas_env\lib\site-packages\copulas\bivariate\base.py in _compute_theta(self) 163 """Compute theta, validate it and assign it to self.""" 164 self.theta = self.compute_theta() --> 165 self.check_theta() 166 167 def fit(self, X):
~\Anaconda3\envs\copulas_env\lib\site-packages\copulas\bivariate\base.py in check_theta(self) 126 if (not lower <= self.theta <= upper) or (self.theta in self.invalid_thetas): 127 message = 'The computed theta value {} is out of limits for the given {} copula.' --> 128 raise ValueError(message.format(self.theta, self.copula_type.name)) 129 130 def check_fit(self):
ValueError: The computed theta value 0.6602079416724338 is out of limits for the given GUMBEL copula.
Hello, I am having a similar error to this - @dorcasgicuku did you come to a solution? Details of my problem are below:
Environment Details
Copulas version: 0.9.0 Python version: 3.8.8 (iPython environment in Spyder) Operating System: Windows
Error Description
Fitting Bivariate Gumbel copula returns ValueError
Steps to reproduce
from copulas.bivariate import Bivariate
# Format data
copula_arr=np.array([x,y]).T
# Initialise the copula
copula=Bivariate(copula_type='gumbel')
# Fit the copula to the extremes
copula.fit(copula_arr)
Please note that x and y are on uniform margins as required. Please see histograms of x and y below.
Error
Traceback (most recent call last):
File "C:\Users\admin\AppData\Local\Temp\ipykernel_15604\3537192975.py", line 1, in <module>
run_solar_earth_bi_eva.phi_d_vs_ae()
File "C:\Users\admin\Documents\wind_waves_akr_code\run_solar_earth_bi_eva\run_solar_earth_bi_eva.py", line 680, in phi_d_vs_ae
bs_copula_arr.append(fit_copula_to_extremes.fit_copula_bivariate(bs_phid_um, bs_ae_um, 'phi_d', 'AE'))
File "C:\Users\admin\Documents\wind_waves_akr_code\bi_multi_variate_eva\fit_copula_to_extremes.py", line 61, in fit_copula_bivariate
copula.fit(copula_arr)
File "C:\Users\admin\anaconda3\lib\site-packages\copulas\bivariate\base.py", line 186, in fit
self._compute_theta()
File "C:\Users\admin\anaconda3\lib\site-packages\copulas\bivariate\base.py", line 167, in _compute_theta
self.check_theta()
File "C:\Users\admin\anaconda3\lib\site-packages\copulas\bivariate\base.py", line 130, in check_theta
raise ValueError(message.format(self.theta, self.copula_type.name))
ValueError: The computed theta value 0.9601028214324197 is out of limits for the given GUMBEL copula.
Experimenting, the Gumbel copula has a theta range of 1-inf:
from copulas.bivariate import Bivariate
copula=Bivariate(copula_type='gumbel')
print(copula.theta_interval)
out: [1, inf]
Given that I'm inputing data on uniform margins, why is the copula fitting the data in a way that's out of bounds? Please note that I have also used this same copula from this package without errors.
Thanks, Alexandra
Just to note I came to a solution on this. Essentially the data I was putting in to copula.fit was not related as it should be. Essentially x and y were almost independent, and hence the fitting was not a success.
Hence I'm not sure if this is a bug. If that's the case, it could be helpful to make the error message more verbose if possible! Thanks, Alexandra