Skip to content
Snippets Groups Projects
Verified Commit fc0a4a7a authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Fix bug, pac.bgp.set should also work with exogenous variables.

(cherry picked from commit 60c8ed19)
parent 31ba42e2
Branches
Tags
No related merge requests found
......@@ -33,7 +33,15 @@ global M_
eqtag = M_.pac.(pacmodel).tag_map{strcmp(paceq, M_.pac.(pacmodel).tag_map(:,1)),2};
dummy = [];
ide = find(strcmp(variable, M_.endo_names));
xflag = false;
if isempty(ide)
% variable is not an endogenous variable
ide = find(strcmp(variable, M_.exo_names));
xflag = true;
end
if ~isempty(ide)
if isfield(M_.pac.(pacmodel).equations.(eqtag), 'additive') && length(M_.pac.(pacmodel).equations.(eqtag).additive.vars)>1
if ~isfield(M_.pac.(pacmodel).equations.(eqtag).additive, 'bgp')
......@@ -41,6 +49,11 @@ if ~isempty(ide)
end
[isvar, ie] = ismember(ide, M_.pac.(pacmodel).equations.(eqtag).additive.vars);
if isvar
if xflag
assert(~M_.pac.(pacmodel).equations.(eqtag).additive.isendo(ie), 'Variable type issue.')
else
assert(M_.pac.(pacmodel).equations.(eqtag).additive.isendo(ie), 'Variable type issue.')
end
M_.pac.(pacmodel).equations.(eqtag).additive.bgp(ie) = nonzeromean;
return
end
......@@ -51,6 +64,11 @@ if ~isempty(ide)
end
[isvar, ie] = ismember(ide, M_.pac.(pacmodel).equations.(eqtag).optim_additive.vars);
if isvar
if xflag
assert(~M_.pac.(pacmodel).equations.(eqtag).optim_additive.isendo(ie), 'Variable type issue.')
else
assert(M_.pac.(pacmodel).equations.(eqtag).optim_additive.isendo(ie), 'Variable type issue.')
end
M_.pac.(pacmodel).equations.(eqtag).optim_additive.bgp(ie) = nonzeromean;
return
end
......@@ -61,11 +79,16 @@ if ~isempty(ide)
end
[isvar, ie] = ismember(ide, M_.pac.(pacmodel).equations.(eqtag).non_optimizing_behaviour.vars);
if isvar
if xflag
assert(~M_.pac.(pacmodel).equations.(eqtag).non_optimizing_behaviour.isendo(ie), 'Variable type issue.')
else
assert(M_.pac.(pacmodel).equations.(eqtag).non_optimizing_behaviour.isendo(ie), 'Variable type issue.')
end
M_.pac.(pacmodel).equations.(eqtag).non_optimizing_behaviour.bgp(ie) = nonzeromean;
return
end
end
warning('%s is not an exogenous variable in equation %s.', variable, paceq)
else
error('Endogenous variable %s is unknown.', variable)
error('Endogenous/Exogenous variable %s is unknown.', variable)
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment