[ADMB Users] Adjusted pow function for ADMB-RE
Stirrup, Oliver
oliver.stirrup.13 at ucl.ac.uk
Wed Nov 26 10:01:14 PST 2014
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.stirrup.13 at ucl.ac.uk>
To: "users at admb-project.org" <users at admb-project.org>
Subject: Re: [ADMB Users] Adjusted pow function for ADMB-RE
Message-ID:
<AM3PR01MB03913A28FD01E5170ED16E53FE730 at AM3PR01MB0391.eurprd01.prod.exchangelabs.com>
Content-Type: text/plain; charset="us-ascii"
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-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 <davef at otter-rsch.com>
To: users at admb-project.org
Subject: Re: [ADMB Users] Adjusted pow function for ADMB-RE
Message-ID: <5474BE1E.9060502 at otter-rsch.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
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);}
}
-------------- 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
Users at admb-project.org
http://lists.admb-project.org/mailman/listinfo/users
End of Users Digest, Vol 73, Issue 11
*************************************
More information about the Users
mailing list