# Error message for 2nd order approximation

**URL:** <https://forum.dynare.org/t/error-message-for-2nd-order-approximation/858>\
**Category:** Dynare v4 (legacy)\
**Created:** [19 November 2008 11:25 UTC](https://forum.dynare.org/t/error-message-for-2nd-order-approximation/858 "2008-11-19T11:25:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lombard](https://forum.dynare.org/letter_avatar_proxy/v4/letter/l/ecb155/32.png) [@lombard](https://forum.dynare.org/u/lombard)\
**Post date:** [19 November 2008 11:25 UTC](https://forum.dynare.org/t/error-message-for-2nd-order-approximation/858/1 "2008-11-19T11:25:20Z")

</div>

Hi,

I couldn’t find any related QA in the forum (I searched Gamma\_y{nar+2})

The problem is that Dynare (4.0.2) crashes with the message

> [@](#):
>
> ??? Assignment has more non-singleton rhs dimensions than non-singleton  
> subscripts
> 
> Error in ==\> th\_autocovariances at 131  
> Gamma\_y{nar+2}(:,i) = abs(diag(aa_vx1_aa’+b2(:,i)\*b2(:,i)'))./vv;
> 
> Error in ==\> disp\_th\_moments at 38  
> [oo\_.gamma\_y,ivar] = th\_autocovariances(dr,ivar,M\_,options\_);
> 
> Error in ==\> stoch\_simul at 69  
> disp\_th\_moments(oo\_.dr,var\_list);
> 
> Error in ==\> trade\_optimal at 699  
> info = stoch\_simul(var\_list\_);
> 
> Error in ==\> dynare at 102  
> evalin(‘base’,fname) ;

My options are

> [@](#):
>
> options\_.irf=0;  
> options\_.order=2;  
> options\_.periods=0;  
> options\_.nograph=1;  
> options\_.noprint=1;  
> options\_.nomoments=0;  
> options\_.steadystate\_flag=0;  
> options\_.nocorr=1;  
> stoch\_simul u,c;

where u and c are two existing variables.

If I set options\_nomoments=1, then Dynare computes the solution and I can compute the moments out of the (second order) state-space representation.

Any idea about what could cause this crash?

Thanks and regards

Gianni

---

<div class="post-metadata">

**Author:** ![lombard](https://forum.dynare.org/letter_avatar_proxy/v4/letter/l/ecb155/32.png) [@lombard](https://forum.dynare.org/u/lombard)\
**Post date:** [19 November 2008 15:26 UTC](https://forum.dynare.org/t/error-message-for-2nd-order-approximation/858/2 "2008-11-19T15:26:40Z")

</div>

I found where the problem originated.  
At about line 84 of th\_autocovariances.m you find the block

```auto
    [vx, u] = lyapunov_symm(A,B*M_.Sigma_e*B',options_.qz_criterium);
    iky = iv(ivar);
    if ~isempty(u)
      iky = iky(find(all(abs(ghx(iky,:)*u) < options_.Schur_vec_tol,2)));
      ivar = dr.order_var(iky);
    end
```

What happens is that lyapunov\_symm returns a ‘u’ matrix that in the position of the selected variable (i.e. the variable(s) listed after stoch\_simul) has some values that violate the Schur\_vec\_tol. It then returns an empty iky vector, which will produce an ivar empty vector etc.

Notice though that if I don’t list any variable after stoch\_simul, Dynare returns a solution. with numeric (second order) constant term and numeric correction, although the mean vector is NaN.  
Furthermore, as mentioned in the previous message in this thread, I can compute the (conditional and unconditional) mean of the variables to second order using the state-space solution that Dynare provides even in the buggy case.

The source of the problem seem to be the existence of a unit root in some (not all) variables.

I think that if this is correct a warning message in the block quoted above would be very much appreciated 😃

Cheers

Gianni

---

<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:** [24 July 2017 13:37 UTC](https://forum.dynare.org/t/error-message-for-2nd-order-approximation/858/3 "2017-07-24T13:37:09Z")

</div>

Closed on 24 July 2017 13:37 UTC


