ADMB new feature: Prior and likelihood section
The priors and likelihood sections was aim at help converting the winbugs model to admb. So the basic format is the same as winbugs x ~ dnorm(mu,sigma); You can have any spaces between the ~ and within the argument lists. Here the dnorm is just any function name which taken on -log scale of the distribution, admb will provide some, you can has your own function or use the contribute library in contrib folder. One thing need notice is the first argument of actual function will be put on the left side of ~, all the remaining will be on right side of ~, such as your real function definition dnorm(x, mu,sigma), when you use ~, the first argument x will be on the left side of ~, the right side of ~ will be dnorm(mu,sigma), it doesn’t need to be x, but should has the same data type as x.
The section definition can be PRIOR_SECTION or PRIORS_SECTION, LIKELIHOOD_SECTION or LIKELIHOODS_SECTION. The user can choose to use any of these section, which allowed to be put before procedure_section, if you choose to use both of them, the basic order will be priors section, likelihood section, and procedure section. For random effect model, the preliminary_calcs section only be allowed after likelihood section and before procedure section. Also for random effect, there are other limits too, one is the initialization section should be before parameter section if you use it, the runtime section only can be put after either the report section or preliminary section, I suggest you put after the report section.
The priors, likelihood sections allow to use any valid c++ code inside, it is like procedure_section, so don't forget the ; at the end of line except the if,else, for, while etc, and make sure they are valid c++ code. We will constrain the use of prior section only for parameters which are prefix init_ from parameter section. For the likelihood section, we constrain the use for constant data type, which from data_section only. If not, it throws the warning. But it is just remind warning, will not affect your final results. We also initialize the objective function value as 0 at the beginning of the procedure section, so you don't need to reinitialize, although it is not harm if you still want to do so. Remember every ~ you defined will be count into the objective function automatically, so use with some caution.
We also defined two variables, prior_function_value and likelihood_function_value, each sum up the negative log likelihood function value for their respective section, and will be added to objective function value automatically. Actually these two sections (including any C++ code there) will be appended at the end of procedure section. You can get the value by referring the above name in your report section, such as report<