permuted

41 views
Skip to first unread message

Jingjing Chen

unread,
Jul 13, 2016, 12:39:57 PM7/13/16
to Stan users mailing list
Dear Stan Users,
I am currently using the script "alpha = fit.extract(permuted=True)['alpha']" to extract the posterior samples.
But I have 4 chains and I want to preserve the full information of each chain separately without shuffling the samples.
Do I just write "alpha = fit.extract()['alpha']" and then the first quarter of alpha belongs to the first chain, etc?

Thanks!

Ben Goodrich

unread,
Jul 13, 2016, 2:07:44 PM7/13/16
to Stan users mailing list

In the extract() function, permuted = TRUE is the default, so you would have to explicitly specify permuted = FALSE. And in that case, it will output an array that is simulations by chains by number of parameters specified in the pars argument to extract. So, you would just look at the appropriate column. All of this is documented in help(extract).

Ben

Jingjing Chen

unread,
Jul 16, 2016, 1:26:35 AM7/16/16
to Stan users mailing list
I am just a little confused. Because for example if I have parameters (alpha, beta), and when I extract them using permuted, the covariance will be lost, right?
Say the chain is 

p, alpha, beta
1  a1,      b1
2  a2,      b2
...

I don't mind that (a1,b1) and (a2, b2) is shuffled.
But if when I extract alpha using the default, alpha chain becomes (a2,a1,...) and beta chain because (b1,b2,...), then the covariance between alpha and beta is lo


在 2016年7月13日星期三 UTC-4下午2:07:44,Ben Goodrich写道:

Ben Goodrich

unread,
Jul 16, 2016, 1:49:07 AM7/16/16
to Stan users mailing list
On Saturday, July 16, 2016 at 1:26:35 AM UTC-4, Jingjing Chen wrote:
I am just a little confused. Because for example if I have parameters (alpha, beta), and when I extract them using permuted, the covariance will be lost, right?

It only permutes the rows, which are the MCMC iterations, so the covariance remains between parameters, which are the third dimension of the array.

Ben

Chen Jingjing

unread,
Jul 16, 2016, 1:52:53 AM7/16/16
to stan-...@googlegroups.com
I just want to make sure, so when I do 

a = fit.extract()['alpha']
b = fit.extract()['beta']

and plot(a,b), the covariance will be correct?

--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/W0gSHYhlPxA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jingjing Chen [ chen...@gmail.com ]
Department of Astronomy
Columbia University
550 West 120th Street
New York, New York 10027
Cell Phone: +1(347)5746709

Michael Betancourt

unread,
Jul 16, 2016, 7:48:42 AM7/16/16
to stan-...@googlegroups.com
Yes.  You loose the autocorrelation and crosscorrelations of the _chains_,
but not the marginal covariances of the parameters themselves, which
is all you really care about.

You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.

Jingjing Chen

unread,
Jul 18, 2016, 5:33:09 PM7/18/16
to Stan users mailing list
I still feel a little unsure. If the covariance between alpha and beta is correct, that means these two lines of codes permute the chains of alpha and beta in the same way. But they are two different lines of code. I am sorry I keep asking about this but it just feels a little counter-intuitive for me.

在 2016年7月16日星期六 UTC-7上午4:48:42,Michael Betancourt写道:

Ben Goodrich

unread,
Jul 18, 2016, 5:45:46 PM7/18/16
to Stan users mailing list
On Monday, July 18, 2016 at 5:33:09 PM UTC-4, Jingjing Chen wrote:
I still feel a little unsure. If the covariance between alpha and beta is correct, that means these two lines of codes permute the chains of alpha and beta in the same way. But they are two different lines of code. I am sorry I keep asking about this but it just feels a little counter-intuitive for me.

I don't know what to tell you. Maybe you could estimate the covariance with and without permuting and find that they are identical?

Jingjing Chen

unread,
Jul 18, 2016, 5:59:42 PM7/18/16
to Stan users mailing list
Sorry I just want to make sure that I made my question clear. Thank you I believe now. And I was having some trouble with the syntax of permuted, which keeps me away from testing it myself so I decide to come here to ask.

在 2016年7月18日星期一 UTC-7下午2:45:46,Ben Goodrich写道:
Reply all
Reply to author
Forward
0 new messages