Revision 1603

trunk/tests/xml/pella-xml.tpl (revision 1603)
1
//======================================================================================================================
2
// File:        pella-xml.tpl
3
// Model:       Pella-Tomlinson model, with Binit=k*a
4
// Parameters:  r, k, a, p, q, sigma
5
// Fitted data: Abundance index
6
// Likelihood:  Log-transformed normal
7
// References:  Polacheck et al. (1993)
8
// Notes:       q and sigma are free parameters, to allow full uncertainty in MCMC analysis
9
// History:      January 2014 John Sibert added some ADMB_XMLDoc examples.
10
//               6 Jan 2011 Arni Magnusson improved vector extraction
11
//               7 Oct 2010 Arni Magnusson improved string handling and comments
12
//               9 Mar 2010 Arni Magnusson created, to benchmark against R optimizers
13
//======================================================================================================================
14
// Implementation notes
15
//   Abundance index may not exist for all years
16
//   Vectors that include all years: B, C
17
//   Vectors that include abundance index years: I, Ifit, X
18
//   X links long and short vectors
19
//======================================================================================================================
20

  
21
GLOBALS_SECTION
22
  #include <string>
23
  #include "ADMB_XMLDoc.h"
24

  
25
  using std::string;
26
  const double pi = 3.141592654;
27
  int mcmc_iteration = 0;
28
  int phz;    // phase
29
  double lb;  // lower bound
30
  double ub;  // upper bound
31
  ofstream mcmc_par("mcmc_par.csv");
32
  ofstream mcmc_bio("mcmc_bio.csv");
33

  
34
DATA_SECTION
35
  // Read data file
36
  init_int nc
37
  init_matrix Cdata(1,nc,1,2)  // Year | C
38
  init_int ni
39
  init_matrix Idata(1,ni,1,2)  // Year | I
40
  // Vectors
41
  ivector Cyear(1,nc)
42
  ivector Iyear(1,ni)
43
  vector C(1,nc)
44
  vector I(1,ni)
45
  ivector X(1,ni)  // years with abundance index: 1995 | 1998 | ...
46
  // Constants
47
  number halfnlog2pi
48
  vector logI(1,ni)
49
  // Switch to control file
50
  !! string run_name = string(adprogram_name);
51
  !! if(option_match(argc,argv,"-ind") > -1)
52
  !! {
53
  !!   run_name = argv[option_match(argc,argv,"-ind") + 1];
54
  !!   run_name = run_name.substr(0, run_name.rfind("."));
55
  !! }
56
  !! change_datafile_name((adstring)run_name.c_str() + ".ctl");
57
  // Read control file (phase, lower, upper, init)
58
  init_vector logr_plui(1,4)
59
  init_vector logk_plui(1,4)
60
  init_vector loga_plui(1,4)
61
  init_vector logp_plui(1,4)
62
  init_vector logq_plui(1,4)
63
  init_vector logsigma_plui(1,4)
64

  
65
PARAMETER_SECTION
66
  // Estimated
67
  !! phz = (int) logr_plui(1);
68
  !! lb  =       logr_plui(2);
69
  !! ub  =       logr_plui(3);
70
  init_bounded_number logr(lb,ub,phz)
71
  !! phz = (int) logk_plui(1);
72
  !! lb  =       logk_plui(2);
73
  !! ub  =       logk_plui(3);
74
  init_bounded_number logk(lb,ub,phz)
75
  !! phz = (int) loga_plui(1);
76
  !! lb  =       loga_plui(2);
77
  !! ub  =       loga_plui(3);
78
  init_bounded_number loga(lb,ub,phz)
79
  !! phz = (int) logp_plui(1);
80
  !! lb  =       logp_plui(2);
81
  !! ub  =       logp_plui(3);
82
  init_bounded_number logp(lb,ub,phz)
83
  !! phz = (int) logq_plui(1);
84
  !! lb  =       logq_plui(2);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff