Dear community,

I programmed the same model in Dynare and Matlab. The model is the Hybrid NKM under Commitment.

The plots and outputs are equal but there is a difference in the loss.

**In Dynare I calculated the loss by:**

```
variance.x=oo_.var(x_pos,x_pos);
variance.pi=oo_.var(pi_pos,pi_pos);
L= (0.5*variance.pi)+ (0.25*variance.x)
```

which is quite easy. The loss is 13.0859.

**In Matlab it was a bit more difficult:**

The input arguments are:

```
data = struct('v_solution', [1:1000; randn(1, 1000)]);
w_pi = 0.5 ;
w_x = 0.25;
[ LossVal,vol_pi, vol_x ] = Loss_fun( data,w_pi, w_x )
```

and the Loss_fun.m

```
function [ LossVal,vol_pi, vol_x ] = Loss_fun( data,w_pi, w_x)
vol_pi = (mean(data.v_solution(2,:).^2));
vol_x = (mean(data.v_solution(1,:).^2));
LossVal = w_pi * vol_pi ...
+ w_x * vol_x
end
```

In Matlab I got two Loss values instead of one.

Where could be the mistake?