1. how to load steady state values into mod file?
2. how to call a matlab function within the model block?
My purpose is to have a loop over parameters to see how IRF and other endogenous variables behave. Because of changing exogenously specified deep parameters, the utility function form and thus the marginal utility form in the Euler equation will change, as well as all steady state values.
The scenario is like this: first, I have defined a matlab function "solveSS" that with solve for steady state values of all endogenous variables according to exogenously given deep parameters (all deep parameters are exogenously specified); second, I have defined a matlab function call "unmu" which return utility and marginal utility when two variables and some exogenously specified parameters are input, so
- Code: Select all
function [u muc muh]=unmu(c,h,paras)
if paras==1
u=....% equation that calculate utility level
muc=... % calculate marginal utility of c
muh=... % calculate marginal utility of h
else
u=....% equation that calculate utility level
muc=... % calculate marginal utility of c
muh=... % calculate marginal utility of h
end
Obviously, the way to calculate marginal utility depends on the parameters input.
Could anyone provide some hints about how to do such loops?
Ideally, I would think it is feasible to code like this:
- Code: Select all
//**************************************
// dynare mod file
//**************************************
//**************************************
// Declare variables and parameters
//**************************************
var ...
varexo ...
parameters ...
// provide parameter values
load parameters.mat
for npara=1:length(M_.params)
deep_parameter_name = M_.param_names(npara,:);
eval(['M_.params(npara) = ' deep_parameter_name ' ;'])
end
// provide steady state values
[b]Please, how to load steady state values from my defined function 'solveSS'? [/b]
....
//**************************************
model;
//**************************************
[b]please, how to call matlab function 'unmu' I defined that return marginal utility to me such that I can use it in my Euler equation?[/b]
// Function 'unmu' will give me [u muc muh]=unmu(c,h,parameters), where [u muc muh] are utility level, marginal utility of c and h, respectively,
//but I only need muc and muh
// so could I write like this:
[u muc muh]=unmu(c,h,parameters);
muc=beta*mucXXXXXXXXXXXXXXXXXXXXXXXXXXXX // No, wrong! Do not know how to do it, I need c(+1) and unmu(c(+1),h(+1), parameters) but this cannot be handle in unmu function
end;
Could someone provide samples that have similar scenarios?