You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
elliptical, archimedean: corr_from_tau and theta_from_tau could/should be classmethods (or static methods) so we can call them before creating an instance. That's useful if we want to set tau in __init__
elliptical t copula mixes up (spearman) rho and tau as temp variable that is returned
base Copula class has _theta_from_tau and fit_theta method. However, elliptical copulas have inconsistent method name corr_from_tau
Copula.fit_theta uses only the first two columns to compute kendalls_tau, i.e. assumes bivariate.
for elliptical we also need multivariate tau. For multivariate archimedean it would be better to use tau averaged over pairs of r.v.
We need attributes to know how many parameters and args a distribution or copula has. k_args is not necessarily the same as k_params
EV dep funcs have two or three args,
archimedean has one arg
elliptical has one args but if k_dim >2, then the arg has several params, i.e. k_params >= k_args, k_params could be k * (k -1) for triangular submatrix of corr.
in fit: k_params is needed for start_params, k_args is needed for tuple packing/unpacking (*args)
We need this for the copula parameter, but similarly for marginal distribution paramaters. In the latter case k_args = k_params
This is separate from vectorization across observations, e.g. we could have the single arg scale vectorized over observations when we have heteroscedasticity. Mean parameter will always be vectorized by obs in regression models.
It gets messier when we allow for partial constraints, e.g. restrict some parameters and leave other parameters free for estimation.
type of constraint combination
unconstrained: estimate copula and marginal distribution parameters
fixed marginal distribution parameters and estimate only copula parameters
fixed copula parameters and estimated marginal distribution parameters
all parameters fixed
Currently I only have case 2, estimate only copula parameters, working for Frank and EV. Copula.logpdf and other methods do not yet support args for marginal distributions.
more difficult will be partial constraints:
partial copula constraints, only relevant for EV (e.g. symmetry constraint) and possibly for correlation patterns in elliptical
partial constraints in marginal distributions for copula distribution, e.g. loc in R+ distribution, df in t-distribution
partial constraints in marginal model for copula regression model, depends on marginal Model.
optimization problems in EV HR: copula = ExtremeValueCopula(transform=dep.HR())
In unit tests for new CopulaModel I get optimization problems with HR or parameter estimates for marginal means are not close to true values. However, data is generated with Frank copula, We don't have rvs for EV copulas yet.
Other EV copulas have marginal means reasonably close to true values.
update found a bug the HR depfunc had hardcoded lamda=2 in the deriv.
There is only one unit test case for HR depfunc and that has lamda=2
now EV AsymLogistic has convergence failure in one test case: Frank copula with marginal normal, estimating mean and with fixed scale)
Estimating both marginal means and scale converges
missed one: unused and incomplete, conditional distribution
FrankCopula has cdfcond_2g1(u[, args]) | Conditional cdf of second component given the value of first.
ExtremeValueCopula has (with NotImplementedError) conditional_2g1(self, u, args=())
inconsistent naming
Requiring u as bivariate (2 columns) will not always make sense, e.g. when we wand to evaluate pdf or cdf for many u2 at one value of u1.
Shapes of u1 and u2 need not match for all use cases, and, I guess we better separate them.
initial usecase where we need conditional ppf is for inverse sampling (rvs using conditional ppf)
Frank is the only copula that has explicit formula for ppfcond_2g1(self, q, u1, args=()) (AFAIK, or maybe only for archimedean)
rvs for archimedean requires monotonicity (what's the name?)
i.e. only for positive correlation, not extended to negative correlation.
we might need to raise an explicit exception if condition on theta does not hold.
Archimedean generator transform has is_completly_monotonic method that returns boolean.
So far we don't handle "singular" components in copulas, i.e. we assume some kind of continuous wrt Lebesque measure.
(I never really read those details.)
Activity
josef-pkt commentedon Aug 11, 2021
specific copulas in docs
rst docs https://www.statsmodels.org/dev/distributions.html#copula should include available archimedean generators and extreme value pickands functions
dep_func_evavailable EV copulas are listed only in class docstring of ExtremeValueCopula
(*a) conditional is equal to marginal distribution
update IndependenceCompula is the new name
josef-pkt commentedon Aug 12, 2021
logpdf for Archimedean needs work
only Frank has explicit logpdf and only for dim=2 bivariate
ArchimedeanCopula class itself only supports 2-dim generically. Need more derivatives of transform function
elliptical, Gaussian, T, only define pdf, logpdf inherited from base class Copula which returns
np.log(self.pdf(u))ExtremeValueCopula uses
np.log(self.pdf(u, args=args))josef-pkt commentedon Aug 12, 2021
argshandling, args in methodsIn archimedean copulas: only Frank has
argsin methods. Other require frozen args. Estimation for copula parameter is through kendall's tau.We currently don't have any estimator for the EV Copula args.
We need an MLE model or function to estimate args in asymmetric EV copulas
two options:
fit; generic solution; we just need a helper function as wrapper.d or k_dim: need to add it consistently across copulas.
josef-pkt commentedon Aug 12, 2021
elliptical, archimedean: corr_from_tau and theta_from_tau could/should be classmethods (or static methods) so we can call them before creating an instance. That's useful if we want to set tau in
__init__elliptical t copula mixes up (spearman) rho and tau as temp variable that is returned
base Copula class has
_theta_from_tauandfit_thetamethod. However, elliptical copulas have inconsistent method namecorr_from_tauCopula.fit_thetauses only the first two columns to compute kendalls_tau, i.e. assumes bivariate.for elliptical we also need multivariate tau. For multivariate archimedean it would be better to use tau averaged over pairs of r.v.
josef-pkt commentedon Aug 13, 2021
We need attributes to know how many parameters and args a distribution or copula has.
k_argsis not necessarily the same ask_paramsEV dep funcs have two or three
args,archimedean has one
argelliptical has one
argsbut if k_dim >2, then the arg has several params, i.e. k_params >= k_args, k_params could be k * (k -1) for triangular submatrix ofcorr.in fit: k_params is needed for start_params, k_args is needed for tuple packing/unpacking (
*args)We need this for the copula parameter, but similarly for marginal distribution paramaters. In the latter case k_args = k_params
This is separate from vectorization across observations, e.g. we could have the single arg
scalevectorized over observations when we have heteroscedasticity. Mean parameter will always be vectorized by obs in regression models.It gets messier when we allow for partial constraints, e.g. restrict some parameters and leave other parameters free for estimation.
type of constraint combination
Currently I only have case 2, estimate only copula parameters, working for Frank and EV.
Copula.logpdfand other methods do not yet support args for marginal distributions.more difficult will be partial constraints:
josef-pkt commentedon Aug 17, 2021
optimization problems in EV HR:
copula = ExtremeValueCopula(transform=dep.HR())In unit tests for new CopulaModel I get optimization problems with HR or parameter estimates for marginal means are not close to true values. However, data is generated with Frank copula, We don't have rvs for EV copulas yet.
Other EV copulas have marginal means reasonably close to true values.
update found a bug the HR depfunc had hardcoded lamda=2 in the deriv.
There is only one unit test case for HR depfunc and that has lamda=2
now EV AsymLogistic has convergence failure in one test case: Frank copula with marginal normal, estimating mean and with fixed scale)
Estimating both marginal means and scale converges
josef-pkt commentedon Sep 15, 2021
missed one: unused and incomplete, conditional distribution
FrankCopula has
cdfcond_2g1(u[, args]) | Conditional cdf of second component given the value of first.ExtremeValueCopula has (with NotImplementedError)
conditional_2g1(self, u, args=())inconsistent naming
Requiring
uas bivariate (2 columns) will not always make sense, e.g. when we wand to evaluate pdf or cdf for many u2 at one value of u1.Shapes of u1 and u2 need not match for all use cases, and, I guess we better separate them.
initial usecase where we need conditional ppf is for inverse sampling (rvs using conditional ppf)
Frank is the only copula that has explicit formula for
ppfcond_2g1(self, q, u1, args=())(AFAIK, or maybe only for archimedean)josef-pkt commentedon Jan 31, 2023
another limitation
rvs for archimedean requires monotonicity (what's the name?)
i.e. only for positive correlation, not extended to negative correlation.
we might need to raise an explicit exception if condition on theta does not hold.
Archimedean generator
transformhasis_completly_monotonicmethod that returns boolean.So far we don't handle "singular" components in copulas, i.e. we assume some kind of continuous wrt Lebesque measure.
(I never really read those details.)