From 99037e74a011c3b162d2b1512ca0d7466954286a Mon Sep 17 00:00:00 2001
From: tzha <tzha@eco-tzha-01i.(none)>
Date: Fri, 12 Feb 2010 15:25:47 -0500
Subject: [PATCH] Add tzDocumentation and activate .prn files in .gitignore

---
 .gitignore                                   |   4 +-
 MatlabFiles/MSV/readme_msv.prn               |  35 +
 tzDocumentation/Template_datainp_Markov.prn  | 198 +++++
 tzDocumentation/readme_use_dwVARestimate.prn | 162 ++++
 tzDocumentation/readme_use_dwVARmhm.prn      |  49 ++
 tzDocumentation/readme_use_dwswitch.prn      | 769 +++++++++++++++++++
 tzDocumentation/testjunk.prn                 |  49 ++
 7 files changed, 1265 insertions(+), 1 deletion(-)
 create mode 100755 MatlabFiles/MSV/readme_msv.prn
 create mode 100755 tzDocumentation/Template_datainp_Markov.prn
 create mode 100755 tzDocumentation/readme_use_dwVARestimate.prn
 create mode 100755 tzDocumentation/readme_use_dwVARmhm.prn
 create mode 100755 tzDocumentation/readme_use_dwswitch.prn
 create mode 100755 tzDocumentation/testjunk.prn

diff --git a/.gitignore b/.gitignore
index 7cd0850..b102fd0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,10 +2,11 @@
 .DS_Store
 
 # Use wildcards as well
+# *.prn
+
 *~
 *.mat
 *.pyc
-*.prn
 *.aux
 *.log
 *.dvi
@@ -19,6 +20,7 @@
 *.pdf
 *.npy
 *.o
+*.dll
 
 # Can also ignore all directories and files in a directory.
 # tmp/**/*
diff --git a/MatlabFiles/MSV/readme_msv.prn b/MatlabFiles/MSV/readme_msv.prn
new file mode 100755
index 0000000..7b8ece0
--- /dev/null
+++ b/MatlabFiles/MSV/readme_msv.prn
@@ -0,0 +1,35 @@
+**********************************************************************
+************************** Important Notes ***************************
+**********************************************************************
+When eu=[0,1] in the original gensys setup, it means that in our MSV setting that exogenous persistence is put
+  in a wrong place when we reorder the roots.  Thus, there is no such [0,1] return in our MSV solution.
+
+When eu=[1,0] in the original gensys setup, it means that the MSV solution must exist with another order.  See
+  example3_10_sw.m in D:\ZhaData\WorkDisk\LiuWZ\ZhaNotes\UnderstandingMSV\OneDimentionCaseImportant.
+
+With our MSV solution, we abuse the notation eu=[1,0], which really means that we have multiple MSV solutions.
+  But multiple MSV solutions can occur only in complex numbers.  The imaginary part of the solution can be scaled
+  arbitrarily, which gives sunspot solutions.  Thus, the real MSV solution will be unique.
+
+If we encourter eu=[3,?], it means that all MSV solutions are explosive.  Thus, no stable MSV solution.
+
+
+
+========================= New files for MSV solutions ==============================
+msv_complex_AR.m: gives an MSV solution (upon the order that first works) with a flag indicating if [1,0].  If
+                    [1;0], the complex solution exits and thus the MSV solution is NOT unique.
+                    AR: autoregressive or gensys form;
+msv_all_complex_AR.m: gives all MSV-like solutions (including complex solutions).  That is, all the solutions that
+                        come from the undetermined coefficients method.
+
+
+========================= Old files for MSV solutions ==============================
+msv_simple.m:  works only for the first order if an msv solution (even if it is non-unique where the solution is
+                 complex) exist.  It does not try the second order (where the exogenous persistence may be larger
+                 than the endogenous persistence).
+
+msv_one.m: works only for the unqiue MSV solution (thus, no complex solution) for the order that comes first.  If no
+             solution is found for all orders, then no unique MSV solution (but there may be multiple MSV solutions
+             such as a complex solution).
+
+msv_all.m:  gives all MSV-like real solutions (thus, some solutions are NOT an MSV solution).
diff --git a/tzDocumentation/Template_datainp_Markov.prn b/tzDocumentation/Template_datainp_Markov.prn
new file mode 100755
index 0000000..9bc5271
--- /dev/null
+++ b/tzDocumentation/Template_datainp_Markov.prn
@@ -0,0 +1,198 @@
+/******************************************************************************/
+/********************* Markov State Variable Information **********************/
+/******************************************************************************/
+
+//== Flat Independent Markov States and Simple Restrictions ==//
+
+
+//1st state variable: learning gain.
+//2nd state variable: average seigniorage.
+//3rd state variable: seigniorage shocks.
+//4th state variable: after-escape shocks.
+//+
+//Case: tv_varibles == (TV_GAIN | TV_AD | TV_DSHOCKS) && syntypes == S_D_SHOCKS.  See datainp_setup.prn.
+//== Number Independent State Variables ==//
+2
+
+//=====================================================//
+//== state_variable[i] (1 <= i <= n_state_variables) ==//
+//=====================================================//
+//== Number of states for state_variable[1] ==//
+2
+
+
+//----------------- Prior for the transition matrix Q_k -----------------
+//== Each column contains the parameters for a Dirichlet prior on the corresponding
+//== column of the transition matrix.  Each element must be positive.  For each column,
+//== the relative size of the prior elements determine the relative size of the elements
+//== of the transition matrix and overall larger sizes implies a tighter prior.
+//If it is an identity matrix, we have no prior (i.e., a flat prior in this case).
+//Examples:
+//2.000000 1.000000
+//1.000000 2.000000
+//2.000000 1.000000 1.000000
+//1.000000 2.000000 1.000000
+//1.000000 1.000000 2.000000
+//== Transition matrix prior for state_variable[1]. (n_states x n_states) ==//
+1.000000 1.000000
+1.000000 1.000000
+
+
+//----------------- The semi-free parameter vector free -----------------
+//The vector, free, indictates the number of semi-free parameters in each column of Q_k.  By semi-free, we
+//  meen that the sum of each column in Q_k is 1.0 so that the number of true free parameters is one less.
+//== Free Dirichet dimensions for state_variable[1]  ==//
+2 2
+
+
+//----------------- The restriction matrix R_j -----------------
+//== The jth restriction matrix is n_states x free[j].  Each row of the restriction
+//== matrix has exactly one non-zero entry and the sum of each column must be one.
+//Example 1:
+//1 0 0
+//0 1 0
+//0 0 1
+//Example 2 (3 states but 2 semi-free parameters for column j of Q_1):
+//0 0
+//1 0
+//0 1
+//which gives the free-parameter vector [0 q_2 q_3] where q_2 + q_3 = 1.0.
+//== Column restrictions for state_variable[1] ==//
+1 0
+0 1
+
+1 0
+0 1
+
+
+//----------------- Allows for lagged values of the state variable to be encoded -----------------
+//== Number of lags encoded for state_variable[1] ==//
+1
+
+
+//== Number of states for state_variable[2] ==//
+3
+
+//== Each column contains the parameters for a Dirichlet prior on the corresponding
+//== column of the transition matrix.  Each element must be positive.  For each column,
+//== the relative size of the prior elements determine the relative size of the elements
+//== of the transition matrix and overall larger sizes implies a tighter prior.
+//== Transition matrix prior for state_variable[2]. (n_states x n_states) ==//
+ 1.0  1.0  1.0
+ 1.0  1.0  1.0
+ 1.0  1.0  1.0
+
+//== Free Dirichet dimensions for state_variable[2]  ==//
+2 2 2
+
+//== The jth restriction matrix is n_states x free[j].  Each row of the restriction
+//== matrix has exactly one non-zero entry and the sum of each column must be one.
+//== Column restrictions for state_variable[2] ==//
+1 0
+0 0
+0 1
+
+0 0
+1 0
+0 1
+
+0 0.5
+0 0.5
+1 0
+
+
+//----------------- Allows for lagged values of the state variable to be encoded -----------------
+//== Number of lags encoded for state_variable[1] ==//
+0
+
+
+//----------------- User-defined intial values of the transition matrix Q_k, mainly for debugging purposes -----------------
+//Non-zero integer: use the values under Initial: Transition matrix; 0: use Waggoner's default value which is the prior mean.
+//== indxInitializeTransitionMatrix ==//
+1
+
+
+// 0.5  0.5
+// 0.5  0.5
+//Call ReadTransitionMatrices(f,(char*)NULL,"Initial: ",model) in the main function.
+//If indxInitializeTransitionMatrix=0 or does not exist, the following values are not used and
+//  Waggoner's function initializes the value from the prior mean.
+//== Initial: Transition matrix[1] ==//
+ 9.7331908462961059e-01  1.5790335972902768e-02
+ 2.6680915370389413e-02  9.8420966402709720e-01
+
+
+
+//--- Initial guess
+ 9.7331908462961059e-01  1.5790335972902768e-02
+ 2.6680915370389413e-02  9.8420966402709720e-01
+//--- Converged results
+ 9.7885175490925935e-001  1.6213439424811054e-002
+ 2.1148245090740647e-002  9.8378656057518898e-001
+
+
+
+
+//== Initial: Transition matrix[2] ==//
+ 3.8872218833300276e-01  0.0                     3.185699602083008e-002
+ 0.0                     9.8480151496509816e-01  3.185699602083008e-002
+ 6.112778116669972e-001  1.519848503490184e-002  9.3628600795833983e-01
+
+
+//--- Initial guess
+ 3.8872218833300276e-01  0.0                     3.185699602083008e-002
+ 0.0                     9.8480151496509816e-01  3.185699602083008e-002
+ 6.112778116669972e-001  1.519848503490184e-002  9.3628600795833983e-01
+//--- Converged results
+ 4.3952235591344235e-001  0.0000000000000000e+000  3.6997582827338338e-002
+ 0.0000000000000000e+000  9.7128777689293189e-001  3.6997582827338338e-002
+ 5.6047764408655765e-001  2.8712223107068113e-002  9.2600483434532332e-001
+
+
+
+
+
+
+
+
+
+
+
+
+//********************************** Notes ******************************************//
+//----------------- Not working any more but used to have the user-defined intial values of Q_k -----------------
+//== Initial transition matrix for state_variable[12]. (n_states x n_states)  ==//
+0.99 0.01
+0.01 0.99
+
+The following no longer used in the new switch.c:
+line 564 switch.c.
+// Initial transition matrix[1]  //
+0.8 0.1 0.1
+0.1 0.8 0.1
+0.1 0.1 0.8
+
+
+For the restrictions of the absorbing type:
+X  X  0
+X  X  0
+X  X  1
+
+we have:
+
+// Free parameters in state_variable[1] //
+3 3 1
+
+// Column restrictions for state_variable[1] //
+1 0 0
+0 1 0
+0 0 1
+
+1 0 0
+0 1 0
+0 0 1
+
+0
+0
+1
+//--------------------------------------------------------------------------//
diff --git a/tzDocumentation/readme_use_dwVARestimate.prn b/tzDocumentation/readme_use_dwVARestimate.prn
new file mode 100755
index 0000000..332ed23
--- /dev/null
+++ b/tzDocumentation/readme_use_dwVARestimate.prn
@@ -0,0 +1,162 @@
+Zeta in DW's output is Xi^2 in SWZ's JE article.  The prior on Zeta is gamma(a=1,b=1).  <<>> Check with Dan to be sure (17 Jan 2010 with Kirstin)
+   Sigma(k) = inv( A0(K) Zeta(k) A0(k)' )
+
+In the init_*.dat, the following is always true (hard-coded when using create_init_file.c):
+//== Specification (0=default  1=Sims-Zha  2=Random Walk) ==//
+1
+
+But if you want to change this, you must go into this file to do it manually.
+
+
+
+3by2 (e.g., 3 states for variances and 2 states for coefficients)
+
+sv 1         sv 2
+3 states    2 states
+A1-A3       B1-B2
+
+Block A1
+B1 and B2
+
+Block A2
+B1 and B2
+
+Block A3
+B1 and B2
+==>
+Overall Sates:  Individual Sates
+1.                 A1 B1
+2.                 A1 B2
+3.                 A2 B1
+4.                 A2 B2
+5.                 A3 B1
+6.                 A3 B2
+
+
+WriteTransitionMatrices(f_out,(char*)NULL,header,model);
+Write_VAR_Parameters(f_out,(char*)NULL,header,model);
+
+
+create_init_file <
+TZMatlab file> <DWSpecification file> file_tag name.
+Example
+exectuable datainp2_a_case2p2_sz5v_lp5011_d8507.prn specification2p2_3by2.dat test
+All these do is to read the SZ prior and the data and the starting point for the estimation.
+
+In Specification*.dat:
+//== Controlling states variables for coefficients ==//
+
+//== Controlling states variables for variance ==//
+
+
+In init_tag.dat, we have
+
+Mean of the prior.
+//== Initial: Transition matrix[1] ==//
+
+//== Initial: Transition matrix[2] ==//
+
+
+
+
+If -ft is chosen, -fs, -fr, and -rh will be all ignored.
+For -fr option, supply a different file with the data from //== Initial: Transition matrix[1] ==// on.
+    Perhaps change to //== Restart: ?????==//
+-rh "Restart: " in the command line.
+  or if I'm lazy, I would do the following instead:
+-rh "Initial: " in the command line.
+
+Another example:
+
+executable -ft tag -MLE -ce 1.03-6 -ii 1.5
+        //-ii can be a double.
+
+
+
+
+
+
+Input Command line:
+
+Group 1 (must specify most inputs).
+   Attempt to set up model from command line.  Command line options are the following
+
+   -di <directory>
+      If this argument exists, then all input files are in specified directory.
+
+   -ft <filename tag>
+      If this argument exists, then the following is attempted:
+
+         specification file name:  est_final_<tag>.dat
+         init/restart file name:   est_final_<tag>.dat with header="Posterior mode: "
+
+         specification file name:  init_<tag>.dat
+         init/restart file name:   est_intermediate_<tag>.dat with header="Iteration %d: "
+
+         (not yet implemented)
+         specification file name:  init_<tag>.dat
+         init/restart file name:   est_csminwel_<tag>.dat
+
+         specification file name:  init_<tag>.dat
+         init/restart file name:   init_<tag>.dat with header="Initial: "
+
+      Failure to load both the specification and restart/init files causes the routine to exit.
+
+   -fs <filename>
+      If this argument exists, then the specification file name is <filename>.  The argument -ft
+      takes precedence over -fs.
+
+   -fr <filename>
+      If this argument exists, then the init/restart file name is <filename>.  Must be used in
+      conjunction with the argument -fs.  The default value is the filename associated with the
+      argument -fs.
+
+   -rh <header>
+      If this argument exists, then the header for the init/restart file is <header>.  Must be
+      used in conjuction with the arguments -fr or -fs.  The default value is "".
+
+   If no command line options are given, then attemps to use a default input file
+   with the name "default.ini".  Returns one valid pointer to a TStateModel upon
+   success and null upon failure.
+
+
+Group 2 (either output or controlling execution of csminwel) (has a lot of default values).
+   Attempt to set up model from command line.  Command line options are the following
+
+   -do <directory>
+      If this argument exists, then all output files are put in the specified directory.
+
+   -fo <filename tag>
+      If this argument exists, then the output files are
+
+         est_csminwel_<tag>.dat
+         est_intermediate_<tag>.dat
+         est_final_<tag>.dat
+
+      The default value is the filename tag associated with the argument -ft if it exists.  Otherwise
+      it is "default".
+
+   -MLE
+      Find the maximum likelihood estimate
+
+   -PM (default)
+      Find the posterior mode
+
+   -cb <floating point number> (default = 1.0e-3)
+      Beginning csminwel exit criterion
+
+   -ce <floating point number> (default = 1.03-6)
+      Ending csminwel exit criterion
+
+   -ci <floating point number> (default = 0.1)
+      csminwel exit criterion increment multiplier
+
+   -ib <integer> (default = 50)
+      Beginning csminwel maximum iteration value
+
+   -ii <floating point number> (default = 2)
+      csminwel maximum interation increment multiplier
+
+   If no command line options are given, then attemps to use a default input file
+   with the name "default.ini".  Returns one valid pointer to a TStateModel upon
+   success and null upon failure.
diff --git a/tzDocumentation/readme_use_dwVARmhm.prn b/tzDocumentation/readme_use_dwVARmhm.prn
new file mode 100755
index 0000000..2132a3b
--- /dev/null
+++ b/tzDocumentation/readme_use_dwVARmhm.prn
@@ -0,0 +1,49 @@
+Example:
+
+swzmnhstage1 -fi MHM_input.dat -ft sz5v_2vby2m
+
+Command line:
+
+   Attempt to set up model from command line.  Command line options are the
+   following
+
+   -di <directory>
+      If this argument exists, then all input files are in specified directory.
+
+   -do <directory>
+      If this argument exists, then all output files are in specified directory.
+
+   -ft <filename tag>
+      If this argument exists, then the following is attempted:
+
+         1) specification file name:  mhm_final_<tag>.dat
+            mhm arguments file name:  mhm_final_<tag>.dat
+
+         2) specification file name:  mhm_intermediate_<tag>.dat
+            mhm arguments file name:  mhm_intermediate_<tag>.dat
+
+         3) specification file name:  est_final_<tag>.dat
+            mhm arguments file name:  -fi <filename>
+
+   -fi <filename>
+      If this argument exists, then additional mhm arguments are read from the
+      input file with the given filename.
+
+   -fs <filename>
+      If this argument exists, then the specification file name is <filename>.
+      The argument -ft takes precedence over -fs.
+
+   -fp <filename>
+      If this argument exists, then the posterior is read from <filename>.  Must
+      be used in conjunction with the argument -fs.  The default value is the
+      filename associated with the argument -fs.
+
+   -ph <header>
+      If this argument exists, then the header for the posterior file is
+      <header>.  Must be used in conjuction with the arguments -fp or -fs.  The
+      default value is "Posterior mode: ".
+
+   If no command line options are given, then attemps to use a default input file
+   with the name "default.ini".  Returns one valid pointer to a TStateModel upon
+   success and null upon failure.
+
diff --git a/tzDocumentation/readme_use_dwswitch.prn b/tzDocumentation/readme_use_dwswitch.prn
new file mode 100755
index 0000000..c62c1cc
--- /dev/null
+++ b/tzDocumentation/readme_use_dwswitch.prn
@@ -0,0 +1,769 @@
+                                  ********* Contents **********
+               **********  Guide for using Waggoner switch.c and switch_opt.c. **********
+/* Basic steps
+/* How to use DW regime contral table for DSGE and any regime-switching models
+/* Some basic DW's functions in his switch.h, such as likelihood, posterior, probabilities of regimes.
+/* Calling some switching variables from DW code
+     (1) Regime swaps.
+     (2) Grand, base, lagged regimes.
+     (3) Getting P(s_t = i | Y_{t-1}, theta) or P(s_t = i | Y_{t}, theta) using DW's ElementV() where
+           t is base-1 (1 to T) while i is base-0 (regimes 0 to h-1).
+     (4) Getting base regimes.
+     (5) Getting number of lags for a particular regime variable.
+     (6) Getting base transition probabilities.
+/* Notes on block-wise optimization in switch_opt.c
+/* How are overall states (regimes) ordered
+/* Dirichlet prior for a column of the transition probability matrix
+     in DW's initial Markov-switching data file used by the SWZ estimation procedure
+/* How to specify time variations for coefficients and variance sizes for the VAR model
+/* How to convert between model free parameters and model specific parameters (no transition matrix Q is involved)
+/* How to specify restrictions on each transition matrix Q_k
+/* How to obtain starting point of the transition matrix Q_k
+/* How to reset the probability of the initial state s_0
+/* How to set the transition matrix for the 3rd state that is redundant to the 2nd state
+/* How to call base regimes
+/* How to write out transition matrices
+/*
+/* DSGE output files
+                                  *****************************
+
+
+//==================================
+// Basic steps
+//==================================
+(-1) In extern_dw_switch.c, toggel between the old DW switch program
+            #include "switch.c"
+            #include "switchio.c"
+            #include "switch_opt.c"
+      and the new DW switch program
+            #include "dsge_switch.c"
+            #include "dsge_switchio.c"
+            #include "dsge_switch_opt.c"
+            #include "Dirichlet.c"
+
+(0) For the new DW switch program, make sure that in tzmatlab.h, use
+            #define NEWVERSIONofDW_SWITCH
+
+(1) In matrix.h, make sure the following line is activated and the other related lines (e.g., STRUCTURED_COLUMN_MAJOR) are disactivated:
+      #define TZ_COLUMN_MAJOR
+
+    In general toggle between #define STRUCTURED_COLUMN_MAJOR and #define TZ_COLUMN_MAJOR;
+
+(2) In matrix.h, make sure the following line is activated and the line #include "tz2dw.h" is disactivated:
+      #include "tzmatlab.h"
+
+    In general toggle between #include "tzmatlab.h" and #include "tz2dw.h"
+
+(3) In bmatrix.c, always comment out the following for Windows (Linux seems working fine; if not, we can always comment it out).
+
+      /********************
+      #include "blas_lapack.h"
+      #define USE_BLAS_LAPACK
+      /********************/
+
+      When this is commented out, Dan's code will work slower because it does not use any Blas and Lapack calls,
+        but Tao's code will be fine because he is using MKL.
+
+(4) To use the old code, uncomment the function in switch.c (at the end of this file):
+         TParameters* CreateParameters()
+
+(5) Make sure to uncomment out the function
+         int main(void)
+    in switchio.c.
+
+
+//==================================
+// How to use DW regime contral table for DSGE and any regime-switching models
+//==================================
+There three blocks of parameters: constant, coefficient TV, and volatility TV.
+It is better that each block is NOT empty.  If for some reasons one of the blocks is empty, saying,
+  the coeffivient TV block (Time varying coefficient parameters) is set to 0, then
+  use the following convention:
+    DWRegimeControlVariables_ps->cum_total_coef in the DW code  will be NULL;
+    DWRegimeControlVariables_ps->indx_st_coef in the DW code  will be NULL;
+      In this case, do not call dw_DimA(n_st_coef) because the program will crash and give an error.
+      To make it automatic, we can do this: if it is NULL, do not call dw_DimA(n_st_coef) or
+        create an macro (use define) to globally return (define) dw_DimA(n_st_coef) to be 0.
+
+
+Illustration:
+
+Parameters not time varying
+------
+X
+X
+X
+
+Coefficient parameters time varying
+------
+1st coefficient (2 regimes)
+X    <-- cum_total_coef[0] (=3)
+X
+
+2nd coefficient (3 regimes)
+X    <-- cum_total_coef[1] (=5)
+X
+X    <-- cum_total_coef[1] + (n_st_coef[1]-1) (= 7)
+
+Variance parameters time varying
+------
+1st variance parameter (2 regimes)
+X    <-- cum_total_var[0] (=8)
+X
+
+2st variance parameter (1 regime)
+X    <-- cum_total_var[1] (=10)
+
+3nd variance parameter (3 regimes)
+X
+X
+X
+
+Notes: (a) dw_DimA(n_st_coef) = 2 (coef parameters), dw_DimA(n_st_var) = 3 (variance parameters);
+       (b) n_st_coef[0] = 2 (regimes), n_st_coef[1] = 3 (regimes);
+           n_st_var[0] = 2 (regimes), n_st_var[1] = 1 (regime), n_st_var[2] = 3 (regimes);
+
+
+typedef struct TSDWRegimeControlVariables_tag
+{
+   //--- Memory of all the following arrays will be allocated by DW and destroyed by the DW function dw_FreeArray(),
+   //---   partly because DW allocated array with some information stored in the -2, -1 elements, so
+   //---   the array does not begin with base 0.   Thus, tzDestroy(n_coef) or free(n_coef)will NOT work.
+   //--- Thus, it's essential to destroy them using dw_FreeArray().
+
+   int n_constpars;  // number of constant (not time varying) free parameters.
+
+   int *n_st_coef;   //n_st_coef[i-1] is the number of regimes associated with the i_th time-varying coefficient parameter.
+   int *cum_total_coef; //cum_total_coef[i-1] is the offset of the i_th time-varying coefficient parameter
+                        //  in the whole vector of free parameters.
+   int **indx_st_coef; //indx_st_coef[st][i-1] is the regime associated with the i_th time-varying
+                       //  variance parameter with the grand regime st.
+
+   int *n_st_var; //n_st_var[i-1] is the number of regimes associated with the i_th time-varying variance parameter.
+   int *cum_total_var; //cum_total_var[i-1] is the offset of the i_th time-varying variance parameter
+                       //  in the whole vector of free parameters.
+   int **indx_st_var; //indx_var[st][i-1] is the regime associated with the i_th time-varying
+                      //  variance parameter with the grand regime st.
+                     //Use 1: g_sigma_w_dv->v[indx_st_var[st][2]] where 2 means that g_sigma_w_dv is the 3rd
+                     //         time-varying variance parameter to be considered.
+                     //Use 2: xphi_dv->v[cum_total_var[2]+indx_st_var[st][2]] where 2 means the 3rd time-varying
+                     //         variance parameters;  this value is the same as g_sigma_w_dv->v[idx_var[st][2]].
+} TSDWRegimeControlVariables;
+
+
+
+//==================================
+// Some basic DW's functions in his switch.h, such as likelihood, posterior, probabilities of regimes.
+//==================================
+// ln(P(y[t] | Y[t-1], Z[t], s[t], theta, q))
+#define LogConditionalLikelihood(s,t,model)  ((model)->routines->pLogConditionalLikelihood(s,t,model))
+
+// ln(P(y[t] | Y[t-1], Z[t], theta, q))
+PRECISION LogConditionalLikelihood_StatesIntegratedOut(int t, TStateModel *model);
+
+// E[y[t] | Y[t-1], Z[t], s[t], theta, q]
+#define ExpectationSingleStep(y,s,t,model) ((model)->routines->pExpectationSingleStep(y,s,t,model))
+
+// E[y[t] | Y[t-1], Z[t], theta, q]
+TVector ExpectationSingleStep_StatesIntegratedOut(TVector y, int t, TStateModel *model);
+
+// ln(P(q))
+PRECISION LogPrior_q(TStateModel *model);
+
+// ln(P(theta))
+#define LogPrior_theta(model)  ((model)->routines->pLogPrior(model))
+
+// ln(P(theta, q))
+#define LogPrior(model)  (LogPrior_theta(model) + LogPrior_q(model))
+
+// ln(P(S[T] | theta, q))
+PRECISION LogConditionalPrior_S(TStateModel *model);
+
+// ln(P(Y[T] | Z[T], S[T], theta, q)) = Assumes that the data is for fobs <= t <= nobs
+PRECISION LogLikelihood(TStateModel *model);
+
+// ln(P(Y[T] | Z[T], S[T], theta, Q) * P(S[T] | theta, q) * P(theta, q))
+#define LogPosterior(model)  (LogLikelihood(model) + LogConditionalPrior_S(model) + LogPrior(model))
+
+// ln(P(Y[T] | Z[T], theta, Q)) - Assumes that the data is for fobs <= t <= nobs
+PRECISION LogLikelihood_StatesIntegratedOut(TStateModel *model);
+
+// ln(P(Y[T] | Z[T], theta, q) * P(Theta, q))
+#define LogPosterior_StatesIntegratedOut(model)  (LogLikelihood_StatesIntegratedOut(model) + LogPrior(model))
+
+// ln(P(S[T] = S | Y[T], Z[T], theta, q))
+PRECISION LogConditionalProbabilityStates(int *S, TStateModel *model);
+
+// P(s[t] = s | Y[t], Z[t], theta, q)
+PRECISION ProbabilityStateConditionalCurrent(int s, int t, TStateModel *model);
+
+// P(s[t] = s | Y[t-1], Z[t-1], theta, q)
+PRECISION ProbabilityStateConditionalPrevious(int s, int t, TStateModel *model);
+
+// p[t] = P(s[t] = s | Y[T], Z[T], theta, q)
+TVector ProbabilitiesState(TVector p, int s, TStateModel *model);
+
+
+
+//==================================
+// Calling some switching variables from DW code
+//    (1) Regime swaps.
+//    (2) Grand, base, lagged regimes.
+//    (3) Getting P(s_t = i | Y_{t-1}, theta) or P(s_t = i | Y_{t}, theta) using DW's ElementV() where
+//          t is base-1 (1 to T) while i is base-0 (regimes 0 to h-1).
+//    (4) Getting base regimes.
+//    (5) Getting number of lags for a particular regime variable.
+//    (6) Getting base transition probabilities.
+//==================================
+(1) Regime swaps.
+   Swap_SV(smodel_ps->sv->state_variable[0], 0, si);
+
+
+(2) Grand, base, lagged regimes.
+   //------------ Index individual states from the grand state. -------------------//
+   Define the following:
+   struct TStateModel_tag *smodel
+   struct TMarkovStateVariable_tag *sv
+
+   smodel->sv->nstates (***grand*** number of states, seldom used by the user)
+   smodel->sv->n_state_variables (number of state variables)
+   smodel->sv->state_variable[0]->nbasestates (number of states for the 1st state variable)
+   smodel->sv->state_variable[0]->nstates (number of ***sub-grand** states for the 1st state variable,
+                  which equals nbasestates^nlags), where nlags is specified in the Markov input data file (see,
+                  for example, template_datainp_Markov.prn) as in the following 1-lag case for the 1st state variable:
+
+   //-----------------------------------------------------------------------------//
+   //-- Allows for lagged values of the state variable to be encoded            --//
+   //-----------------------------------------------------------------------------//
+   //== Number of lags encoded for state_variable[1] ==//
+   1
+
+   smodel->sv->state_variable[0]->lag_index (lagged states for the 1st state variable)
+   smodel->sv->state_variable[0]->nlags_encoded  (number of lags of the states for the 1st state variable)
+   smodel->sv->state_variable[0]->Q (transition matrix for 1st state variable)
+     Equivalently, smodel->sv->QA[0];
+
+
+   In the file switch.h, there is a structure called TMarkovStateVariable.
+   This sturcture contains a field called lag_index which is an array of arrays of integers.
+   This field provides for decoding the state indexes.  For instance, suppose there are 2 lags encoded,
+   so the grand state k would consist of three states (i_0,i_1,i_2) which would be the current state,
+   the first lagged state, and the second lagged state.  In this case we have that
+
+        lag_index[k][0] = i_0
+        lag_index[k][1] = i_1
+        lag_index[k][2] = i_2
+
+   This allows you to easily decode the grand state k.  Currently, Dan does not have a procedure for
+   going in the other direction to encode the grand state from the current and lagged states.
+
+
+(3) Getting P(s_t = i | Y_{t-1}, theta) or P(s_t = i | Y_{t}, theta) using DW's ElementV() where
+      t is base-1 (1 to T) while i is base-0 (regimes 0 to h-1).
+   int _t; //base-1 where my own C data is base-0, thus we need to use _t-1.
+   int _i; //base-0 regimes at time t.
+   P(s_t = i | Y_{t-1}, theta) = ElementV(smodel_ps->Z[_t],_i);
+   P(s_t = i | Y_{t}, theta) = ElementV(smodel_ps->V[_t],_i);
+   //---------------- Real example (OLD Code) -----------------//
+   prob_gainstate_dv->v[si] = 0.0;
+   for (ki=smodel_ps->sv->nstates-1; ki>=0; ki--)
+      if (smodel_ps->sv->state_variable[0]->lag_index[Index[ki][0]][0]==si)
+         prob_gainstate_dv->v[si] += ElementV(smodel_ps->Z[inpt],ki);
+           //July/2007.  prob_gainstate_dv->v[si] += ProbabilityStateGivenPreviousData(ki,inpt,smodel_ps);
+           //Cannot call the above function because it calls the likelihood function which creates an infinite loop.
+   gBeta_dm->M[mos(inpt,si,gBeta_dm->nrows)] = gBeta_dm->M[mloc] + prob_gainstate_dv->v[si]*exp(tvp7d_ps->loggain_dv->v[si]) * (ginf_dv->v[(nlags_max-1)+inpt0] - gBeta_dm->M[mloc]);
+
+
+(4) Getting base regimes.
+   Consider the following example
+      s_t = (m*_t, v_t) where m*_t = (m_t, m_{t-1}).
+   for s_t = k, we have
+      mstar = smodel_ps->sv->index[k][0]; //Old Code: smodel_ps->sv->Index[k][0];
+      v = smodel_ps->sv->index[k][1]; //Old Code: smodel_ps->sv->Index[k][1];
+      m_0 = smodel_ps->sv->state_variable[0]->lag_index[mstar][0];
+      m_1 = smodel_ps->sv->state_variable[0]->lag_index[mstar][1];
+   such that m_t = m_0, m_{t-1} = m_1, v_t = v.
+
+
+(5) Getting number of lags for a particular regime variable.
+   int nlags_statevariable0 = smodel_ps->sv->state_variable[0]->nlags_encoded;
+
+
+(6) Getting base transition probabilities.
+   New Code
+   -------------
+   sv_ComputeTransitionMatrix(0, smodel_ps->sv, smodel_ps);  //0 mean time 0 (in the time-varying Q, t means time t)
+            //This line must be used before copying it to any Q in case theta or q or anything has changed.
+   CopyMatrix0(Qc_dm, smodel_ps->sv->state_variable[0]->baseQ);  //$$##
+   Qc_dm->flag = M_GE;
+
+
+   OLD Code
+   -------------
+   Example: getting Qm for m_t.
+
+   Allocate the memory for MyMatrixQm and call
+
+      GetBaseTransitionMatrix_SV(MyMatrixQm, smodel->sv->state_variable[0]);
+
+   or call the following function, which creates MyMatrixQm as well
+
+      MyMatrixQm = GetBaseTransitionMatrix_SV(NULL, smodel->sv->state_variable[0]);
+
+   //--- Getting Qv for v_t ---
+   Simply call
+
+        smodel->sv->QA[1];
+
+   or
+
+        CopyMatrix0(MyMatrixQv, smodel->sv->QA[1]);
+
+   or
+
+        GetBaseTransitionMatrix_SV(MyMatrixQv, smodel->sv->state_variable[1]);
+
+
+
+//==================================
+// Notes on block-wise optimization in switch_opt.c
+//==================================
+In switch_opt.c, we have
+
+void SetupObjectiveFunction(TStateModel *model, PRECISION *Modified, PRECISION *FreeQ, PRECISION *FreeTheta)
+
+where FreeTheta points to free model parameters only (no free parameters in transition matricies);
+      FreeQ points to free q's in the transtiona matrices only;
+      Modified ponts to the location to be modified.
+*** Note that FreeQ and FreeTheta need not be adjacent. ***
+
+
+
+//==================================
+// How are overall states (regimes) ordered
+//==================================
+sv 1         sv 2
+3 states    2 states
+A1-A3       B1-B2
+
+Block A1
+B1 and B2
+
+Block A2
+B1 and B2
+
+Block A3
+B1 and B2
+==>
+Overall Sates:  Individual Sates
+1.                 A1 B1
+2.                 A1 B2
+3.                 A2 B1
+4.                 A2 B2
+5.                 A3 B1
+6.                 A3 B2
+
+
+
+//==================================
+// Dirichlet prior for a column of the transition probability matrix
+//   in DW's initial Markov-switching data file used by the SWZ estimation procedure
+//==================================
+Let x_h be a Dirichlet of form of Gelman (2004) where h be the number of states,
+   a_h be the diagonal parameter, and a_1, ..., a_{h-1}=1 to allow for an absorbing state.
+Let p be the probability of staying in that regime (for 20 months -- 1.7 years, p = 0.95;
+   for 6.7 quarters -- 1.67 years, p = 0.85)
+For E(x_h) = p, we have a_h/(h-1+a_h) = p, ==>
+    a_h = ( p/(1-p) )*(h-1)
+
+For monthly data, h=2, and p=0.95, a_h = 19.0e+000, ==>
+//== Transition matrix prior for state_variable[1]. (n_states x n_states) ==//
+ 19.0e+000                1.0000000000000000e+000
+ 1.0000000000000000e+000  19.0e+000
+
+For quarterly data, h=2, and p=0.85, a_h = 5.6666666666666661e+000, ==>
+//== Transition matrix prior for state_variable[1]. (n_states x n_states) ==//
+ 5.6666666666666661e+000  1.0000000000000000e+000
+ 1.0000000000000000e+000  5.6666666666666661e+000
+
+For quarterly data and restricted Q:
+    a    (1-b)/2     0
+    1-a   b          1-c
+    0     (1-b)/2    c
+h=3, and p=0.85, a_h = 5.67, ==>
+//== Transition matrix prior for state_variable[1]. (n_states x n_states) ==//
+  5.67   1.0   1.0
+   1.0  5.67   1.0
+   1.0   1.0  5.67
+
+For monthly data and restricted Q:
+    a    (1-b)/2     0
+    1-a   b          1-c
+    0     (1-b)/2    c
+h=3, and p=0.95, a_h = 19.0, ==>
+//== Transition matrix prior for state_variable[1]. (n_states x n_states) ==//
+ 19.000  1.0    1.0
+  1.0   19.00   1.0
+  1.0    1.0   19.00
+
+
+For quarterly data and unrestricted Q, h=3, and p=0.85, a_h = 11.333333, ==>
+//== Transition matrix prior for state_variable[1]. (n_states x n_states) ==//
+  11.33   1.0    1.0
+   1.0   11.33   1.0
+   1.0    1.0   11.33
+
+For quarterly data and unrestricted Q, h=4, and p=0.85, a_h = 17.0, ==>
+//== Transition matrix prior for state_variable[1]. (n_states x n_states) ==//
+  17.0    1.0    1.0    1.0
+   1.0   17.0    1.0    1.0
+   1.0    1.0   17.0    1.0
+   1.0    1.0    1.0   17.0
+
+
+
+//==================================
+// How to specify hard restrictions on each transitiona matrix Q_k
+//   in DW's initial Markov-switching data file used by the SWZ estimation procedure
+//==================================
+In specification*.prn or datainp_markovswitching*.prn or any file that contains Markov-switching information,
+   follow the following template:
+
+Suppose Q = [
+  p1      (1-p2)/2    0
+  1-p1      p2        1-p2
+  0       (1-p2)/2    p2
+  ];
+We have
+
+//== Free Dirichet dimensions for state_variable[1]  ==//
+2 2 2
+
+//== The jth restriction matrix is n_states-by-free[j].  Each row of the restriction
+//== matrix has exactly one non-zero entry and the sum of each column must be one.
+//== Column restrictions for state_variable[1] ==//
+1 0
+0 1
+0 0
+
+0.5  0
+0    1
+0.5  0
+
+0 0
+1 0
+0 1
+
+For the restrictions of the absorbing type:
+   X  X  0
+   X  X  0
+   X  X  1
+we have:
+
+// Free parameters in state_variable[1] //
+3 3 1
+
+// Column restrictions for state_variable[1] //
+1 0 0
+0 1 0
+0 0 1
+
+1 0 0
+0 1 0
+0 0 1
+
+0
+0
+1
+
+Other examples:
+
+Example 1:
+1 0 0
+0 1 0
+0 0 1
+Example 2 (3 states but 2 semi-free parameters for column j of Q_1):
+0 0
+1 0
+0 1
+which gives the free-parameter vector [0 q_2 q_3] where q_2 + q_3 = 1.0.
+
+
+
+//==================================
+// How to specify time variations for coefficients and variance sizes for the VAR model
+//==================================
+Note that the first column corresponds to the first state variable, and so forth.
+
+For example:
+
+//== nvar x n_state_variables matrix.  In the jth row, a non-zero value implies that
+//== this state variable controls the jth column of A0 and Aplus
+//== Controlling states variables for coefficients ==//
+0  0
+0  0
+0  0
+0  0
+0  1
+
+//== nvar x n_state_variables matrix.  In the jth row, a non-zero value implies that
+//== this state variable controls the jth diagonal element of Xi
+//== Controlling states variables for variance ==//
+ 1  0
+ 1  0
+ 1  0
+ 1  0
+ 1  0
+
+Clearly, the 1st state variable corresponds to variance sizes and the 2nd state variable corresponds to coefficients.
+  for coefficient, only the fifth equation is time variation.
+
+
+
+
+//==================================
+// How to convert between model free parameters and model specific parameters (no transition matrix Q is involved)
+//==================================
+When calling Waggoner's function CreateParameters(), one needs supply the two functions to which Waggoner's
+  function names point.  These two Waggoner's function names (of course, the functions are supplied by the
+  user himself) are:
+    ConvertFreeParametersToTheta(smodel_ps, xphi_sdv.v);   //Waggoner's function.
+         //Converting the vectorized free model parameters and the model specific (and meaningful) parameters.
+    ConvertFreeParametersToQ(smodel_ps, xqs_sdv.v);   //Waggoner's function.
+         //Converting the model specific (and meaningful) parameters to the vectorized free model parameters.
+
+
+
+
+//==================================
+// How to specify restrictions on each transitiona matrix Q_k
+//==================================
+//----------------- The semi-free parameter vector: free -----------------
+//The vector, free, indictates the number of semi-free parameters in each column of Q_k.  By semi-free, we
+//  meen that the sum of each column in Q_k is 1.0 so that the number of true free parameters is one less.
+//== Free Dirichet dimensions for state_variable[1]  ==//
+2 2
+
+//----------------- The restriction matrix R_j -----------------
+//== The jth restriction matrix is n_states-by-free[j].  Each row of the restriction
+//== matrix has exactly one non-zero entry and the sum of each column must be one.
+
+
+
+
+
+
+//==================================
+// How to obtain starting point of the transition matrix Q_k
+//==================================
+Without supplying initial Q, DW's code will use the prior mean of Q as a starting point (default).
+To have a random starting point, call in the C file:
+      DrawTransitionMatrixFromPrior(smodel_est_ps);
+To mannually supply initial Q_k, (1) use the following 2-state 1-variable example in the input file datainp_markovswitching*.prn:
+         //== indxInitializeTransitionMatrix ==//
+         1
+
+         //== Initial: Transition matrix ==//
+         1.0 1.0
+         0.0 0.0
+  (2) call DW's function in the C file:
+        ReadTransitionMatrices(fptr_markov, (char*)NULL, "Initial: ", smodel_ps);  //Waggoner's function..
+  (3) for more complicated cases such as 2 independent state variables, we can have the following:
+         //== Initial: Transition matrix[1] ==//
+          0.5   0.5
+          0.5   0.5
+
+         //== Initial: Transition matrix[2] ==//
+          0.9   0.2
+          0.1   0.8
+
+
+
+//==================================
+// How to reset the probability of the initial state s_0
+//==================================
+At two places in switch.c, change the values (1: use ergodic distribution; 0: use 1/h for overall Q):
+         sv->UseErgodic=1;  //in line 239
+         sv->UseErgodic=1;  //in line 344
+
+
+//==================================
+// How to set the transition matrix for the 3rd state that is redundant to the 2nd state
+//==================================
+Say the estimated 2-state transition matrix is:
+
+   p11 p12
+   p21 p22
+
+Then the initial value of the 3-state transition matrix should be in the following form:
+
+   p11 p12 p12
+   p21 p22 p23
+   0   0   p33
+
+where p23+p33 = p22.
+
+Matlab example about the ergodic properties of these transition matrices:
+x1 = [
+   0.9 0.2
+   0.1 0.8
+    ];
+e1=fn_ergodp(x)
+e1 =
+    0.6667
+    0.3333
+
+x2 = [
+   0.9 0.2 0.2
+   0.1 0.8 0.3
+   0.0 0.0 0.5
+    ];
+e2=fn_ergodp(x2)
+e2 =
+    0.6667
+    0.3333
+         0
+
+x2 = [
+    0.9000    0.2000    0.2000
+    0.1000    0.8000         0
+         0         0    0.8000
+      ];
+e2=fn_ergodp(x2)
+e2 =
+    0.6667
+    0.3333
+         0
+
+x2 = [
+    0.9000    0.2000         0
+    0.1000    0.8000    0.3000
+         0         0    0.7000
+         ];
+e2=fn_ergodp(x2)
+e2 =
+    0.6667
+    0.3333
+         0
+
+x2 = [
+    0.9000    0.2000         0
+    0.1000    0.8000         0
+         0         0    1.0000
+     ];
+e2=fn_ergodp(x2)
+e2 =
+     0
+     0
+     1
+
+e2=fn_ergodp(eye(4))
+e2 =
+     0
+     0
+     0
+     1
+
+
+
+//==================================
+// How to call base regimes
+//==================================
+int **Index = smodel_ps->sv->Index;  //Regime-switching states.
+//--- Example 1 (two types of state variables) where s_t is an overall state variable combining the both state variables.
+st_d = st_dshocks = Index[s_t][0];  //[0]: 1st state variable.
+st_gain = Index[s_t][1];  //[1]: 2nd state variable.
+
+
+//==================================
+// How to write out transition matrices
+//==================================
+printf("Obj. func. value: %g\n", *fret_p);
+WriteTransitionMatrices(stdout, (char*)NULL, "DDDDebugging: ", SMODEL_PS);  //Waggoner's function.
+fgetc(stdin);   //fgetc(stdin) will automatically fflush(stdout).  Use ctrl-c to stop the program.
+
+
+//==================================
+// DSGE output files
+//==================================
+          Output format for ir_percentiles_TAG.prn reporting impulse responses with error bands
+-------------------------------------------------------------------------------------------------------
+Each block represents the responses corresponding to each percentile.  In each block, the element in the position (k,i+j*nz) is the response of the ith state variable to the jth shock at horizon k.  The variable nz is the total number of states. Shocks 0 through nepsilon-1 are fundamental and shocks nepsilon through nepsilon+nu-1 aremeasurement error.  Horizon 0 is the contemporaneous response.
+
+This files contains the impulse responses of the unobservable variables.   The code to produce the impulse responses of the observable variables has been commented out and so would be easy to produce.
+
+
+              Output format for simulation_TAG.prn reporting posterior draws of parameters
+-------------------------------------------------------------------------------------------------------
+Rows:                     posterior draws saved after the burning period and the thinning factor
+Column 1:                 log posterior (states integrated out)
+Column 2:                 log likelihood (states integrated out)
+Columns 3-length(Theta):  free model specific parameters (Theta)
+Columns (last)            free transition matrix parameters (q)
+
+The draws were generated with a burn-in period of 10,000 draws, this was starting from the posterior mode after the adaptive code had run to determine the jumping kernel.  Example: two files contain 100,000 draws, but the thinning factor for the constant parameter case was 10 (1,000,000 total draws) while the thinning factor for the 2v case was 5 (500,000 total draws).
+
+
+
+
+
+
+
+
+//-------------------------
+// How to use switch.c
+//-------------------------
+For call of the old functions, uncomment the following functions in switch.c
+
+TParameters* CreateParameters()
+
+
+
+
+
+
+
+Tempary fix
+in switch.h and switch.c
+  //=== Control variables ===
+  int UseErgodic;  //1: use ergodic; 0: use 1/h for Q (not individual Q_k).
+
+===================================================================================================
+
+
+sv->UseErgodic=1; //in switch.c.
+
+//------------------------------------------------------------
+// Functions required by CreateParameters() in switch.c.
+//------------------------------------------------------------
+int NumberOfFreeModelSpecificParameters(struct TStateModel_tag *smodel_ps)
+{
+   struct TStvp7d_tag *tvp7d_ps = (struct TStvp7d_tag *)smodel_ps->p->p;
+   return (tvp7d_ps->gphi_dv->n);
+}
+//---
+void ConvertFreeParameters2ModelSpecificParameters(struct TStateModel_tag *smodel_ps, PRECISION *xopt_pd)
+{
+   //xopt_pd: the (temporary) vector of free model parameters for optimization or minimization.
+   struct TStvp7d_tag *tvp7d_ps = (struct TStvp7d_tag *)smodel_ps->p->p;
+   memcpy(tvp7d_ps->gphi_dv->v, xopt_pd, tvp7d_ps->gphi_dv->n);
+   $$$$$$ This gphi_dv must also be syncronized with interpretable individual parameters, which I forgot to do. ??????????
+   $$$$$$ Convertphi2indpars(tvp7d_ps);
+}
+//---
+void ConvertModelSpecificParameters2FreeParameters(struct TStateModel_tag *smodel_ps, PRECISION *xopt_pd)
+{
+   //xopt_pd: the (temporary) vector of free model parameters for optimization or minimization.
+   struct TStvp7d_tag *tvp7d_ps = (struct TStvp7d_tag *)smodel_ps->p->p;
+   $$$$$$$$$$$$$ Convertindpars2phi(tvp7d_ps);
+   memcpy(xopt_pd, tvp7d_ps->gphi_dv->v, tvp7d_ps->gphi_dv->n);
+}
+
+
+
+
+ConvertFreeParametersToTheta(smodel_ps, xphi_sdv.v);   //Waggoner's function.
+ConvertFreeParametersToQ(smodel_ps, xqs_sdv.v);   //Waggoner's function.
+smodel_ps->ValidForwardRecursion = 0;  //Reset so recursion can do through.
+logvalue = LogLikelihoodGivenParameters(smodel_ps);  //log(P(Y_T|theta, Q)).  Waggoner's function.
+
diff --git a/tzDocumentation/testjunk.prn b/tzDocumentation/testjunk.prn
new file mode 100755
index 0000000..2132a3b
--- /dev/null
+++ b/tzDocumentation/testjunk.prn
@@ -0,0 +1,49 @@
+Example:
+
+swzmnhstage1 -fi MHM_input.dat -ft sz5v_2vby2m
+
+Command line:
+
+   Attempt to set up model from command line.  Command line options are the
+   following
+
+   -di <directory>
+      If this argument exists, then all input files are in specified directory.
+
+   -do <directory>
+      If this argument exists, then all output files are in specified directory.
+
+   -ft <filename tag>
+      If this argument exists, then the following is attempted:
+
+         1) specification file name:  mhm_final_<tag>.dat
+            mhm arguments file name:  mhm_final_<tag>.dat
+
+         2) specification file name:  mhm_intermediate_<tag>.dat
+            mhm arguments file name:  mhm_intermediate_<tag>.dat
+
+         3) specification file name:  est_final_<tag>.dat
+            mhm arguments file name:  -fi <filename>
+
+   -fi <filename>
+      If this argument exists, then additional mhm arguments are read from the
+      input file with the given filename.
+
+   -fs <filename>
+      If this argument exists, then the specification file name is <filename>.
+      The argument -ft takes precedence over -fs.
+
+   -fp <filename>
+      If this argument exists, then the posterior is read from <filename>.  Must
+      be used in conjunction with the argument -fs.  The default value is the
+      filename associated with the argument -fs.
+
+   -ph <header>
+      If this argument exists, then the header for the posterior file is
+      <header>.  Must be used in conjuction with the arguments -fp or -fs.  The
+      default value is "Posterior mode: ".
+
+   If no command line options are given, then attemps to use a default input file
+   with the name "default.ini".  Returns one valid pointer to a TStateModel upon
+   success and null upon failure.
+
-- 
GitLab