Closed GoogleCodeExporter closed 9 years ago
If you accept my arguments that the code must be changed, here is a better
method for doing it than using sum(exp(log(dij) − bic[j] + min_bic)). It is
mathematically equivalent, just as numerically stable, and avoids an unncessary
log. The translation from C to Java should be straightforward.
//assumptions:
// * branch length vectors 'b[i]' of length 'nedges' have been stored
// for all models 'i'
// * BIC values have already been stored into an array 'bic'
// * bic_min has already been determined
double denom = 0.0;
for (uint i = 0; i < nmodels; i++)
{
/* Note that we don't need to worry about underflow here, as at least
one of the "bic[i] - bic_min" values will be zero, and any terms
that underflow to zero when exponentiated would make a negligible
contribution to the sum anyway.
*/
bic_like[i] = exp_safe(-0.5*(bic[i] - bic_min));
denom += bic_like[i];
}
for (uint i = 0; i < nmodels; i++)
{
double sum = 0.0;
for (j = 0; j < nmodels; j++)
if (j != i)
sum += euclideanDistance(b[i], b[j], nedges)*bic_like[j];
dt[i] = sum/denom;
}
Original comment by dave.swo...@gmail.com
on 17 Mar 2014 at 4:16
Replacing the previous PDF...
Original comment by dave.swo...@gmail.com
on 17 Mar 2014 at 4:59
Attachments:
That's right. There was a bug in those calculations. It was fixed in the trunk.
Thank you very much for your detailed report!
Original comment by DiegoDL84
on 28 Mar 2014 at 10:14
Hi Dave, we will look into this.
It is possible I made such mistake 7 years ago when coding DT into Jmodeltest 0.1, although I did compare my output with that of DTModSel and the differences were minimal, so I thought they were due to using Phyml vs PAUP to get the likelihoods.
In any case we will fix it, thanks much!
So, is PAUP coming back with model selection, bayes, etc?? I hope so!!
Hope all is well, take care
D
Original comment by dposad...@gmail.com
on 3 Apr 2014 at 1:41
Original comment by DiegoDL84
on 2 Sep 2014 at 8:30
Original issue reported on code.google.com by
dave.swo...@gmail.com
on 17 Mar 2014 at 3:07Attachments: