stan-dev / stan-dev/rstanarm

Argument `save_warmup` is ignored?

Open
#575 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
401
Forks
136
PR merge metrics
No merged PRs in 30d

Description

Description:

rstanarm's modeling functions won't save warm-up draws even if save_warmup = TRUE is specified.

(refresh, otoh is correctly passed to stan(), for example).

Reproducible example:
> library(rstanarm)
> sglm <- stan_glm(vs ~ wt, data = mtcars, family = "binomial", chains = 1, 
+                  seed = 1234, iter = 2000, refresh = 400,  save_warmup = TRUE)

SAMPLING FOR MODEL 'bernoulli' NOW (CHAIN 1).
Chain 1: 
Chain 1: Gradient evaluation took 1.7e-05 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.17 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 1: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 1: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 1: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 1: 
Chain 1:  Elapsed Time: 0.041092 seconds (Warm-up)
Chain 1:                0.037098 seconds (Sampling)
Chain 1:                0.07819 seconds (Total)
Chain 1: 
> sglm$stanfit@stan_args[[1]]$save_warmup
[1] FALSE
> sglm$stanfit@stan_args[[1]]$refresh
[1] 400

Code only:

library(rstanarm)
sglm <- stan_glm(vs ~ wt, data = mtcars, family = "binomial", chains = 1, 
                 seed = 1234, iter = 2000, refresh = 400,  save_warmup = TRUE)
sglm$stanfit@stan_args[[1]]$save_warmup
sglm$stanfit@stan_args[[1]]$refresh
Package version:
> packageVersion("rstanarm")
[1] ‘2.21.3’
> packageVersion("rstan")
[1] ‘2.21.7’
R Version:

4.2.0

Operating System:

OS X 10.14.6

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 by running the reproducible stan_glm example and inspecting sglm$stanfit@stan_args[[1]]$save_warmup alongside refresh. Trace how the modeling function forwards arguments to stan(); done when save_warmup=TRUE is preserved and warm-up draws are saved as requested.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.