Hello,

I am running Dynare 4.4.3 stoch_simul with option periods.

Then I compare correlation between two variables calculated with data in oo_.var

and compare the corr coef with that calculated with oo_.endo_simul.

For example:

and

Since I am using periods option, both oo_.var & oo_.endo_simul contain simulated data but I obtain significantly different results (for some series the difference is about 0.2).

Am I missing anything?

Please provide the full codes.

I think I figured out what went wrong.

I used stoch_simul with option periods AND option hp_filter.

oo_.var saves filtered statistics, while

oo_.endo_simul saves simulated series before the HP filter.

Can you confirm, please?

A corollary question, after I run `stoch_simul(hp_filter = 100, order = 1, irf = 1000, periods=10000)`

the moments I obtain via `oo_.var`

are the same regardless of the number of periods, whereas the moments obtained via `corrcoef(oo_.endo_simul(2,:),oo_.endo_simul(1,:))`

vary with the number of periods. I tried from the range from 100 to 10^4. The difference can be as high as 0.04

Does it mean that oo_.var gives theoretical moments? I thought the manual says to the contrary:

[quote] oo_.var Contains theoretical variance if the periods option is not present (or an approximation thereof for

order=2), and empirical variance otherwise.[/quote]

I attached the files with minimal working examples

`stoch_simul(order=1, periods=1000);`

and

`stoch_simul(order=1, periods=1000, hp_filter=100);`

In this version, the difference between the correlations of C & Y are around 0.006 but it decreases with the length of the simulated series.

Also, for the HP-filtered version, I was wondering how Dynare filters the simulated series (with hp_filter option) so fast. If I conduct HP filtering of endo_simul by hand with periods=10000, it takes my computer to filter the series and to calculate the moments significantly longer than if I use Dynare’s hp_filter option.

With periods = 100000, my PC runs into the curse of dimensionality.

I attached the HP filter code I use as well.

Thanks.

hpfilter.m (914 Bytes)

StochSimul_HP_empir.mod (1.51 KB)

StochSimul_empir.mod (1.05 KB)

When switching from 10000 to 1000 periods,

goes from

[code]ans =

0.000326615664192 0.000035416548315 0.000224502764851 0.000139894628857 0.000075319264576 0.000071830808337

0.000035416548315 0.000021236903551 0.000049779041118 0.000027336117315 0.000001851174164 -0.000020538216304

0.000224502764851 0.000049779041118 0.001170764900180 0.000081945259818 0.000042536905984 0.000075228986918

0.000139894628857 0.000027336117315 0.000081945259818 0.000069473878539 0.000027843140250 0.000008756607555

0.000075319264576 0.000001851174164 0.000042536905984 0.000027843140250 0.000019662155193 0.000026849167137

0.000071830808337 -0.000020538216304 0.000075228986918 0.000008756607555 0.000026849167137 0.000066544587358

[/code]

to

[code]ans =

0.000334544718752 0.000039518537012 0.000239060495493 0.000145415558713 0.000075970615395 0.000068595256611

0.000039518537012 0.000021475606432 0.000061794114533 0.000028638576743 0.000002871940263 -0.000018648095685

0.000239060495493 0.000061794114533 0.001217896764845 0.000094765000760 0.000042104863384 0.000062938707817

0.000145415558713 0.000028638576743 0.000094765000760 0.000072069499163 0.000028860770924 0.000009374071833

0.000075970615395 0.000002871940263 0.000042104863384 0.000028860770924 0.000019467398574 0.000025289415214

0.000068595256611 -0.000018648095685 0.000062938707817 0.000009374071833 0.000025289415214 0.000061267383943

[/code]

showing that the simulation correctly works.

Regarding your second question: you are using the most inefficient version of the HP-filter you can program. It does not make use of the sparsity of HP-filter matrix and uses an explicit inverse. You might want to use Dynare’s

`sample_hp_filter.m`

instead

Thank your for pointing my attention to *sample_hp_filter.m*, Johannes.

Per oo_.var. Please correct me if I am wrong but I think the comparison of oo_.var from simulations with different # of periods shows that empirical moments vary with the length of the series. Which is fine.

However, I am trying to understand why, given a certain number of periods, the values correlations calculated from oo_.var and oo_.endo_simul do not coincide.

for example, after

I obtain the following correlations between the first two variables:

```
OOVar =
0.8910
CorrCoef =
1.0000 0.8847
0.8847 1.0000
difference between oo_.var & oo_.endo_simul:
ans =
0.0063
```

That’s because Dynare drops

periods of burnin when computing the moments