pairs function

16 views
Skip to first unread message

Ben Goodrich

unread,
Feb 24, 2013, 5:54:30 PM2/24/13
to stan...@googlegroups.com
You can call pairs() on an object of class stanfit, but it tends not to look that good. So, I've written a custom one. It differs from pairs.default in the following ways

-- You can select which quantities to include via the pars argument (works the same way as in extract) which makes it more readable on smaller screens
-- You can select which chains to use via the chains argument
-- The diagonal has marginal histograms with all included chains
-- The labels on the diagonal parse as Greek
-- The default plot function for the off-diagonals is smoothScatter() rather than points(). This is a 2D kernel density plot of the intersection of the row-variable and column-variable.
-- The lower panel will plot the first "half" of the selected chains; the upper panel the rest. So if chains = 1:3, then the lower panel would include chain 1 only and the upper panel would pool chains 2 and 3. This is useful if you suspect one chain is out of whack and you want to compare it against a good chain.

Function attached. Plot inlined below. Complaints needed.

Ben


pairs.txt

Jiqiang Guo

unread,
Feb 24, 2013, 6:38:02 PM2/24/13
to stan...@googlegroups.com
I am not sure it is a good idea to use Greek labels.  At least one problem is that for parameters like q[i, k], the second index gets lost.  

Should we use chain_id instead of chains? chains is used to indicate the number of chains previously. 

--
Jiqiang 


--
You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ben Goodrich

unread,
Feb 24, 2013, 7:00:33 PM2/24/13
to stan...@googlegroups.com
On Sunday, February 24, 2013 6:38:02 PM UTC-5, Jiqiang Guo wrote:
I am not sure it is a good idea to use Greek labels.  At least one problem is that for parameters like q[i, k], the second index gets lost.  

I hadn't tested that. I can strip the commas but in that case 112 is ambiguous as to whether it is 1,1,2 or 11,2 or 1,12. Or we can use the text names. But it is really hard to visualize more than ten or so quantities anyway.
 
Should we use chain_id instead of chains? chains is used to indicate the number of chains previously. 

Yeah. And I am going to make it also accept a list of length two so you can specify chain_id = list(4, 1:3) to isolate the 4th chain and pool the first three.

Ben

Bob Carpenter

unread,
Feb 25, 2013, 12:34:19 AM2/25/13
to stan...@googlegroups.com
That looks nice. Don't we only need half due to
symmetry? For that, it'd be nice if the plots were
square.

Labels on the axes, too, of course. I'd prefer ASCII
to Greek translations.

- Bob
> <https://lh4.googleusercontent.com/-zeO9bd737lo/USqZzTOQcRI/AAAAAAAAAIE/iWEtsGh8t4o/s1600/pairs.png>

Ben Goodrich

unread,
Feb 25, 2013, 1:47:05 AM2/25/13
to stan...@googlegroups.com
On Monday, February 25, 2013 12:34:19 AM UTC-5, Bob Carpenter wrote:
Don't we only need half due to symmetry?

The default version of pairs is symmetric, which is one reason why I don't like it. Mine puts different chains below and above the diagonal, which will look almost symmetrical if they all have converged but hopefully will stand out enough if they haven't.
 
For that, it'd be nice if the plots were square.

You can make a square plotting region (for any plot) by calling

par(pty = "s")

beforehand, so it is up to the user. But with 10+ variables and a rectangular screen, a lot of space gets wasted.
 
Labels on the axes, too, of course.  

What do you mean? Like putting "alpha", "beta", etc. on the outsides of the plots?
 
I'd prefer ASCII to Greek translations.

Okay, it is a little harder to fit, but the user can control that somewhat.

Ben

Bob Carpenter

unread,
Feb 25, 2013, 2:11:42 AM2/25/13
to stan...@googlegroups.com


On 2/25/13 1:47 AM, Ben Goodrich wrote:
> On Monday, February 25, 2013 12:34:19 AM UTC-5, Bob Carpenter wrote:
>
> Don't we only need half due to symmetry?
>
>
> The default version of pairs is symmetric, which is one reason why I don't like it. Mine puts different chains below and
> above the diagonal, which will look almost symmetrical if they all have converged but hopefully will stand out enough if
> they haven't.

Ah -- I didn't notice that.

> For that, it'd be nice if the plots were square.
>
> You can make a square plotting region (for any plot) by calling
>
> par(pty = "s")
>
> beforehand, so it is up to the user. But with 10+ variables and a rectangular screen, a lot of space gets wasted.

I meant the individual plots, not the overall plot.

> Labels on the axes, too, of course.
>
>
> What do you mean? Like putting "alpha", "beta", etc. on the outsides of the plots?

Yes. I didn't see it in the example, but I assumed that's what
you were talking about w.r.t. ASCII vs. Greek.

> I'd prefer ASCII to Greek translations.
>
>
> Okay, it is a little harder to fit, but the user can control that somewhat.

No big deal either way. I just prefer literal
rendering to a translation.

- Bob
Reply all
Reply to author
Forward
0 new messages