[ADMB Users] Random effects model with integration in the likelihood

dave fournier davef at otter-rsch.com
Sat Nov 10 18:25:24 PST 2012


On 12-11-10 04:48 PM, H. Skaug wrote:


Its not that hard. What I did only took about an hour. trapzd is the 
same game.
The compiler is just telling you what to do.   I'll check it out tomorrow.

      Dave
> Thanks for that explanation. I verified that your recipe compiles works
> when I put in a trivial adromb(). However, there are problem with the actual
> code for adromb(). It contains a call to another function trapzd(), so
> there is the questions how to handle this, and more details.
>
> It seems that we are walking outside the original random effects design
> of the random effects stuff, and thus everything gets very complicated.
> What do people think, is it better to live without a adromb() routine
> that works for random effects? I guess similar functionality may be needed
> in the future, so at least we have a recipe.
>
> The general strategy of letting the compiler lead is valuable.
>
> Hans
>
> On Sat, Nov 10, 2012 at 6:17 PM, dave fournier <davef at otter-rsch.com> wrote:
>> When I want to try and understand something like this I try and let
>> the compiler do the work. So I run tpl2rem on your tpl (after
>> getting rid of the sigma thing for now).
>> An immediate problem is
>>
>>    df1b2variable sigma=exp(beta+eps);
>>     mu=adromb(&model_parameters::fct,0,width,8);
>>     f -= -0.5*square(u);
>>
>> Need to change that to
>>> mu=adromb(&df1b2_parameters::fct,0,width,8);
>> That is a problem with the sed scripts in tpl2rem
>>
>> Now compile again and you get
>>   undefined reference to df1b2_pre_parameters::adromb(df1b2variable
>> (df1b2_parameters::*)(df1b2variable const&), int, data_number&, int)
>>
>> So give it what it want. Put this in s.htp
>>
>> class df1b2_parameters;
>>
>> class df1b2_pre_parameters : public model_parameters
>> {
>> public:
>>    df1b2_pre_parameters(int sz,int argc, char * argv[]) :
>>      model_parameters(sz,argc,argv){;}
>>    re_objective_function_value  f;
>>    void begin_df1b2_funnel(void);
>>    void setup_quadprior_calcs(void);
>>    void end_df1b2_funnel(void);
>>   void ll_j(const int j, const funnel_init_df1b2variable& beta,const
>> funnel_init_df1b2variable& sigeps,const funnel_init_df1b2variable& u);
>>    df1b2variable df1b2_pre_parameters::adromb(df1b2variable
>> (df1b2_parameters::*)(const df1b2variable&), int, data_number&, int);
>> };
>>
>> Now it compiles and returns a link error for this function. So now we
>> understand the hierarchy.
>> So where is the difficulty?  What we would like to do is to put this
>> function in a base class, in this
>> case function_minimizer. that is where the dvariable form lives.  It almost
>> works, but
>> the problem is that function_minimizer does not know about df1b2variables so
>> you can't return one
>> because at that time it wont know what the size on the stack is.
>>
>> Anyway that is the idea.  To fix this we can pass the df1b2variable as a
>> reference to the function
>> instead of returning it and make the function void. So in admodel.h I added
>>
>> #if defined(USE_LAPLACE)
>>    class df1b2variable;
>>    class init_df1b2vector;
>>    class df1b2vector;
>>    class df1b2_parameters;
>>    typedef df1b2variable (df1b2_parameters::*DFPMF) (const df1b2variable&);
>> #endif
>>
>>
>> class function_minimizer
>> {
>>     // stuff  ...
>>
>> #if defined(USE_LAPLACE)
>>    void adromb(DFPMF,double a,double b,const df1b2variable& _v,int ns=9);
>> #endif
>>
>>
>> This is all the information the compiler needs.
>>
>> We can put the code for the actual function in a place where it knows about
>> df1b2variables.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at admb-project.org
>> http://lists.admb-project.org/mailman/listinfo/users
>>




More information about the Users mailing list