Dear All,
I am doing some work with metropolis and I noted that the seeds for parallel chains are initialized at the same status, so that the chains only differ by the first point, but the random sequences are the same: this implies that sequences for each parameter from different chains are correlated (just compare the values from different blocks stored in files _mhxx_blck1.mat _mhxx_blck2.mat). I am wandering if this is on purpose or this behavior is not desirable.
best Marco
Hi Marco,
This is obviously a bug. If we have to set seeds in the metropolis (I am still not convinced by that but Michel is) we should have a seed specific to each chain.
Best, Stéphane.
On 29/08/2012 09:38, Marco Ratto wrote:
Dear All,
I am doing some work with metropolis and I noted that the seeds for parallel chains are initialized at the same status, so that the chains only differ by the first point, but the random sequences are the same: this implies that sequences for each parameter from different chains are correlated (just compare the values from different blocks stored in files _mhxx_blck1.mat _mhxx_blck2.mat). I am wandering if this is on purpose or this behavior is not desirable.
best Marco
Hi Stephane,
indeed the initialization of the seed loops over the chains, but the problem there is that in the loop from 1 to nblocks, the command randn('state') rand('state')
always provide the same state (at least under R2009a and unless there is a difference between such version and more recent ones).
One strategy to set states in metropolis which keeps reproducibility (with which I agree with Michel), may be the following:
assume we take N replicas for npar estimated params, then the loop to initialize seeds may be modified as:
for b=1:nblocks, Seeds(b).Normal=randn('state'); tmp = randn(N, npar); Seeds(b).Uniform=rand('state'); tmp = rand(N, 1); end clear tmp
In this way, we would increase the state of the seeds by a fixed reproducible (and proper?) amount before initializing the seeds for the next block?
best Marco
On 8/29/2012 9:44 AM, Stéphane Adjemian wrote:
Hi Marco,
This is obviously a bug. If we have to set seeds in the metropolis (I am still not convinced by that but Michel is) we should have a seed specific to each chain.
Best, Stéphane.
On 29/08/2012 09:38, Marco Ratto wrote:
Dear All,
I am doing some work with metropolis and I noted that the seeds for parallel chains are initialized at the same status, so that the chains only differ by the first point, but the random sequences are the same: this implies that sequences for each parameter from different chains are correlated (just compare the values from different blocks stored in files _mhxx_blck1.mat _mhxx_blck2.mat). I am wandering if this is on purpose or this behavior is not desirable.
best Marco
Dev mailing list Dev@dynare.org https://www.dynare.org/cgi-bin/mailman/listinfo/dev
Marco,
This way we would obtain a seed specific to each chain, but the seed would be different from a run to another. To fix that we may impose a seed before the loop with numbers saved in options_ and ideally provide an interface to change these numbers.
Best, Stéphane.
On 29/08/2012 09:58, Marco Ratto wrote:
Hi Stephane,
indeed the initialization of the seed loops over the chains, but the problem there is that in the loop from 1 to nblocks, the command randn('state') rand('state')
always provide the same state (at least under R2009a and unless there is a difference between such version and more recent ones).
One strategy to set states in metropolis which keeps reproducibility (with which I agree with Michel), may be the following:
assume we take N replicas for npar estimated params, then the loop to initialize seeds may be modified as:
for b=1:nblocks, Seeds(b).Normal=randn('state'); tmp = randn(N, npar); Seeds(b).Uniform=rand('state'); tmp = rand(N, 1); end clear tmp
In this way, we would increase the state of the seeds by a fixed reproducible (and proper?) amount before initializing the seeds for the next block?
best Marco
On 8/29/2012 9:44 AM, Stéphane Adjemian wrote:
Hi Marco,
This is obviously a bug. If we have to set seeds in the metropolis (I am still not convinced by that but Michel is) we should have a seed specific to each chain.
Best, Stéphane.
On 29/08/2012 09:38, Marco Ratto wrote:
Dear All,
I am doing some work with metropolis and I noted that the seeds for parallel chains are initialized at the same status, so that the chains only differ by the first point, but the random sequences are the same: this implies that sequences for each parameter from different chains are correlated (just compare the values from different blocks stored in files _mhxx_blck1.mat _mhxx_blck2.mat). I am wandering if this is on purpose or this behavior is not desirable.
best Marco
Dev mailing list Dev@dynare.org https://www.dynare.org/cgi-bin/mailman/listinfo/dev
Dev mailing list Dev@dynare.org https://www.dynare.org/cgi-bin/mailman/listinfo/dev
Dear all,
I agree with Marco and would prefer setting a different but reproducible seed.
Best,
Johannes
--------
Johannes Pfeifer
Haußerstr. 29
72076 Tübingen
Tel.: +49-(0)7071-6396184
Mobil: +49-(0)170-6936820
jpfeifer@gmx.de
Von: dev-bounces@dynare.org [mailto:dev-bounces@dynare.org] Im Auftrag von Marco Ratto Gesendet: Mittwoch, 29. August 2012 09:58 An: dev@dynare.org Betreff: Re: [DynareDev] random seeds in metropolis
Hi Stephane,
indeed the initialization of the seed loops over the chains, but the problem there is that in the loop from 1 to nblocks, the command randn('state') rand('state')
always provide the same state (at least under R2009a and unless there is a difference between such version and more recent ones).
One strategy to set states in metropolis which keeps reproducibility (with which I agree with Michel), may be the following:
assume we take N replicas for npar estimated params, then the loop to initialize seeds may be modified as:
for b=1:nblocks, Seeds(b).Normal=randn('state'); tmp = randn(N, npar); Seeds(b).Uniform=rand('state'); tmp = rand(N, 1); end clear tmp
In this way, we would increase the state of the seeds by a fixed reproducible (and proper?) amount before initializing the seeds for the next block?
best Marco
On 8/29/2012 9:44 AM, Stéphane Adjemian wrote:
Hi Marco,
This is obviously a bug. If we have to set seeds in the metropolis (I am still not convinced by that but Michel is) we should have a seed specific to each chain.
Best, Stéphane.
On 29/08/2012 09:38, Marco Ratto wrote:
Dear All,
I am doing some work with metropolis and I noted that the seeds for parallel chains are initialized at the same status, so that the chains only differ by the first point, but the random sequences are the same: this implies that sequences for each parameter from different chains are correlated (just compare the values from different blocks stored in files _mhxx_blck1.mat _mhxx_blck2.mat). I am wandering if this is on purpose or this behavior is not desirable.
best Marco
_______________________________________________ Dev mailing list Dev@dynare.org https://www.dynare.org/cgi-bin/mailman/listinfo/dev
I think that Dynare should be deterministic-returning the same results of the same runs in the same environment, computer and software versions. This makes it easier to reproduce results, debug code and analyzing issues such as this one. If we are doing something crazy with the initialization of the chains, it is more obvious in a deterministic setup than in a random one.
In R2012a, I have warning that we are calling randn('state') when state is not set. I think that corresponds to what Marco is seeing in R2009a. When I touched that part of the code the last time, I forgot that we need to replace these instances of randn('state') with our own function that manages the different version of Matlab.
I will look into it
Best
Michel
On 08/29/2012 09:44 AM, Stéphane Adjemian wrote:
Hi Marco,
This is obviously a bug. If we have to set seeds in the metropolis (I am still not convinced by that but Michel is) we should have a seed specific to each chain.
Best, Stéphane.
On 29/08/2012 09:38, Marco Ratto wrote:
Dear All,
I am doing some work with metropolis and I noted that the seeds for parallel chains are initialized at the same status, so that the chains only differ by the first point, but the random sequences are the same: this implies that sequences for each parameter from different chains are correlated (just compare the values from different blocks stored in files _mhxx_blck1.mat _mhxx_blck2.mat). I am wandering if this is on purpose or this behavior is not desirable.
best Marco
Dev mailing list Dev@dynare.org https://www.dynare.org/cgi-bin/mailman/listinfo/dev
Hi Marco,
On 08/29/2012 09:38 AM, Marco Ratto wrote:
Dear All,
I am doing some work with metropolis and I noted that the seeds for parallel chains are initialized at the same status,
what do you mean by "same status" ?
so that the chains only differ by the first point,
if the first point is different, is it not that the entire sequence is different (and not an obvious deterministic function of the other sequences?)
but the random sequences are the same: this implies that sequences for each parameter from different chains are correlated (just compare the values from different blocks stored in files _mhxx_blck1.mat _mhxx_blck2.mat).
I would expect initial (positive or negative, depending on initial values of the parameters) correlation while the chains converge from initial conditions towards the ergodic distribution.
Best
Michel
I am wandering if this is on purpose or this behavior is not desirable.
best Marco
Hi Michel,
Concerning the chain convergence to ergodicity, I think you are right theoretically. However, I have compared two chains of length 120.000 for a model with 63 params. What surprised me is that the correlation is always significant for all parameters even for the last mat file saved.
This may not be a general result and indeed I should take a smaller model so that convergence to ergodic would be much quicker.
However, wouldn't we get a better exploration of the posterior distribution, if we initialize the seeds in different chains to a different state, in addition to using a different starting point? Of course, always keeping a clear criterion for doing that to allow for reproducibility?
In the meantime I have seen your other e-mails. Thanks a lot for looking into this.
best Marco
On 8/29/2012 9:54 AM, Michel Juillard wrote:
Hi Marco,
On 08/29/2012 09:38 AM, Marco Ratto wrote:
Dear All,
I am doing some work with metropolis and I noted that the seeds for parallel chains are initialized at the same status,
what do you mean by "same status" ?
so that the chains only differ by the first point,
if the first point is different, is it not that the entire sequence is different (and not an obvious deterministic function of the other sequences?)
but the random sequences are the same: this implies that sequences for each parameter from different chains are correlated (just compare the values from different blocks stored in files _mhxx_blck1.mat _mhxx_blck2.mat).
I would expect initial (positive or negative, depending on initial values of the parameters) correlation while the chains converge from initial conditions towards the ergodic distribution.
Best
Michel
I am wandering if this is on purpose or this behavior is not desirable.
best Marco
Dev mailing list Dev@dynare.org https://www.dynare.org/cgi-bin/mailman/listinfo/dev
Marco
Concerning the chain convergence to ergodicity, I think you are right theoretically. However, I have compared two chains of length 120.000 for a model with 63 params. What surprised me is that the correlation is always significant for all parameters even for the last mat file saved.
this may be worth investigating independently
This may not be a general result and indeed I should take a smaller model so that convergence to ergodic would be much quicker.
However, wouldn't we get a better exploration of the posterior distribution, if we initialize the seeds in different chains to a different state, in addition to using a different starting point? Of course, always keeping a clear criterion for doing that to allow for reproducibility?
For sure, we don't want to use the same sequence where one draw in one chain would always be the same as the draw k iterations later in another chain, with k small.
Best
Michel
In the meantime I have seen your other e-mails. Thanks a lot for looking into this.
best Marco
On 8/29/2012 9:54 AM, Michel Juillard wrote:
Hi Marco,
On 08/29/2012 09:38 AM, Marco Ratto wrote:
Dear All,
I am doing some work with metropolis and I noted that the seeds for parallel chains are initialized at the same status,
what do you mean by "same status" ?
so that the chains only differ by the first point,
if the first point is different, is it not that the entire sequence is different (and not an obvious deterministic function of the other sequences?)
but the random sequences are the same: this implies that sequences for each parameter from different chains are correlated (just compare the values from different blocks stored in files _mhxx_blck1.mat _mhxx_blck2.mat).
I would expect initial (positive or negative, depending on initial values of the parameters) correlation while the chains converge from initial conditions towards the ergodic distribution.
Best
Michel
I am wandering if this is on purpose or this behavior is not desirable.
best Marco
Dev mailing list Dev@dynare.org https://www.dynare.org/cgi-bin/mailman/listinfo/dev