stan-dev / stan-dev/rstanarm

Errors running the vignette example for a beta regression

Open
#430 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

Hello, I am trying to run a beta regression in rstanarm. I was getting errors using my dataset so I tried using the example code. I still get errors, even with that code.

rstanarm version 2.19.3
r version 3.6.3 Mac OS X 10.15.4
Here is my r session info:

R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.4

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/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
[7] base

other attached packages:
[1] rstanarm_2.19.3 Rcpp_1.0.3

loaded via a namespace (and not attached):
[1] splines_3.6.3 gtools_3.8.1 StanHeaders_2.21.0-1
[4] threejs_0.3.3 Formula_1.2-3 shiny_1.4.0
[7] assertthat_0.2.1 stats4_3.6.3 pillar_1.4.3
[10] lattice_0.20-38 glue_1.3.1 digest_0.6.24
[13] promises_1.1.0 minqa_1.2.4 sandwich_2.5-1
[16] colorspace_1.4-1 htmltools_0.4.0 httpuv_1.5.2
[19] Matrix_1.2-18 plyr_1.8.5 dygraphs_1.1.1.6
[22] pkgconfig_2.0.3 rstan_2.19.3 purrr_0.3.3
[25] xtable_1.8-4 scales_1.1.0 processx_3.4.2
[28] later_1.0.0 lme4_1.1-21 tibble_2.1.3
[31] bayesplot_1.7.1 ggplot2_3.2.1 DT_0.12
[34] shinyjs_1.1 nnet_7.3-12 lazyeval_0.2.2
[37] cli_2.0.1 survival_3.1-8 magrittr_1.5
[40] crayon_1.3.4 mime_0.9 ps_1.3.2
[43] fansi_0.4.1 nlme_3.1-144 MASS_7.3-51.5
[46] xts_0.12-0 pkgbuild_1.0.6 colourpicker_1.0
[49] rsconnect_0.8.16 tools_3.6.3 loo_2.2.0
[52] prettyunits_1.1.1 lifecycle_0.1.0 matrixStats_0.55.0
[55] stringr_1.4.0 munsell_0.5.0 callr_3.4.2
[58] compiler_3.6.3 rlang_0.4.4 nloptr_1.2.1
[61] grid_3.6.3 ggridges_0.5.2 rstudioapi_0.11
[64] htmlwidgets_1.5.1 crosstalk_1.0.0 igraph_1.2.4.2
[67] miniUI_0.1.1.1 base64enc_0.1-3 boot_1.3-24
[70] codetools_0.2-16 gtable_0.3.0 flexmix_2.3-15
[73] inline_0.3.15 markdown_1.1 reshape2_1.4.3
[76] R6_2.4.1 gridExtra_2.3 rstantools_2.0.0
[79] zoo_1.8-7 dplyr_0.8.4 fastmap_1.0.1
[82] shinystan_2.5.0 shinythemes_1.1.2 betareg_3.1-3
[85] modeltools_0.2-22 stringi_1.4.5 parallel_3.6.3
[88] lmtest_0.9-37 tidyselect_1.0.0

Description:

A full description of the problem (or question).

Reproducible Steps:

If applicable, the steps required to reproduce the issue. If you have a reproducible example, please include it.

Here is the exact code (from empty workspace:
SEED <- 1234
set.seed(SEED)
eta <- c(1, -0.2)
gamma <- c(1.8, 0.4)
N <- 200
x <- rnorm(N, 2, 2)
z <- rnorm(N, 0, 2)
mu <- binomial(link = logit)$linkinv(eta[1] + eta[2]*x)
phi <- binomial(link = log)$linkinv(gamma[1] + gamma[2]*z)
y <- rbeta(N, mu * phi, (1 - mu) * phi)
dat <- data.frame(cbind(y, x, z))
hist(dat$y, col = "darkgrey", border = F, main = "Distribution of Outcome Variable", xlab = "y", breaks = 20, freq = F)

library(rstanarm)
fit1 <- stan_betareg(y ~ x | z, data = dat, link = "logit", link.phi = "log",
cores = 2, seed = 12345)

And here is the error

starting worker pid=17814 on localhost:11523 at 13:47:15.793
starting worker pid=17828 on localhost:11523 at 13:47:16.095

SAMPLING FOR MODEL 'continuous' NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 0.000406 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 4.06 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " c++ exception (unknown reason)"
error occurred during calling the sampler; sampling not done

SAMPLING FOR MODEL 'continuous' NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 0.000341 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 3.41 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " c++ exception (unknown reason)"
error occurred during calling the sampler; sampling not done

SAMPLING FOR MODEL 'continuous' NOW (CHAIN 3).
Chain 3: empty_nested() must be true before calling recover_memory()
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " empty_nested() must be true before calling recover_memory()"
error occurred during calling the sampler; sampling not done

SAMPLING FOR MODEL 'continuous' NOW (CHAIN 4).
Chain 4: empty_nested() must be true before calling recover_memory()
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " empty_nested() must be true before calling recover_memory()"
error occurred during calling the sampler; sampling not done
here are whatever error messages were returned
[[1]]
Stan model 'continuous' does not contain samples.

[[2]]
Stan model 'continuous' does not contain samples.

[[3]]
Stan model 'continuous' does not contain samples.

[[4]]
Stan model 'continuous' does not contain samples.

Error in check_stanfit(stanfit) :
Invalid stanfit object produced please report bug
In addition: Warning message:
In .local(object, ...) :
some chains had errors; consider specifying chains = 1 to debug

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 exact beta-regression example in the issue with the reported R and rstanarm versions, first checking the behavior with the suggested single-chain configuration. Compare the sampler output and determine why the reproducible example fails; done means the documented vignette example runs successfully or the failure is clearly isolated and reported with supporting evidence.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.