MS-SBVAR: correcting bug in handling of exclusion of constants. Changed options_.ms.Qi and options_.ms.Ri from 3 dimension arrays into cellarray of matrices.
parent
6f406ffca1
commit
54b813d3d7
|
@ -3,7 +3,7 @@ function [Ui,Vi,n0,np,ixmC0Pres] = exclusions(nvar,nexo,options_ms)
|
||||||
indxC0Pres = options_ms.cross_restrictions;
|
indxC0Pres = options_ms.cross_restrictions;
|
||||||
nlags = options_ms.nlags;
|
nlags = options_ms.nlags;
|
||||||
|
|
||||||
Qi = options_ms.Qi;
|
Qi1 = options_ms.Qi;
|
||||||
Ri1 = options_ms.Ri;
|
Ri1 = options_ms.Ri;
|
||||||
|
|
||||||
Ui = cell(nvar,1);
|
Ui = cell(nvar,1);
|
||||||
|
@ -13,19 +13,24 @@ np = zeros(nvar,1);
|
||||||
|
|
||||||
k = nlags*nvar+1;
|
k = nlags*nvar+1;
|
||||||
|
|
||||||
Ri = zeros(k,k,nvar);
|
|
||||||
sR = size(Ri1);
|
|
||||||
Ri(1:sR(1),1:sR(2),1:sR(3)) = Ri1;
|
|
||||||
|
|
||||||
if options_ms.constants_exclusion
|
|
||||||
for i=1:nvar
|
|
||||||
Ri(i,k,i) = 1;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for n=1:nvar
|
for n=1:nvar
|
||||||
Ui{n} = null(Qi(:,:,n));
|
Qi{n} = zeros(nvar,nvar);
|
||||||
Vi{n} = null(Ri(:,:,n));
|
sQ = size(Qi1{n});
|
||||||
|
if all(sQ) > 0
|
||||||
|
Qi{n}(1:sQ(1),1:sQ(2)) = Qi1{n};
|
||||||
|
end
|
||||||
|
Ri{n} = zeros(k,k);
|
||||||
|
sR = size(Ri1{n});
|
||||||
|
if all(sR) > 0
|
||||||
|
Ri{n}(1:sR(1),1:sR(2)) = Ri1{n};
|
||||||
|
end
|
||||||
|
|
||||||
|
if options_ms.constants_exclusion
|
||||||
|
Ri{n}(sR(1)+1,k) = 1;
|
||||||
|
end
|
||||||
|
|
||||||
|
Ui{n} = null(Qi{n});
|
||||||
|
Vi{n} = null(Ri{n});
|
||||||
n0(n) = size(Ui{n},2);
|
n0(n) = size(Ui{n},2);
|
||||||
np(n) = size(Vi{n},2);
|
np(n) = size(Vi{n},2);
|
||||||
end
|
end
|
||||||
|
|
|
@ -1226,8 +1226,8 @@ SvarIdentificationStatement::writeOutput(ostream &output, const string &basename
|
||||||
<< "error in the specification of the .mod file, please report it to the Dynare Team." << endl;
|
<< "error in the specification of the .mod file, please report it to the Dynare Team." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
output << "options_.ms.Qi = zeros(" << n << ", " << n << ", " << n << ");" << endl;
|
output << "options_.ms.Qi = cell(" << n << ",1);" << endl;
|
||||||
output << "options_.ms.Ri = zeros(" << k << ", " << k << ", " << n << ");" << endl;
|
output << "options_.ms.Ri = cell(" << n << ",1);" << endl;
|
||||||
|
|
||||||
vector<int> rows(n);
|
vector<int> rows(n);
|
||||||
fill(rows.begin(),rows.end(),1);
|
fill(rows.begin(),rows.end(),1);
|
||||||
|
@ -1251,7 +1251,7 @@ SvarIdentificationStatement::writeOutput(ostream &output, const string &basename
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lag == 0)
|
if (lag == 0)
|
||||||
output << "options_.ms.Qi(" << h+1 << ", " << j << ", "<< i << ") = 1;" << endl;
|
output << "options_.ms.Qi{" << i << "}(" << h+1 << ", " << j << ") = 1;" << endl;
|
||||||
else if (lag > 0)
|
else if (lag > 0)
|
||||||
{
|
{
|
||||||
if ((lag-1)*n+j > k)
|
if ((lag-1)*n+j > k)
|
||||||
|
@ -1259,7 +1259,7 @@ SvarIdentificationStatement::writeOutput(ostream &output, const string &basename
|
||||||
cerr << "ERROR: lag =" << lag << ", num endog vars = " << n << "current endog var index = " << j << ". Index "
|
cerr << "ERROR: lag =" << lag << ", num endog vars = " << n << "current endog var index = " << j << ". Index "
|
||||||
<< "out of bounds. If the above does not represent a logical error, please report this to the Dyanre Team." << endl;
|
<< "out of bounds. If the above does not represent a logical error, please report this to the Dyanre Team." << endl;
|
||||||
}
|
}
|
||||||
output << "options_.ms.Ri(" << rows[i-1] << ", " << (lag-1)*n+j << ", "<< i << ") = 1;" << endl;
|
output << "options_.ms.Ri{" << i << "}(" << rows[i-1] << ", " << (lag-1)*n+j << ") = 1;" << endl;
|
||||||
rows[i-1]++;
|
rows[i-1]++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue