[ADMB Users] function definition

anders at nielsensweb.org anders at nielsensweb.org
Tue Sep 7 02:44:14 PDT 2010


Hi Mollie,

You can add a functions with parameters. The following small
example illustrates it in a simple negative binomial model
x_1, ..., x_15 ~ neg.bin(p,size).

Cheers,

Anders.

DATA_SECTION
  init_vector X(1,15);

PARAMETER_SECTION
  init_number logsize;
  init_bounded_number p(0,1);
  sdreport_number size;
  objective_function_value nll;

PROCEDURE_SECTION
  size=exp(logsize);
  nll=nb(p,size);

FUNCTION dvariable nb(const dvariable& p, const dvariable& size)
  dvariable ret;
  int N=X.indexmax()-X.indexmin()+1;
  ret=-sum(gammln(X+size))+N*gammln(size)+
       sum(gammln(X+1.0))-N*size*log(p)-sum(X)*log(1.0-p);
  return(ret);



> Hi ADMB Users,
> Is there a way to define a function that receives parameters?
> I found function definitions in procedure sections in admb.pdf, but
> none of them have parameters.
>
> Also, is there an automated way to search the mailing list archives?
> thanks,
> Mollie
>
> Mollie Brooks
> Ph.D. Candidate
> NSF IGERT Fellow
> Biology Department
> University of Florida
> mbrooks at ufl.edu
> www.zoology.ufl.edu/mbrooks
>
>
>
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users
>





More information about the Users mailing list