# Consumption equivalence across different models

**URL:** <https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569>\
**Category:** Stochastic simulations\
**Created:** [21 November 2023 12:29 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569 "2023-11-21T12:29:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dh.murakami](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/58956e/32.png) [@dh.murakami](https://forum.dynare.org/u/dh.murakami)\
**Post date:** [21 November 2023 12:29 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569/1 "2023-11-21T12:29:11Z")

</div>

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:

```auto
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:

```auto
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:

> <https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Born_Pfeifer_2018/Welfare/get_consumption_equivalent_unconditional_welfare.m>

Any assistance or suggestions would be appreciated.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [21 November 2023 23:14 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569/2 "2023-11-21T23:14:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dh.murakami](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/58956e/32.png) [@dh.murakami](https://forum.dynare.org/u/dh.murakami)\
**Post date:** [22 November 2023 13:11 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569/3 "2023-11-22T13:11:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [23 November 2023 12:37 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569/4 "2023-11-23T12:37:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pbousquet](https://forum.dynare.org/letter_avatar_proxy/v4/letter/p/ba8739/32.png) [@pbousquet](https://forum.dynare.org/u/pbousquet)\
**Post date:** [4 July 2025 13:42 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569/5 "2025-07-04T13:42:54Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [5 July 2025 14:14 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569/6 "2025-07-05T14:14:13Z")

</div>

Without seeing the files it is impossible to tell.

---

<div class="post-metadata">

**Author:** ![pbousquet](https://forum.dynare.org/letter_avatar_proxy/v4/letter/p/ba8739/32.png) [@pbousquet](https://forum.dynare.org/u/pbousquet)\
**Post date:** [5 July 2025 14:27 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569/7 "2025-07-05T14:27:52Z")

</div>

So for example if I run `dynamics.m` from your [github repo](https://github.com/JohannesPfeifer/winberryAlgorithmCodes) 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..).

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [5 July 2025 21:11 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569/8 "2025-07-05T21:11:21Z")

</div>

Where exactly did you put which command?

```auto
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.

---

<div class="post-metadata">

**Author:** ![pbousquet](https://forum.dynare.org/letter_avatar_proxy/v4/letter/p/ba8739/32.png) [@pbousquet](https://forum.dynare.org/u/pbousquet)\
**Post date:** [6 July 2025 01:20 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569/9 "2025-07-06T01:20:58Z")

</div>

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_)`

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [6 July 2025 08:20 UTC](https://forum.dynare.org/t/consumption-equivalence-across-different-models/24569/10 "2025-07-06T08:20:49Z")

</div>

No, in Dynare 6 the correct call is:

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

```

Otherwise, you won’t retrieve the output.
