<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 12-12-05 09:59 AM, Jeff Laake wrote:<br>
<br>
It could be done with a bit of work. The main idea would be to
make adromb a SEPARABLE_FUNCTION<br>
then you need to pass all the necessary variables though it to
trapz and further through to h.<br>
you could make trapz and h just dvariable type objects with the
corresponding df1b2variable types.<br>
so for example h would be somethng like<br>
<br>
dvariable h(const double x,const prevariable& sigma)<br>
{<br>
dvariable tmp;<br>
tmp=exp(-.5*square(x/sigma))/(sqrt(2*PI)*sigma); // Normal
(0,sigma) pdf<br>
return tmp;<br>
}<br>
df1b2variable h(const double x,const df1b2variable& sigma)<br>
{<br>
df1b2variable tmp;<br>
tmp=exp(-.5*square(x/sigma))/(sqrt(2*PI)*sigma); // Normal
(0,sigma) pdf<br>
return tmp;<br>
}<br>
<br>
and trapzd becomes somethng like<br>
<br>
dvariable trapzd(double a,double b,int n,const dvariable&
s,const prevariable& sigma)<br>
{<br>
double x,num_interval,hn;^M<br>
dvariable sum;^M<br>
<br>
static int interval;^M<br>
int j;^M<br>
if (n == 1) {^M<br>
interval=1;^M<br>
return (s=0.5*(b-a)*(h(a,sigma)+h(b,sigma)));^M<br>
} else {^M<br>
num_interval=interval;^M<br>
<br>
<br>
with a corresponding df1b2variable trapz as well.<br>
<br>
etc. <br>
<br>
<br>
</div>
<blockquote
cite="mid:CAAyWzSXpuFirAWx-SDoOpxEyJs_3vUVMnbDWry+_ASYX7sfhwQ@mail.gmail.com"
type="cite">So I spent some time with this and I was able to get
it to work with adromb although there are some minor differences
probably related to Laplace approximation. It is not due to the
integration because I swapped out the adromb code for cumd_norm
and got the same answer. From what I understand this will not work
with separable functions which is a bit of an issue because it
doesn't scale up nicely like the separable function. If I'm wrong
about that please let me know. It would be a big improvement if
the integration could be used from a separable function.
<div>
<br>
</div>
<div>I've attached the tpl and dat files (they are identical) from
existing example for random effect example (hnre_f2.tpl) and the
adromb version of the same likelihood (inthnre_f2.tpl). Both
are based on eq 7 in <a moz-do-not-send="true"
href="https://github.com/downloads/jlaake/ADMB-Examples/distance_random_effect.pdf">https://github.com/downloads/jlaake/ADMB-Examples/distance_random_effect.pdf</a>.</div>
<div><br>
</div>
<div>Thanks for your effort here Dave. It does work as you stated
and it worked great for say n<=200. If I were to take the
integral into the loop for the case of covariates then the temp
files get huge and become problematic. The separable function
approach is preferable and doesn't suffer from the temp file
problem. So far the time being I'm left with functions like
cumd_norm or internally coding an approximation.</div>
<div><br>
</div>
<div>regards--jeff</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Fri, Nov 30, 2012 at 1:34 PM, dave
fournier <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:davef@otter-rsch.com" target="_blank">davef@otter-rsch.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">If the
model is just crashing you should be able to run it with<br>
a debugger and see at what line it happens. Much faster
than thinking.<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>