[ADMB Users] Problem with negative log likelihoods?

Steve Martell SteveM at iphc.int
Wed Oct 1 12:20:58 PDT 2014


Hola Carlos,

Mucho gracias por la correccion.  I will update the source code.

Steve
On Oct 1, 2014, at 10:59 AM, Carlos Martorell <martorell at ciencias.unam.mx<mailto: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<mailto:Users at admb-project.org>
http://lists.admb-project.org/mailman/listinfo/users


________________________________

This internet e-mail message, and any files transmitted with it, contains confidential, privileged information that is intended only for the addressee. If you have received this e-mail message in error, please call us at (206) 634-1838 collect if necessary) and ask to speak to the message sender. Nothing in this e-mail or the act of transmitting it, is to be construed as a waiver of any rights or privileges enjoyed by the sender or the International Pacific Halibut Commission pursuant to the International Organizations Immunities Act, 22 U.S.C. Sec. 288 et seq.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20141001/c6dd9371/attachment.html>


More information about the Users mailing list