[ADMB Users] Turning parameters on and off

Mark Payne mpa at aqua.dtu.dk
Thu Feb 10 03:05:27 PST 2011


So phase=-1 turns a parameter off? That's handy. Does it also apply for something like
PARAMETER_SECTION
  init_number g(FIT_PHASE)
as well?

As an alternative, is it possible to pass parameters directly from the command line eg

./fit_my_model #Fits full model
./fit_my_model -no_linear_trend
or 
./fit_my_model -args 1

Mark

-----Oprindelig meddelelse-----
Fra: anders at nielsensweb.org [mailto:anders at nielsensweb.org]
Sendt: to 2/10/2011 11:48
Til: Mark Payne
Cc: users at admb-project.org
Emne: Re: [ADMB Users] Turning parameters on and off
 
Hi Mark,

I would use the phases capabilities, and then set them to -1 if
you don't want to estimate a given parameter. Then you can read
the phase in via your data file, or via a different control file
that you switch to via:

  !! ad_comm::change_datafile_name("newfile.dat");

in your data section.

A small example below of reading in phases and bounds is shown
below. It uses the init_bounded_number_vector type, but that is
not necessary, as you can set the phases on all model parameters.

Cheers,

Anders.


DATA_SECTION
  init_int N
  init_vector Y(1,N)
  init_vector x(1,N)
  init_vector lb(1,3)
  init_vector ub(1,3)
  init_ivector phase(1,3)
PARAMETER_SECTION
  init_bounded_number_vector th(1,3,lb,ub,phase)
  objective_function_value nll
PROCEDURE_SECTION
  nll=0.5*(N*log(2*M_PI*square(th(3)))
      +sum(square(Y-(th(1)+th(2)*x)))/square(th(3)));


With the datafile


# number of observations
10
# observed Y values
1.4 4.7 5.1 8.3 9.0 14.5
14.0 13.4 19.2 18
# observed x values
-1 0 1 2 3 4 5 6 7 8
# lower bounds a b sigma
-100 -100 0
# upper bounds a b sigma
100 100 100
# phase a b sigma
1 1 2


> Hi,
>
> I was wondering if anyone had suggestions for a good coding practice in
> ADMB that might help with the following problem.
>
> I would like to have the ability to switch various parts of my model on
> and off at run-time, without having to edit and recompile. For example, I
> would like to use my ADMB fitting engine to fit e.g. a gaussian in time,
> and compare this to a fit with a gaussian + linear time trend. This can
> obvious be done with two different engines, but from a code maintenance
> and practical point of view, this is not optimal. I can pass a flag "fit
> linear trend" and use it to omit the linear trend component, but this then
> creates problems with the calculation of my Hessian and the sds ie the
> matrix ends up being singular, because some of the parameters are not
> used....
>
> Does anyone have suggestions how I can have my cake and eat it too?
>
> Cheers,
>
> Mark
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users
>






More information about the Users mailing list