[ADMB Users] Random effects model with integration in the likelihood
dave fournier
davef at otter-rsch.com
Sat Nov 10 09:17:59 PST 2012
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: s.zip
Type: application/zip
Size: 3433 bytes
Desc: not available
URL: <http://lists.admb-project.org/pipermail/users/attachments/20121110/e3cb4dd8/attachment.zip>
More information about the Users
mailing list