Traceplot in rstan

1,281 views
Skip to first unread message

Daniel Hocking

unread,
Oct 22, 2012, 11:09:00 PM10/22/12
to stan-...@googlegroups.com
Hi Team Stan,

I was using the traceplot function in rstan and had a thought. If I use just

traceplot(stanfit)

I get traceplots of all the parameters stacked one above another. If there are many parameters, which is likely the case for many complex models for which stan is especially useful, this is difficult to visualize as everything gets compressed (unless on a very large monitor). In RStudio, which is becoming hugely popular, these plots often can't be printed at all because they are bigger than the plot window (a limitation of RStudio that I hope gets fixed someday). I was wondering if other people thought that it would be more pleasing to have traceplot works like it does in coda and have the plots appear in succession each time the user hits enter?

One possible workaround currently would be to write a loop function for traceplot using the pars option.

Also, one very minor suggestion (if it's easy) would be to reset the traceplot layout panel after use. For example, right now if I run

traceplot(stanfit)

then decide to just look at one parameter in more detail and run

traceplot(stanfit, pars = 'beta')

it plots beta up in the top and leaves blank space for all the other plots. It's easy for me to reset it by running

par(mfrow = c(1,1)

after the first traceplot, but I just thought this was unnecessary if it could be automatically reset after running the traceplot function. Anyway, this is not a priority by any means and might not be preferable for all users. I just thought I'd make the suggestion since I noticed it.

Thanks again for all your work on this great package and program and also for all your help getting me started with it.
Dan

Jiqiang Guo

unread,
Oct 22, 2012, 11:33:00 PM10/22/12
to stan-...@googlegroups.com
Please see comments below. 
--
Jiqiang

On Mon, Oct 22, 2012 at 11:09 PM, Daniel Hocking <dhoc...@unh.edu> wrote:
Hi Team Stan,

I was using the traceplot function in rstan and had a thought. If I use just

traceplot(stanfit)

I get traceplots of all the parameters stacked one above another. If there are many parameters, which is likely the case for many complex models for which stan is especially useful, this is difficult to visualize as everything gets compressed (unless on a very large monitor). In RStudio, which is becoming hugely popular, these plots often can't be printed at all because they are bigger than the plot window (a limitation of RStudio that I hope gets fixed someday). I was wondering if other people thought that it would be more pleasing to have traceplot works like it does in coda and have the plots appear in succession each time the user hits enter?
I think if you specify ask = TRUE, it will do that.  

In the next release of rstan, we can specify nrow and ncol for traceplot function, so that they do not default to 4 and 2 when there are too many parameters.  I hope that it will be helpful for RStudio users. 

One possible workaround currently would be to write a loop function for traceplot using the pars option.

Also, one very minor suggestion (if it's easy) would be to reset the traceplot layout panel after use. For example, right now if I run

traceplot(stanfit)

then decide to just look at one parameter in more detail and run

traceplot(stanfit, pars = 'beta')

it plots beta up in the top and leaves blank space for all the other plots. It's easy for me to reset it by running

par(mfrow = c(1,1)

after the first traceplot, but I just thought this was unnecessary if it could be automatically reset after running the traceplot function. Anyway, this is not a priority by any means and might not be preferable for all users. I just thought I'd make the suggestion since I noticed it.
Once a traceplot call is done, it sets mfrow to its previous value.  I do not know why you have that problem, but I do not.  

Thanks again for all your work on this great package and program and also for all your help getting me started with it.
Dan

--
 
 

Reply all
Reply to author
Forward
0 new messages