[ADMB Users] Problem with negative log likelihoods?
bigA
jaguar.smart at gmail.com
Wed Oct 1 12:05:37 PDT 2014
If I am not mistaken, in Iceland, there was substantial discussion amongst
developers about what functions returned log-likelihood and which
functions returned negative log-likelihood.
If I am not mistaken this hasn't been standardized; it is often different
from R.
The difference between the two versions of 00075 appears to simply be a
negative sign?
Is this a documentation failure or a bug?
Aaron
nll -= -k(i)*log
<http://admb-project.org/documentation/api/d3arr2a_8cpp.html#a921f553085254834ebbe598d5e9c0341>
(lambda(i))+lambda(i)+gammln
<http://admb-project.org/documentation/api/group__gammafunc.html#gae01374ddda83bc2216ba9df9c76d9995>
(k(i)+1.);
vs
nll -= k(i)*log
<http://admb-project.org/documentation/api/d3arr2a_8cpp.html#a921f553085254834ebbe598d5e9c0341>(lambda(i))+lambda(i)+gammln
<http://admb-project.org/documentation/api/group__gammafunc.html#gae01374ddda83bc2216ba9df9c76d9995>(k(i)+1.);
On Tue, Sep 30, 2014 at 6:57 PM, Carlos Martorell <
martorell at ciencias.unam.mx> wrote:
> Hi,
> After checking the output of an ADMB run I believe that I have found a
> problem in (at least) a couple of the functions used to calculate the
> negative log-likelihoods in dpois and dnbinom functions in the statsLib.h
> library. When a vector of parameters (lambdas in the Poisson case) is
> provided, the code for the log-likelihood is
>
> 00067 dvariable <http://admb-project.org/documentation/api/classdvariable.html> dpois <http://admb-project.org/documentation/api/dpois_8cpp.html#a64d2001c40c90f8295bd86ea88ff6979>(const dvector <http://admb-project.org/documentation/api/classdvector.html>& k, const dvar_vector <http://admb-project.org/documentation/api/classdvar__vector.html>& lambda)00068 {00069 RETURN_ARRAYS_INCREMENT <http://admb-project.org/documentation/api/group__RA.html#ga9616d0c80845da3942a30acbb1dbbfa9>();00070 int i;00071 int n = size_count <http://admb-project.org/documentation/api/dsize_8cpp.html#aa42ba747b253f027435b478a7d747f52>(k);00072 dvariable <http://admb-project.org/documentation/api/classdvariable.html> nll=0;00073 for(i = 1; i <= n; i++)00074 {00075 nll -= k(i)*log <http://admb-project.org/documentation/api/d3arr2a_8cpp.html#a921f553085254834ebbe598d5e9c0341>(lambda(i))+lambda(i)+gammln <http://admb-project.org/documentation/api/group__gammafunc.html#gae01374ddda83bc2216ba9df9c76d9995>(k(i)+1.);00076 }00077 RETURN_ARRAYS_DECREMENT <http://admb-project.org/documentation/api/group__RA.html#ga780ea9f1c9038a5116c28140166d6e7e>();00078 return nll;00079 }
>
> I believe that the correct code for line 00075 should be
>
> nll -= -k(i)*log
> <http://admb-project.org/documentation/api/d3arr2a_8cpp.html#a921f553085254834ebbe598d5e9c0341>
> (lambda(i))+lambda(i)+gammln
> <http://admb-project.org/documentation/api/group__gammafunc.html#gae01374ddda83bc2216ba9df9c76d9995>
> (k(i)+1.);
>
> This is evident in the same function when lambda is constant, e.g.,
>
> 00035 <http://admb-project.org/documentation/api/statsLib_8h.html#a64d2001c40c90f8295bd86ea88ff6979> dvariable <http://admb-project.org/documentation/api/classdvariable.html> dpois <http://admb-project.org/documentation/api/dpois_8cpp.html#a64d2001c40c90f8295bd86ea88ff6979>(const double& k, const prevariable <http://admb-project.org/documentation/api/classprevariable.html>& lambda)00036 {00037 RETURN_ARRAYS_INCREMENT <http://admb-project.org/documentation/api/group__RA.html#ga9616d0c80845da3942a30acbb1dbbfa9>();00038 dvariable <http://admb-project.org/documentation/api/classdvariable.html> tmp = -k*log <http://admb-project.org/documentation/api/d3arr2a_8cpp.html#a921f553085254834ebbe598d5e9c0341>(lambda)+lambda + gammln <http://admb-project.org/documentation/api/group__gammafunc.html#gae01374ddda83bc2216ba9df9c76d9995>(k+1.);00039 RETURN_ARRAYS_DECREMENT <http://admb-project.org/documentation/api/group__RA.html#ga780ea9f1c9038a5116c28140166d6e7e>();00040 return tmp;00041 }
>
> I found these codes both in the ADMB version that I downloaded and in the
> package documentation (
> http://admb-project.org/documentation/api/dpois_8cpp_source.html). After
> making the correction that I propose above and re-running ADMB, the program
> reports the correct log-likelihoods. The same problem can be found in
> dnbinom and maybe in other functions.
> Given that the functions provided for the estimation of negative
> log-likelihoods are widely used, it would be important to check that their
> outputs are correct.
> Best,
>
>
>
> --
> I think [the island's] unusually sterile character gives it a
> grandeur
> which more vegetation might have spoiled.
> ----Ch. Darwin. El
> diario del Beagle
>
> Dr. Carlos Martorell
>
> Departamento de Ecología y Recursos Naturales
> Facultad de Ciencias-UNAM
> Circuito Exterior S/N, Cd. Universitaria
> 04510 México D.F.
> Tel. (55) 5622 4835 Fax (55) 5622 4828
>
> http://www.fciencias.unam.mx/investigacion/grupos/biologia/ecologia/ambientesl
>
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20141001/c87cda1e/attachment-0001.html>
More information about the Users
mailing list