I have been wondering about this for quite some time. What is the "correct" way to do interpolation in ADMB, so that you don't run into problems with discontinuous gradients? I see that there are a series of cubic spline interpolation functions in there, spine(), splint() but that they are also marked for replacement. Is there something else in the works or is this the best approach?
Cheers,
Mark
f1(x) for x<X
f2(x) for x>=X
steep=10.; // or larger value depending on expected magnitude of x-X
join(x) =1./(1.+mfexp(steep*(x-X)))); // so is steep and centered on X
// composite function is then
f(x) = f1(x)*join(x) + f2(x)*(1.-join(x));
this is not perfect and depending on the slope of f1 and f2 near X may
result in a small wrinkle in the composite function, but it has served
my purposes.
Rick Methot
Derek
That's good to hear. I was wondering though if they are there or not in the current version published on the website (9.1), as I can't seem to get access to them?
The line
spliney2=spine(splinex,spliney,0,0);
generates an "out of scope" compiler error:
g++ -c -O3 -Wno-deprecated -D__GNUDOS__ -Dlinux -DOPT_LIB -DUSE_LAPLACE -fpermissive -I. -Ic:/admb/gcc440/include Forward.cpp
Forward.cpp: In member function 'virtual void model_parameters::report()':
Forward.cpp:166: error: 'spline' was not declared in this scope
Using "spine" instead of "spline" generates a corresponding error.
Running release 9.1 on Win XP.
Mark
-----Oprindelig meddelelse-----
Fra: Derek Seiple [mailto:dsei...@gmail.com]
Sendt: 5. oktober 2010 21:14
Til: Richard Methot
Cc: Mark Payne; us...@admb-project.org
Emne: Re: [ADMB Users] Interpolation while optimising
log_self(10) = log_self(7);
You should always compile your code with the safe version of ADMB which
has bounds checking
especially if you are observing strange behaviour.
Indeed, and the safe mode warns for this. Thanks for pointing this out. However the model still aborts with exit code 5 if I fix this (going outside of one of my arrays. No further warnings are given in safe mode.
So my question still remains; what could be wrong, and where could I find the meaning of the exit codes.
Help is greatly appreciated.
Jan Jaap
------
likeprof_params * likeprof_params::likeprofptr[50]; // this should be
// a resizeable array
To get you model to work a quick fix is to change this to something
bigger say 500.
you will also need to change the declaration in admodel.h.
Of course anyone is welcome to fix this properly. Isn't open source
wonderful!
The spline system in ADMB is based around a class called vcubic_spline_function. The way these classes work is when you declare something of type
vcubic_spline_function it automatically calls spline() to set up things for splint(). Then when you make a call to the type you just set up it calls splint() to do the interpolation. The class hides these details. so for example you might have something like this:
vcubic_spline_function interp_func(x, y, dfl, dfr); // this calls spline() behind the scenes
interpolated_val = interp_func( some_x_val );
other_interp_val = interp_func( some_other_x_val ); // this calls splint() behind the scenes
And here's an example from my procedure section:
dvector splinex(1,nages);
dvar_vector spliney(1,nages);
//... Populate splinex and spliney ...//
//Create the class
vcubic_spline_function splinefn=vcubic_spline_function(splinex,spliney,0.0,0.0);
//Evaluate the function
interpolated= splinefn(0.1);
-----Original Message-----
From: Derek Seiple [mailto:dsei...@gmail.com]
Sent: Tue 10/5/2010 9:14 PM
To: Richard Methot
Cc: Mark Payne; us...@admb-project.org
Indeed changing the size of the array to 500 in mod_prof.cpp and admodel.h (in combination with making some methods in admodel.h public as discussed before) and rebuilding ADMB fixed the problem.
Thanks a lot,
Jan Jaap
vcubic_spline_function splinefn=vcubic_spline_function(splinex,spliney,0.0,0.0)
are the second derivative of the spline function
at the first and last values of splinex.
One day, the documentation will describe all this
stuff, but for now, the email record certainly helps.
-Ian
I went ahead and posted my quick and dirty spline
testing model, associated R code, and a plot of
the fit and various resulting derivatives at
http://admb-project.org/community/tutorials-and-examples/splines.
Additional examples could easily be added to that
folder, especially from folks who know how to
apply these concepts to real world problems. And
one day splines will presumably get added to the
documentation as well.
-Ian
Indeed, setting the size of the list to 500 in mod_prof.cpp and admodel.h and building ADMB fixed the problem. I don't know about the costs in terms of memory use or speed of execution, but maybe it is a good idea to do this as a default in the standard ADMB code.
Building the ADMB code for windows I used mingw. This is currently not described on the admb-project.org website, despite the makefile being there. So it should be fairly straightforward to add this.
Note that the mingw makefile to all popular windows options (bcc, vc, mingw) contains a call to svn. The instructions for building on windows don't include installing a cli svn client, and cli svn clients are rarely installed by default on windows machines. That means that make will fail.
Even with a cli svn client it seems that the call to svn fails (I can't remember the exact error message). It seems to attempt to get a copy of the examples from a repository (but I may be wrong here). Those examples are already in the source (in the version 9.1 zip file), so the svn line can safely be commented out.
I hope the developers of ADMB can make some of these changes.
Cheers, Jan Jaap
-----Original Message-----
From: users-...@admb-project.org [mailto:users-...@admb-project.org] On Behalf Of dave fournier
Sent: Thursday, October 07, 2010 9:50 PM
To: us...@admb-project.org
Subject: Re: [ADMB Users] exit codes and likelihood profile vectors