1

I have an R package I am working on that returns output from a Metropolis-Hastings sampler. The output consists of, among other things, matrices where the columns are the variables and the rows are the samples from the posterior. I convert these into coda mcmc objects with this code:

colnames(results$beta) = x$data$Pops
results$beta = mcmc(results$beta, thin = thin)

where thin is 183 and beta is a 21 x 15 matrix (this is a toy example). The mcmc.summary method works fine, but the plot.mcmc gives me:

Error in plot.new() : figure margins too large

I have done a bit of debugging. All the values are finite, there are no NA's, the limits of the axes seem to be being set okay, and there are enough panels (2 plots each with 4 rows and 2 columns) I think. Is there something I am missing in the coercion into the mcmc object?

Package source and all associated files can be found on http://github.com/jmcurran/rbayesfst. A script which will produce the error quickly is in the unexported function mytest, so you'll need

rbayesfst:::mytest()

to get it to run.

There has been suggestion that this has been answered already in this question, but I would like to point out that it is not me setting any of the par values, but plot.mcmc so my question is not about par or plot but what (if anything) I am doing wrong in making a matrix into an mcmc object that cannot be plotted by plot.mcmc It can't be the size of the matrix, because I have had examples with many more dimensions directly from rjags that worked fine.

Community
  • 1
  • 1
James Curran
  • 1,274
  • 7
  • 23
  • 2
    Possible duplicate of [Error in plot.new() : figure margins too large in R](http://stackoverflow.com/questions/12766166/error-in-plot-new-figure-margins-too-large-in-r) – G5W Jan 08 '17 at 01:49
  • If the function is unexported, you'll need `:::`. Also, if you're plotting many panels in one figure, you'll need to create a large enough graphics device for things to actually fit in there. This is where the margins error comes from. (I can't install your package because of compilation errors.) – Axeman Jan 08 '17 at 12:45
  • I have corrected the `:::` and also added a saved file of results to github repository in the `inst/extdata` directory called `r.Rda` which can be restored using the `load` function. This will give you an output object with a sample from the posterior of size 2000. – James Curran Jan 09 '17 at 03:33

0 Answers0