init list is duplicating inits rather than using all of them
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 1.1k
- Forks
- 266
- Avg merge
- 2h 56m
- Merged PRs (30d)
- 1
Description
Summary:
When supplying a list of 4 lists for initialization and specifying chains = 4, the 1st element is not used and the 4th element is duplicated.
Reproducible Steps:
library(rstan)
binormal_model <- stan_model('binormal.stan')
inits <- list(list(theta = c(8, 8)), list(theta = c(8, -8)),
list(theta = c(-8, 8)), list(theta = c(-8, -8)))
its <- 30
fit <- sampling(binormal_model, init = inits, chains = 4, iter = its,
control = list(stepsize = 1e-3), seed = 1234)
draws <- extract(fit, permuted = FALSE, inc_warmup = TRUE, pars = c("theta"))
df1 <- data.frame(theta1 = draws[ , 1, 1], theta2 = draws[ , 1, 2])
df2 <- data.frame(theta1 = draws[ , 2, 1], theta2 = draws[ , 2, 2])
df3 <- data.frame(theta1 = draws[ , 3, 1], theta2 = draws[ , 3, 2])
df4 <- data.frame(theta1 = draws[ , 4, 1], theta2 = draws[ , 4, 2])
traceplot <- traceplot(fit, inc_warmup = TRUE)
library(ggplot2)
traceplot2d <-
ggplot(df1, aes(x = theta1, y = theta2)) +
geom_path(data = df1, color = "red") +
geom_path(data = df2, color = "yellow") +
geom_path(data = df3, color = "blue") +
geom_path(data = df4, color = "green")
Current Output:
The first init, (8, 8), is not used, and the fourth init, (-8, -8), is used twice. Here's the traceplot and the 2D traceplot:


Expected Output:
The four inits given to be used.
RStan Version:
> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.15.2
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rstan_2.19.2 ggplot2_3.1.0 StanHeaders_2.18.1-10
loaded via a namespace (and not attached):
[1] Rcpp_0.12.18 pillar_1.2.3 compiler_3.5.0 plyr_1.8.4
[5] bindr_0.1.1 prettyunits_1.0.2 base64enc_0.1-3 tools_3.5.0
[9] digest_0.6.15 pkgbuild_1.0.2 tibble_1.4.2 gtable_0.2.0
[13] pkgconfig_2.0.2 rlang_0.4.0 cli_1.0.0 parallel_3.5.0
[17] loo_2.0.0 bindrcpp_0.2.2 gridExtra_2.3 withr_2.1.2
[21] dplyr_0.7.6 stats4_3.5.0 grid_3.5.0 tidyselect_0.2.4
[25] glue_1.2.0 inline_0.3.15 R6_2.2.2 processx_3.2.0
[29] callr_3.0.0 purrr_0.2.5 magrittr_1.5 scales_0.5.0
[33] ps_1.2.0 codetools_0.2-15 matrixStats_0.54.0 assertthat_0.2.0
[37] colorspace_1.3-2 labeling_0.3 lazyeval_0.2.1 munsell_0.4.3
[41] crayon_1.3.4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the supplied rstan sampling() call, using four initialization lists and chains = 4. Trace how the init argument is assigned to chains and compare the resulting trace data; done means each chain uses its corresponding initialization rather than omitting the first and duplicating the fourth.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100