Problem running stan interactively

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem running stan interactively

Tobias Fellinger
Hi,


I try to run a stan model in R 4.0.2 and the session crashes if I run the code interactively (sourcing from an interactive session or from Rstudio) but runs fine if run with Rscript or R -e 'source("rstan_test.R")' . I don't really know where to begin to debug this.

I'm not sure if this is due to the setup on my machine or if this is a bug in either the packaging on Debian, the rstan package or R itself, so I'm posting it here in the most general mailinglist.


For now just running the model in a non-interactive session is a workaround. R and stan code and sessionInfo below.


All the best and thanks in advance, Tobias


==== rstan_test.R ====
library(rstan)


schools_dat <- list(J = 8,

y = c(28, 8, -3, 7, -1, 1, 18, 12),

sigma = c(15, 10, 16, 11, 9, 11, 10, 18))


fit <- stan(file = 'schools.stan', data = schools_dat)


message("done")

====


==== schools.stan ====

// saved as schools.stan

data {

int<lower=0> J; // number of schools

real y[J]; // estimated treatment effects

real<lower=0> sigma[J]; // standard error of effect estimates

}

parameters {

real mu; // population treatment effect

real<lower=0> tau; // standard deviation in treatment effects

vector[J] eta; // unscaled deviation from mu by school

}

transformed parameters {

vector[J] theta = mu + tau * eta; // school treatment effects

}

model {

target += normal_lpdf(eta | 0, 1); // prior log-density

target += normal_lpdf(y | theta, sigma); // log-likelihood

}

====


==== output of sessionInfo ====

$ R -e 'library(rstan); sessionInfo()'


R version 4.0.2 (2020-06-22) -- "Taking Off Again"

Copyright (C) 2020 The R Foundation for Statistical Computing

Platform: x86_64-pc-linux-gnu (64-bit)


R is free software and comes with ABSOLUTELY NO WARRANTY.

You are welcome to redistribute it under certain conditions.

Type 'license()' or 'licence()' for distribution details.


Natural language support but running in an English locale


R is a collaborative project with many contributors.

Type 'contributors()' for more information and

'citation()' on how to cite R or R packages in publications.


Type 'demo()' for some demos, 'help()' for on-line help, or

'help.start()' for an HTML browser interface to help.

Type 'q()' to quit R.


> library(rstan); sessionInfo()

Loading required package: StanHeaders

Loading required package: ggplot2

rstan (Version 2.21.2, GitRev: 2e1f913d3ca3)

For execution on a local, multicore CPU with excess RAM we recommend calling

options(mc.cores = parallel::detectCores()).

To avoid recompilation of unchanged Stan programs, we recommend calling

rstan_options(auto_write = TRUE)

R version 4.0.2 (2020-06-22)

Platform: x86_64-pc-linux-gnu (64-bit)

Running under: Debian GNU/Linux 10 (buster)


Matrix products: default

BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3

LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.3.5.so


locale:

[1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C

[3] LC_TIME=en_DK.UTF-8 LC_COLLATE=en_US.utf8

[5] LC_MONETARY=en_DK.UTF-8 LC_MESSAGES=en_US.utf8

[7] LC_PAPER=en_DK.UTF-8 LC_NAME=C

[9] LC_ADDRESS=C LC_TELEPHONE=C

[11] LC_MEASUREMENT=en_DK.UTF-8 LC_IDENTIFICATION=C


attached base packages:

[1] stats graphics grDevices utils datasets methods base


other attached packages:

[1] rstan_2.21.2 ggplot2_3.3.2 StanHeaders_2.21.0-6


loaded via a namespace (and not attached):

[1] Rcpp_1.0.5 pillar_1.4.6 compiler_4.0.2 prettyunits_1.1.1

[5] tools_4.0.2 pkgbuild_1.1.0 jsonlite_1.7.0 lifecycle_0.2.0

[9] tibble_3.0.3 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.7

[13] cli_2.0.2 parallel_4.0.2 curl_4.3 loo_2.3.1

[17] gridExtra_2.3 withr_2.2.0 dplyr_1.0.2 generics_0.0.2

[21] vctrs_0.3.4 stats4_4.0.2 grid_4.0.2 tidyselect_1.1.0

[25] glue_1.4.2 inline_0.3.15 R6_2.4.1 processx_3.4.3

[29] fansi_0.4.1 callr_3.4.3 purrr_0.3.4 magrittr_1.5

[33] codetools_0.2-16 scales_1.1.1 ps_1.3.4 ellipsis_0.3.1

[37] matrixStats_0.56.0 assertthat_0.2.1 colorspace_1.4-1 V8_3.2.0

[41] RcppParallel_5.0.2 munsell_0.5.0 crayon_1.3.4

>

>

====

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.