<div dir="ltr">Thank you for all of this advice! I will take a look at the work you referenced and try to implement some of these suggestions. I really appreciate it.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Fri, May 23, 2014 at 8:31 PM, John Sibert <span dir="ltr"><<a href="mailto:sibert@hawaii.edu" target="_blank">sibert@hawaii.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Tiffany,<br>
<br>
Yes it is possible to do what you seem to be trying to do with ADMB, but perhaps not in the way you have envisaged.<br>
<br>
You have two problems in the code as it is written:<br>
<br>
1. The compiler (and Aaron) have identified an incompatibility in the "<" operator which appears to be comparing an integer object with a differentiable object. One solution is to write the code for the required operator. A simpler (for your point of view) solution would be cast the left side of comparison to an object for which the required operator is available, that is, write something like<br>
if( (double)(yrKey(n))<cp){<br>
Even simpler yet, redefine the yrKey variable to be a floating point opject (eg vector).<br>
<br>
2. Logical comparisons on model parameters, as Ben pointed out, usually lead to errors computing the likelihood gradients. Using a logistic "switch" is one solution, but the parameter you are interested in my be difficult to estimate. My colleagues and I faced this problem when attempting to detect a difference in behavior of a tag a attached to a fish and a freely drifting tag. Anders Nielsen developed a change point estimation algorithm described in our paper<br>
"Inter-annual variation in large-scale movement of Atlantic bluefin tuna (Thunnus thynnus) determined from pop-up satellite archival tags. Can. J. Fish. Aquat. Sci. 63: 2154-2166". (I will send you the pdfs off list; the supplementary material is particularly relevant.) I'm guessing that this approach might be very similar to what you are trying to do, although it is difficult to be sure without knowing more about your problem. As a last resort, you can finesse the non-differentiability issue by using MCMC to search for the mode of the posterior distributions.<br>
<br>
Cheers,<br>
John<br>
<br>
John Sibert<br>
Emeritus Researcher, SOEST<br>
University of Hawaii at Manoa<br>
Honolulu HI (GMT-10)<br>
<a href="tel:808-294-3842" value="+18082943842" target="_blank">808-294-3842</a> (mobile)<br>
<br>
Visit the ADMB project <a href="http://admb-project.org/" target="_blank">http://admb-project.org/</a><div class=""><br>
<br>
On 05/23/2014 11:29 AM, Tiffany Vidal wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
Hello,<br>
<br>
I'm just starting to use ADMB, and am interested in running a something like a changepoint model. I am running into problems trying to use a parameter, to be estimated, in a conditional statement. When estimating the negative log likelihood I have code that looks like this:<br>
<br>
if(useNB==1){<br>
for(int n=1;n<=nobs;n++){<br>
<br></div><div class="">
*if(yrKey(n)<cp)*{<br>
mu_hat(n)=f0+*rS1*(siteKey(n))<u></u>+(f1+rSs(siteKey(n)))*Cyear(n)<u></u>+rY(yrKey(n)); <br>
}<br>
else {<br>
mu_hat(n)=f0+*rS2*(siteKey(n))<u></u>+(f1+rSs(siteKey(n)))*Cyear(n)<u></u>+rY(yrKey(n)); <br>
}<br></div><div class="">
NB_mu(n)=mfexp(mu_hat(n));<br>
<br>
nll += -log_negbinomial_density((<u></u>catch(n)),(NB_mu(n)),(1+((NB_<u></u>mu(n))/s)));<br>
}<br>
}<br>
<br>
<br>
where cp is my changepoint parameter (intended to estimate a single year in the series), bounded between 0 and max(year index), with an initial value of 30 (max year index = 50). The point of this is to allow the random site parameter to be estimated separately for the period before the changepoint and after it.<br>
<br>
The error that I receive is as follows:<br>
error: no match for 'operator<' in '((df1b2_parameters*)this)-><u></u>df1b2_parameters::<anonymous>.<u></u>df1b2_pre_parameters::<<u></u>anonymous>.model_parameters::<<u></u>anonymous>.model_data::yrKey.<u></u>ivector::operator()(n) < ((df1b2_parameters*)this)-><u></u>df1b2_parameters::cp'<br>
<br>
Is this possible to do in this program? Thank you in advance for any thoughts on how to execute this.<br>
<br>
Kindly,<br>
Tiffany<br>
<br>
<br></div><div class="">
______________________________<u></u>_________________<br>
Users mailing list<br>
<a href="mailto:Users@admb-project.org" target="_blank">Users@admb-project.org</a><br>
<a href="http://lists.admb-project.org/mailman/listinfo/users" target="_blank">http://lists.admb-project.org/<u></u>mailman/listinfo/users</a><br>
</div></blockquote>
<br>
</blockquote></div><br></div>