[ADMB Users] Adjusted pow function for ADMB-RE

Stirrup, Oliver oliver.stirrup.13 at ucl.ac.uk
Tue Nov 25 02:10:39 PST 2014


Thank you for the suggestions returned regarding my problem (including a couple off-list), but I am still having trouble working out how to correctly define the required function. As such, I have created a toy example using the 'orange trees' model from the ADMB website. The attached 'dat' file is unchanged, and in the 'pin' file I have just added the starting value for a new parameter 'log_gamma'.

I have adjusted the 'tpl' file to represent my problem. The times for each individual are now read into a dvector 'time', and are adjusted by subtracting the minimum value (118) in order to create zero values. In the mean response function, the time variable is now raised to the power of gamma, representing a shift in the shape of the growth curve.

If I do not create zero values in time, and use the normal 'pow' function, then the model does compile and converge (although log_gamma barely changes from zero). However, I cannot get this to work with the required adjusted pow function.

The attached adjusted tpl may well not represent a useful model for the given data, but if anyone has any suggestions with regards to how to get this example to compile and run then I would be very grateful.

Thanks and best wishes

Oliver

Oliver Stirrup
PhD Student

MRC Clinical Trials Unit at UCL
Institute of Clinical Trials & Methodology London  UK
e-mail:                          oliver.stirrup.13 at ucl.ac.uk

----------------------------------------------------------------------

Message: 2
Date: Mon, 24 Nov 2014 16:13:16 +0000
From: Steve Martell <SteveM at iphc.int>
To: "Stirrup, Oliver" <oliver.stirrup.13 at ucl.ac.uk>
Cc: "users at admb-project.org" <users at admb-project.org>
Subject: Re: [ADMB Users] Adjusted pow function for ADMB-RE
Message-ID: <ED8CB015-BEF1-433E-81E6-1826A4950198 at iphc.int>
Content-Type: text/plain; charset="windows-1252"

Make sure the arguments of the function are also df1b2variable

Sent from my iPad

On Nov 24, 2014, at 2:51 AM, Stirrup, Oliver <oliver.stirrup.13 at ucl.ac.uk<mailto:oliver.stirrup.13 at ucl.ac.uk>> wrote:

Hello all

I have found that use of the ?pow? function causes executables created by ADMB to crash when the first argument is zero, i.e. when a calculation of 0^x is attempted.

In my template files, data relating to a time variable are read into a dvar_vector and (within a loop) each element of this vector is then raised to the power of a model parameter. The time variable is positive in most cases, but occasionally takes the value of zero, leading to the problem described.

Using the standard mode for ADMB, I have overcome this problem by defining the following function to replace ?pow?:

<<< >>>

GLOBALS_SECTION

  #include <admodel.h>

  dvariable pow2(const dvariable & time, const dvariable & T)
  {
  if(time==0)
    return 0;
  else return pow(time,T);
  }

<<< >>>

I would now like to implement a similar solution for the random effects mode of ADMB, but have so far been unsuccessful in my attempts, with a large number of error messages on compilation. I think that my problem lies in the fact that I do not really understand how to define and manipulate df1b2variable objects.

If anyone can offer a solution or any advice regarding this problem, I would be very grateful.

Best wishes

Oliver


Oliver Stirrup
PhD Student

MRC Clinical Trials Unit at UCL
Institute of Clinical Trials & Methodology London  UK
e-mail:                          oliver.stirrup.13 at ucl.ac.uk

_______________________________________________
Users mailing list
Users at admb-project.org<mailto:Users at admb-project.org>
http://lists.admb-project.org/mailman/listinfo/users

*************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: orange_0.dat
Type: application/octet-stream
Size: 541 bytes
Desc: orange_0.dat
URL: <http://lists.admb-project.org/pipermail/users/attachments/20141125/b9fd25a0/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: orange_0.pin
Type: application/octet-stream
Size: 72 bytes
Desc: orange_0.pin
URL: <http://lists.admb-project.org/pipermail/users/attachments/20141125/b9fd25a0/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: orange_0.tpl
Type: application/octet-stream
Size: 2674 bytes
Desc: orange_0.tpl
URL: <http://lists.admb-project.org/pipermail/users/attachments/20141125/b9fd25a0/attachment-0002.obj>


More information about the Users mailing list