Skip to content
Snippets Groups Projects
Commit 99037e74 authored by tzha's avatar tzha
Browse files

Add tzDocumentation and activate .prn files in .gitignore

parent a71ed835
No related branches found
No related tags found
No related merge requests found
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
.DS_Store .DS_Store
# Use wildcards as well # Use wildcards as well
# *.prn
*~ *~
*.mat *.mat
*.pyc *.pyc
*.prn
*.aux *.aux
*.log *.log
*.dvi *.dvi
...@@ -19,6 +20,7 @@ ...@@ -19,6 +20,7 @@
*.pdf *.pdf
*.npy *.npy
*.o *.o
*.dll
# Can also ignore all directories and files in a directory. # Can also ignore all directories and files in a directory.
# tmp/**/* # tmp/**/*
**********************************************************************
************************** 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).
/******************************************************************************/
/********************* 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
//--------------------------------------------------------------------------//
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.
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.
This diff is collapsed.
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.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment