Consumption equivalence across different models

I’m currently trying to numerically compute consumption equivalence across two regimes (tax and no tax).

Using the code from Born and Pfeifer (2018) as reference, I’ve set up a function to calculate the CE factor:

function outvalue=get_consumption_equivalent_unconditional_welfare(par_value_lambda_ce)

global base_oo base_options base_m permtax_oo permtax_options permtax_m

if par_value_lambda_ce>1 
    outvalue=1e5+par_value_lambda_ce^2;
end

set_param_value('lambda_ce',par_value_lambda_ce) %set consumption equivalent lambda
var_list_ = {'UTIL','V_CE'};
[info1,oo1] = stoch_simul(base_m, base_options, base_oo, var_list_); %get decision rules and moments
[info2,oo2] = stoch_simul(permtax_m, permtax_options, permtax_oo, var_list_); %get decision rules and moments
if info1(1)
    outvalue=1e5+par_value_lambda_ce^2;
    return;
end
if info2(1)
    outvalue=1e5+par_value_lambda_ce^2;
    return;
end
betta = base_m.params(strmatch('betta',base_m.param_names,'exact'));
outvalue = 1/(1-betta)*oo2.mean(strmatch('UTIL',var_list_,'exact')) - oo1.mean(strmatch('V_CE',var_list_,'exact'));

But unfortunately I get the following error:

Dot indexing is not supported for variables of this type.

Error in stoch_simul (line 21)
if isequal(options_.order,0)

Error in get_consumption_equivalent_unconditional_welfare (line 11)
[info1,oo1] = stoch_simul(base_m, base_options, base_oo, var_list_); %get decision rules and moments

Error in csolve (line 60)
    f0=feval(FUN,x);

My initial guess was that stoch_simul cannot treat base_options as a structure when it is declared as a global object. But then I had a look back at the reference code and saw that options_ was also declared as a global object:

Any assistance or suggestions would be appreciated.

Can you please provide the full set of files that generate the error.

Thanks Johannes. I’ve DM’d the necessary files.
(will share results here once complete)

The problem comes from the use of global variables in your code. I amended the original example code to eliminate the globals.

@jpfeifer I’m getting the same error when I try stoch_simul after running Thomas Winberry’s toolbox (both the HA model hosted on your GitHub and the KhanThomas model which I updated similarly). I’m guessing it’s a similar issue since globals are used – do you know what updates would be needed to make this possible? Thanks

Without seeing the files it is impossible to tell.

So for example if I run dynamics.m from your github repo and then try to run something else afterwards like stoch_simul(periods=1000), I get an error as described in the OP (dot indexing not supported..).

Where exactly did you put which command?

stoch_simul(periods=1000)

is not a valid Matlab command. It only works within a mod-file. Otherwise, you need to call the Matlab function stoch_simul withs its correct syntax.

1 Like

Thanks, I misremembered being able to. For anyone else who happens to stumble upon this thread from searching the error – the correct post-estimation call is stoch_simul(M_, options_, oo_, var_list_)

No, in Dynare 6 the correct call is:

[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list)

Otherwise, you won’t retrieve the output.

1 Like