0
$\begingroup$

this is univariate distribution

dist= ProbabilityDistribution[{"CDF", (1 -  E^-(\[Lambda]*x))^\[Alpha]}, {x, 0, \[Infinity]},Assumptions -> {\[Lambda] > 0, \[Alpha] > 0}];

this is data

data = {74, 57, 48, 29, 502, 12, 70, 21, 29, 386, 59, 27, 153, 26, 326}

i used this code to get parameters

 mle = FindDistributionParameters[data, dist, ParameterEstimator -> "MaximumLikelihood"]

and used this code to get -L

LogLikelihood[dist, data] /. mle

how i do it with this bivariate copula distribution and data to get this results

dist1= ProbabilityDistribution[{"CDF", (1 -  E^-(\[Lambda]*x))^\[Alpha]}, {x, 0, \[Infinity]},Assumptions -> {\[Lambda] > 0, \[Alpha] > 0}];
dist2= ProbabilityDistribution[{"CDF", (1 -  E^-(\[Lambda]*x))^\[Alpha]}, {x, 0, \[Infinity]},Assumptions -> {\[Lambda] > 0, \[Alpha] > 0}];

bidist = CopulaDistribution[{"FGM",\[Gamma]}, {dist1, dist2}];


data = {{2, 6.5}, {2, 6.5}, {2.1, 10.1}, {2.2, 7.2}, {2.2, 7.6}, {2.2,
 7.9}, {2.2, 8.5}, {2.2, 9.1}, {2.2, 9.6}, {2.2, 9.6}, {2.2, 
10.7}, {2.3, 9.6}, {2.4, 7.3}, {2.4, 7.9}, {2.4, 7.9}, {2.4, 
9.1}, {2.4, 9.3}, {2.5, 7.9}, {2.5, 8.6}, {2.5, 8.8}, {2.5, 
8.8}, {2.5, 9.3}, {2.5, 11}, {2.5, 12.7}, {2.5, 12.7}, {2.6, 
7.7}, {2.6, 8.3}, {2.6, 9.4}, {2.6, 9.4}, {2.6, 10.5}, {2.6, 
11.5}, {2.7, 8}, {2.7, 9}, {2.7, 9.6}, {2.7, 9.6}, {2.7, 
9.8}, {2.7, 10.4}, {2.7, 11.1}, {2.7, 12}, {2.7, 12.5}, {2.8, 
9.1}, {2.8, 10}, {2.8, 10.2}, {2.8, 11.4}, {2.8, 12}, {2.8, 
13.3}, {2.8, 13.5}, {2.9, 9.4}, {2.9, 10.1}, {2.9, 10.6}, {2.9, 
11.3}, {2.9, 11.8}, {3, 10}, {3, 10.4}, {3, 10.6}, {3, 11.6}, {3, 
12.2}, {3, 12.4}, {3, 12.7}, {3, 13.3}, {3, 13.8}, {3.1, 
9.9}, {3.1, 11.5}, {3.1, 12.1}, {3.1, 12.5}, {3.1, 13}, {3.1, 
14.3}, {3.2, 11.6}, {3.2, 11.9}, {3.2, 12.3}, {3.2, 13}, {3.2, 
13.5}, {3.2, 13.6}, {3.3, 11.5}, {3.3, 12}, {3.3, 14.1}, {3.3, 
14.9}, {3.3, 15.4}, {3.4, 11.2}, {3.4, 12.2}, {3.4, 12.4}, {3.4, 
12.8}, {3.4, 14.4}, {3.5, 11.7}, {3.5, 12.9}, {3.5, 15.6}, {3.5, 
15.7}, {3.5, 17.2}, {3.6, 11.8}, {3.6, 13.3}, {3.6, 14.8}, {3.6, 
15}, {3.7, 11}, {3.8, 14.8}, {3.8, 16.8}, {3.9, 14.4}, {3.9, 
20.5}};

now i want to calculate mle

     mle = FindDistributionParameters[data, bidist , ParameterEstimator -> "MaximumLikelihood"]

but i get error like this enter image description here

and i can't get -L or pvalue

DistributionFitTest[data, bidist /. mle, {"TestDataTable", "KolmogorovSmirnov"}]
$\endgroup$
5
  • 2
    $\begingroup$ "But I get error" - what error do you get exactly? Leaving those details out forces potential helpers to copy and run your code to even find out if they can help. On the other hand, you may be lucky and one of the readers will know the solution from your error code alone, if you include it! $\endgroup$
    – MarcoB
    Commented Aug 10, 2022 at 3:18
  • $\begingroup$ You have an error in the code: "FGM,\[Gamma]" should be {"FGM", \[Gamma]}. In addition, your proposed bivariate distribution has identical marginals. However, the marginal means and variances are wildly different. $\endgroup$
    – JimB
    Commented Aug 10, 2022 at 3:24
  • $\begingroup$ Giving just 4 data points ({{2, 6.5}, {2, 6.5}, {2.1, 10.1}, {2.2, 7.2}}) to estimate 3 parameters is not going to work. $\endgroup$
    – JimB
    Commented Aug 10, 2022 at 18:37
  • $\begingroup$ I gave more than 4 data points but same results JimB $\endgroup$
    – Ahmed
    Commented Aug 10, 2022 at 19:06
  • $\begingroup$ You need to show what you did and not have us guessing. This appears to be a pattern and you could likely lose a lot of interest from folks who could help. $\endgroup$
    – JimB
    Commented Aug 10, 2022 at 19:15

1 Answer 1

3
$\begingroup$

In this case I think one needs to construct the log likelihood "from scratch" and use a high WorkingPrecision.

(* Data *)
data = {{2, 6.5}, {2, 6.5}, {2.1, 10.1}, {2.2, 7.2}, {2.2, 7.6}, {2.2,
     7.9}, {2.2, 8.5}, {2.2, 9.1}, {2.2, 9.6}, {2.2, 9.6}, {2.2, 
    10.7}, {2.3, 9.6}, {2.4, 7.3}, {2.4, 7.9}, {2.4, 7.9}, {2.4, 
    9.1}, {2.4, 9.3}, {2.5, 7.9}, {2.5, 8.6}, {2.5, 8.8}, {2.5, 
    8.8}, {2.5, 9.3}, {2.5, 11}, {2.5, 12.7}, {2.5, 12.7}, {2.6, 
    7.7}, {2.6, 8.3}, {2.6, 9.4}, {2.6, 9.4}, {2.6, 10.5}, {2.6, 
    11.5}, {2.7, 8}, {2.7, 9}, {2.7, 9.6}, {2.7, 9.6}, {2.7, 
    9.8}, {2.7, 10.4}, {2.7, 11.1}, {2.7, 12}, {2.7, 12.5}, {2.8, 
    9.1}, {2.8, 10}, {2.8, 10.2}, {2.8, 11.4}, {2.8, 12}, {2.8, 
    13.3}, {2.8, 13.5}, {2.9, 9.4}, {2.9, 10.1}, {2.9, 10.6}, {2.9, 
    11.3}, {2.9, 11.8}, {3, 10}, {3, 10.4}, {3, 10.6}, {3, 11.6}, {3, 
    12.2}, {3, 12.4}, {3, 12.7}, {3, 13.3}, {3, 13.8}, {3.1, 
    9.9}, {3.1, 11.5}, {3.1, 12.1}, {3.1, 12.5}, {3.1, 13}, {3.1, 
    14.3}, {3.2, 11.6}, {3.2, 11.9}, {3.2, 12.3}, {3.2, 13}, {3.2, 
    13.5}, {3.2, 13.6}, {3.3, 11.5}, {3.3, 12}, {3.3, 14.1}, {3.3, 
    14.9}, {3.3, 15.4}, {3.4, 11.2}, {3.4, 12.2}, {3.4, 12.4}, {3.4, 
    12.8}, {3.4, 14.4}, {3.5, 11.7}, {3.5, 12.9}, {3.5, 15.6}, {3.5, 
    15.7}, {3.5, 17.2}, {3.6, 11.8}, {3.6, 13.3}, {3.6, 14.8}, {3.6, 
    15}, {3.7, 11}, {3.8, 14.8}, {3.8, 16.8}, {3.9, 14.4}, {3.9, 
    20.5}};
data = Rationalize[data, 0];

(* Define distributions *)
dist1 = ProbabilityDistribution[{"CDF", (1 - E^-(λ1*x))^α1}, {x, 0, ∞},
   Assumptions -> {λ1 > 0, α1 > 0}];
dist2 = ProbabilityDistribution[{"CDF", (1 - E^-(λ2*x))^α2}, {x, 0, ∞},
   Assumptions -> {λ2 > 0, α2 > 0}];
bidist = CopulaDistribution[{"FGM", γ}, {dist1, dist2}];

Now construct the log of the likelihood and use some substitutions in an attempt to speed things up. I gave up on using LogLikelihood directly.

(* The substitutions are an attempt to simplify the resulting log likelihood *)
logpdf = (Log[PDF[bidist, {x, y}]] // PiecewiseExpand)[[2]];
logpdf = logpdf //. Log[u_ v_] -> Log[u] + Log[v] //. Log[u_^v_] -> v Log[u]
logL = Total[logpdf /. {x -> data[[All, 1]], y -> data[[All, 2]]}];

mle = FindMaximum[{logL, λ1 > 0 && λ2 > 0 && α1 > 0 && α2 > 0 && -1 < γ < 1},
  {λ1, λ2, α1, α2, γ}, WorkingPrecision -> 30]
(* {-271.80470974521206383075696322790604898437737424471, 
{λ1 -> 2.4941182035060283311914526300852320136344602902781,
 λ2 -> 0.47825679807006947144544091632892697088138495905157,
 α1 -> 765.98664215659951906278158670015743663123546664348,
 α2 -> 122.76925777452731498490642356544790410817809336203,
 γ -> 0.99999999999999999999999999999925884158661728362410}} *)

Show[ContourPlot[PDF[bidist /. mle[[2]], {x, y}],
  {x, 1.5, 4.5}, {y, 5, 22}, ContourShading -> None],
 ListPlot[data]]

Data and estimated bivariate density

I don't think a statistical test of goodness-of-fit is necessary: the fit is not very good.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.