finalize svar_global_identification_check
parent
a88d1bd0f8
commit
511801c903
|
@ -1,4 +1,4 @@
|
|||
function [Ui,Vi,n0,np,ixmC0Pres,Qi] = exclusions(nvar,nexo,options_ms)
|
||||
function [Ui,Vi,n0,np,ixmC0Pres,Qi,Ri] = exclusions(nvar,nexo,options_ms)
|
||||
% function [Ui,Vi,n0,np,ixmC0Pres] = exclusions(nvar,nexo,options_ms)
|
||||
%
|
||||
% INPUTS
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
function indent = sbvar_global_identification_check(options_)
|
||||
% function sbvar_global_identification_check(options_.ms)
|
||||
function indent = svar_global_identification_check(options_)
|
||||
% function svar_global_identification_check(options_.ms) checks
|
||||
% identification of s structural VAR
|
||||
%
|
||||
% INPUTS
|
||||
% options_ms: (struct) options
|
||||
|
@ -9,6 +10,11 @@ function indent = sbvar_global_identification_check(options_)
|
|||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
%
|
||||
% REFERENCES
|
||||
% J. Rubio Ramirez, D. Waggoner, T. Zha (2010) "Structural Vector
|
||||
% Autoregressions: Theory of Identification and Algorithms for
|
||||
% Inference" in Review of Economic Studies, 77, 665-696.
|
||||
|
||||
% Copyright (C) 2015 Dynare Team
|
||||
%
|
||||
|
@ -42,28 +48,34 @@ end
|
|||
nvar = length(options_.varobs); % number of endogenous variables
|
||||
nexo = 1;
|
||||
|
||||
[Uiconst,Viconst,n0,np,ixmC0Pres,Qi] = exclusions(nvar,nexo,options_.ms );
|
||||
[Uiconst,Viconst,n0,np,ixmC0Pres,Qi,Ri] = exclusions(nvar,nexo,options_.ms );
|
||||
|
||||
% order column constraints by rank
|
||||
Qranks = zeros(nvar,2);
|
||||
QQranks = zeros(nvar,2);
|
||||
for j=1:nvar
|
||||
Qranks(j,:) = [j,rank(Qi{j})];
|
||||
n = nvar*(options_.ms.nlags+1);
|
||||
QQi{j} = zeros(n,n);
|
||||
QQi{j}(1:nvar,1:nvar) = Qi{j};
|
||||
QQi{j}(nvar+1:end,nvar+1:end) = Ri{j}(1:end-1,1:end-1);
|
||||
QQranks(j,:) = [j,rank(QQi{j})];
|
||||
end
|
||||
Qranks = sortrows(Qranks,-2);
|
||||
QQranks = sortrows(QQranks,-2);
|
||||
|
||||
ident = true;
|
||||
|
||||
for j=1:nvar
|
||||
i = Qranks(j,1);
|
||||
i = QQranks(j,1);
|
||||
for k=1:1
|
||||
M = [Qi{i}*rand(size(Qi{i},1),nvar);[eye(j) zeros(j,nvar- ...
|
||||
j)]];
|
||||
disp([j,k,rank(M)])
|
||||
M = [QQi{i}*rand(size(QQi{i},1),nvar);[eye(j) ...
|
||||
zeros(j,nvar-j)]];
|
||||
if rank(M) < nvar
|
||||
ident = false
|
||||
ident = false;
|
||||
break
|
||||
end
|
||||
end
|
||||
if ~ident
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if ~options_.noprint
|
|
@ -1627,6 +1627,8 @@ SvarIdentificationStatement::getMaxLag() const
|
|||
void
|
||||
SvarIdentificationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||
{
|
||||
// no equations OK with Svar Identification
|
||||
mod_file_struct.bvar_present = true;
|
||||
if (!mod_file_struct.svar_identification_present)
|
||||
mod_file_struct.svar_identification_present = true;
|
||||
else
|
||||
|
@ -1704,6 +1706,7 @@ SvarIdentificationStatement::writeOutput(ostream &output, const string &basename
|
|||
it->value->writeOutput(output);
|
||||
output << ";" << endl;
|
||||
}
|
||||
output << "options_.ms.nlags = " << r << ";" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2010,6 +2013,16 @@ SvarStatement::writeOutput(ostream &output, const string &basename, bool minimal
|
|||
output << "'ALL';" << endl;
|
||||
}
|
||||
|
||||
SvarGlobalIdentificationCheckStatement::SvarGlobalIdentificationCheckStatement(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
SvarGlobalIdentificationCheckStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||
{
|
||||
output << "svar_global_identification_check(options_);" << std::endl;
|
||||
}
|
||||
|
||||
SetTimeStatement::SetTimeStatement(const OptionsList &options_list_arg) :
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
|
|
|
@ -640,6 +640,13 @@ public:
|
|||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||
};
|
||||
|
||||
class SvarGlobalIdentificationCheckStatement : public Statement
|
||||
{
|
||||
public:
|
||||
SvarGlobalIdentificationCheckStatement();
|
||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||
};
|
||||
|
||||
class SetTimeStatement : public Statement
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -157,7 +157,7 @@ class ParsingDriver;
|
|||
%token MS_ESTIMATION MS_SIMULATION MS_COMPUTE_MDD MS_COMPUTE_PROBABILITIES MS_FORECAST
|
||||
%token SVAR_IDENTIFICATION EQUATION EXCLUSION LAG UPPER_CHOLESKY LOWER_CHOLESKY MONTHLY QUARTERLY
|
||||
%token MARKOV_SWITCHING CHAIN DURATION NUMBER_OF_REGIMES NUMBER_OF_LAGS
|
||||
%token SVAR COEFF COEFFICIENTS VARIANCES CONSTANTS EQUATIONS
|
||||
%token SVAR SVAR_GLOBAL_IDENTIFICATION_CHECK COEFF COEFFICIENTS VARIANCES CONSTANTS EQUATIONS
|
||||
%token EXTERNAL_FUNCTION EXT_FUNC_NAME EXT_FUNC_NARGS FIRST_DERIV_PROVIDED SECOND_DERIV_PROVIDED
|
||||
%token SELECTED_VARIABLES_ONLY COVA_COMPUTE SIMULATION_FILE_TAG FILE_TAG
|
||||
%token NO_ERROR_BANDS ERROR_BAND_PERCENTILES SHOCKS_PER_PARAMETER NO_CREATE_INIT
|
||||
|
@ -258,6 +258,7 @@ statement : parameters
|
|||
| conditional_forecast_paths
|
||||
| plot_conditional_forecast
|
||||
| svar_identification
|
||||
| svar_global_identification_check
|
||||
| markov_switching
|
||||
| svar
|
||||
| external_function
|
||||
|
@ -850,6 +851,10 @@ restriction_elem_expression : COEFF '(' symbol COMMA INT_NUMBER ')'
|
|||
{ driver.add_positive_restriction_element($1,$5,$7);}
|
||||
;
|
||||
|
||||
svar_global_identification_check: SVAR_GLOBAL_IDENTIFICATION_CHECK ';'
|
||||
{ driver.add_svar_global_identification_check(); }
|
||||
;
|
||||
|
||||
markov_switching : MARKOV_SWITCHING '(' ms_options_list ')' ';'
|
||||
{ driver.markov_switching(); }
|
||||
;
|
||||
|
|
|
@ -163,6 +163,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
|
|||
|
||||
<INITIAL>markov_switching {BEGIN DYNARE_STATEMENT; return token::MARKOV_SWITCHING;}
|
||||
<INITIAL>svar {BEGIN DYNARE_STATEMENT; return token::SVAR;}
|
||||
<INITIAL>svar_global_identification_check {BEGIN DYNARE_STATEMENT; return token::SVAR_GLOBAL_IDENTIFICATION_CHECK;}
|
||||
<INITIAL>external_function {BEGIN DYNARE_STATEMENT; return token::EXTERNAL_FUNCTION;}
|
||||
/* End of a Dynare statement */
|
||||
<INITIAL>calib_smoother { BEGIN DYNARE_STATEMENT; return token::CALIB_SMOOTHER; }
|
||||
|
|
|
@ -1013,6 +1013,12 @@ ParsingDriver::add_constants_exclusion()
|
|||
svar_constants_exclusion = true;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::add_svar_global_identification_check()
|
||||
{
|
||||
mod_file->addStatement(new SvarGlobalIdentificationCheckStatement);
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::do_sigma_e()
|
||||
{
|
||||
|
|
|
@ -485,6 +485,8 @@ public:
|
|||
void add_upper_cholesky();
|
||||
//! Svar_Identification Statement: restriction of form lower cholesky
|
||||
void add_lower_cholesky();
|
||||
//! Svar_Global_Identification_Check Statement
|
||||
void add_svar_global_identification_check();
|
||||
//! Forecast Statement
|
||||
void forecast();
|
||||
void set_trends();
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
var Pie Y R;
|
||||
|
||||
varobs Pie Y R;
|
||||
|
||||
svar_identification;
|
||||
exclusion lag 0;
|
||||
equation 1, R;
|
||||
exclusion lag 1;
|
||||
equation 1, Y, R;
|
||||
equation 2, Pie, R;
|
||||
equation 3, Pie, Y;
|
||||
exclusion lag 2;
|
||||
equation 1, Y, R;
|
||||
equation 2, Pie, R;
|
||||
equation 3, Pie, Y, R;
|
||||
restriction equation 1, coeff(R,0) - coeff(Pie,0) = 0;
|
||||
end;
|
||||
|
||||
svar_global_identification_check;
|
||||
|
|
@ -10,7 +10,5 @@ exclusion lag 1;
|
|||
equation 2, Y;
|
||||
end;
|
||||
|
||||
sbvar_global_identification_check(options_);
|
||||
|
||||
sbvar(datafile = data,freq=4,initial_year=1959,final_year=2005,nlags=4);
|
||||
svar_global_identification_check;
|
||||
|
Loading…
Reference in New Issue