[ADMB Users] Adjusted pow function for ADMB-RE

28 views
Skip to first unread message

Stirrup, Oliver

unread,
Nov 24, 2014, 5:50:40 AM11/24/14
to us...@admb-project.org

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.s...@ucl.ac.uk

 

Steve Martell

unread,
Nov 24, 2014, 11:14:27 AM11/24/14
to Stirrup, Oliver, us...@admb-project.org
Make sure the arguments of the function are also df1b2variable

Sent from my iPad
_______________________________________________
Users mailing list
Us...@admb-project.org
http://lists.admb-project.org/mailman/listinfo/users



This internet e-mail message, and any files transmitted with it, contains confidential, privileged information that is intended only for the addressee. If you have received this e-mail message in error, please call us at (206) 634-1838 collect if necessary) and ask to speak to the message sender. Nothing in this e-mail or the act of transmitting it, is to be construed as a waiver of any rights or privileges enjoyed by the sender or the International Pacific Halibut Commission pursuant to the International Organizations Immunities Act, 22 U.S.C. Sec. 288 et seq.

Stirrup, Oliver

unread,
Nov 25, 2014, 5:11:57 AM11/25/14
to us...@admb-project.org
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.s...@ucl.ac.uk

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

Message: 2
Date: Mon, 24 Nov 2014 16:13:16 +0000
From: Steve Martell <Ste...@iphc.int>
To: "Stirrup, Oliver" <oliver.s...@ucl.ac.uk>
Cc: "us...@admb-project.org" <us...@admb-project.org>
Subject: Re: [ADMB Users] Adjusted pow function for ADMB-RE
Message-ID: <ED8CB015-BEF1-433E...@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.s...@ucl.ac.uk<mailto:oliver.s...@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.s...@ucl.ac.uk

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

*************************************
orange_0.dat
orange_0.pin
orange_0.tpl

dave fournier

unread,
Nov 25, 2014, 12:37:37 PM11/25/14
to us...@admb-project.org

This should do the job.


GLOBALS_SECTION

#include <admodel.h>
#include<df1b2fun.h>

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

x.tpl

Stirrup, Oliver

unread,
Nov 26, 2014, 1:02:27 PM11/26/14
to us...@admb-project.org
Thank you very much, Dave. Your solution works perfectly on my machine.

Best wishes,

Oliver

Oliver Stirrup
PhD Student
MRC Clinical Trials Unit at UCL


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

Message: 1
Date: Tue, 25 Nov 2014 10:10:39 +0000
From: "Stirrup, Oliver" <oliver.s...@ucl.ac.uk>
To: "us...@admb-project.org" <us...@admb-project.org>
Subject: Re: [ADMB Users] Adjusted pow function for ADMB-RE
Message-ID:
<AM3PR01MB03913A28FD...@AM3PR01MB0391.eurprd01.prod.exchangelabs.com>

Content-Type: text/plain; charset="us-ascii"
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.s...@ucl.ac.uk

_______________________________________________
Users mailing list
Us...@admb-project.org<mailto:Us...@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-0003.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-0004.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-0005.obj>

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

Message: 2
Date: Tue, 25 Nov 2014 09:36:30 -0800
From: dave fournier <da...@otter-rsch.com>
To: us...@admb-project.org
Subject: Re: [ADMB Users] Adjusted pow function for ADMB-RE
Message-ID: <5474BE1E...@otter-rsch.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x.tpl
Type: application/applefile
Size: 2798 bytes
Desc: not available
URL: <http://lists.admb-project.org/pipermail/users/attachments/20141125/560ba031/attachment-0001.bin>

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

_______________________________________________
Users mailing list
Us...@admb-project.org
http://lists.admb-project.org/mailman/listinfo/users


End of Users Digest, Vol 73, Issue 11
*************************************
_______________________________________________
Users mailing list
Us...@admb-project.org
http://lists.admb-project.org/mailman/listinfo/users
Reply all
Reply to author
Forward
0 new messages