stan-dev / stan-dev/rstan

Unable to assign output from paris.stanfit

Open
#1,045 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.1k
Forks
266
Avg merge
2h 56m
Merged PRs (30d)
1

Description

Summary:

Output from pairs.stanfit can only be directed to a device, it cannot be assigned to a variable. This ability is present in other implementation pairs() such as mcmc_pairs

Description:

When running pairs.stanfit() the returned object is eval(mc) where mc is of class call. As a result it can't be saved locally, but is displayed to the active device.

This behavior is different than, say, mcmc_pairs, whose output can be directed to a local variable.

Reproducible Steps:
library(rstan)
library(bayesplot)

example(read_stan_csv)

## rd_st_csvfiles <- dir(system.file('misc', package = 'rstan'),
## rd_st_+                 pattern = 'rstan_doc_ex_[0-9].csv', full.names = TRUE)
## rd_st_fit <- read_stan_csv(csvfiles)

stanfit_pairs_out <- pairs(fit, pars = c("mu", "sigma", "alpha", "lp__"), log = TRUE, las = 1)

## Warning in par(usr) : argument 1 does not name a graphical parameter
## Warning in par(usr) : argument 1 does not name a graphical parameter
## Warning in par(usr) : argument 1 does not name a graphical parameter
## Warning in par(usr) : argument 1 does not name a graphical parameter

class(stanfit_pairs_out)
## [1] "NULL" ## Current output

mcmc_out <- mcmc_pairs(fit, pars = c("mu", "sigma", "alpha", "lp__"))
class(mcmc_out) ## Expected output
## [1] "bayesplot_grid" "gtable"         "gTree"          "grob"
## [5] "gDesc"
RStan Version:
packageVersion("rstan")
## [1] ‘2.26.13’
R Version:
R.version.string
## [1] "R version 4.2.2 Patched (2022-11-10 r83330)"
Operating System:

MATE/Ubuntu 22.04

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the pairs.stanfit entry point and reproduce the issue with the provided R example, comparing its return value with mcmc_pairs. Confirm that assigning pairs(fit, ...) returns the plotting object rather than NULL while preserving the displayed plot behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.