ADMB Tips

  1. In the PARAMETER_SECTION (and perhaps elsewhere) when LOC_CALCS is used it must be preceded by a single space,

furthermore, all text within the LOC_CALCS - END_CALCS section must be indented by at least two spaces. If this

is not followed then an error results stating “Error in line 72 while reading d” if for example the line after

LOC_CALCS starts with the letter “d”.

  1. For a parameter vector to have individual components with different upper and lower bounds and with estimation of some parameters in different phases, need to declare an init_bounded_number_vector and not an init_bounded_vector. All parameters in the latter must have the same lower, upper bounds and phase.

  2. Using a to start any line is a recipe for complete and utter disaster. It should always be a number of spaces and not a tab.

  3. When there are problems such as “unable to convert prevariable to dvariable”, try: value(X), which returns a double.

  4. The block comment /* */ cannot be on the first space of any line.

  5. fact(x) is not implemented but is equal to exp(gammln(x+1))

  6. When declaring matrices and vectors it is not permissable to have any spaces in the declaration, thus

vector FinalEscapement(1,NGROUPS + 1); //results in an error vector FinalEscapement(1,NGROUPS+1); //does not result in an error

  1. It is possible to input a label as a string using init_adstring label in the data file. There is, however, no way of inputting a vector of labels such as init_vector_adstring. A work around is possible using the following commands:

in GLOBAL_SECTION

adstring_array ParmLabel; // extendable vector to hold the parameter labels created below.

in DATA_SECTION reads parameter label prefixes from a file and generates some integer to strings

LOCAL_CALCS

ifstream ifs(“ParmLabel.ss2”);

adstring_array NumLbl;

adstring onenum(4);

adstring_array MGParmLbl; // parameter label prefixes

adstring_array GenderLbl; // gender label

for (i=1;i<=2;i++) {

line_adstring sAD; // defines a line of input, including any special characters

ifs » sAD; // reads the line from input stream

GenderLbl+=sAD; // appends the line to array, thus extending the vector by one addressable element

}

for (i=1;i<=20;i++) {

_itoa( i, onenum, 10 );

NumLbl+=onenum;

line_adstring sAD;

ifs » sAD;

MGParmLbl+=sAD;

}

END_CALCS

later in DATA_SECTION as parameters are pre-processed, customized labels are created, such as:

ParCount++; ParmLabel+=MGParmLbl(20)+”move_in_seas“+NumLbl(s)+”from“+NumLbl(p)+”to“+NumLbl(p2);

  1. In the REPORT_SECTION nothing is allowed in the first column of characters, all lines must be indented by at least one space.

  2. To output the maximum gradient component, cout or report1« “objective_function_value::pobjfun->gmax”

If this is small (usually 1e-3 or less) then convergence is

likely, if large (>1) then convergence is unlikely.

  1. The function sfabs implements a smooth absolute value.

ADMB Foundation © 2007–2024