This is an awesome answer. I had the same difficulties with installing rstanarm as other people mentioned above and this fixed it. Could it be mentioned on the GitHub page for the survival branch - it would’ve saved many people a lot of time (around 8 hours in my case till I randomly found this reply)?
@Frantisek_Bartos Yeah you are right – this should really be documented somewhere more obvious. And sorry it wasn’t at the time you went through this!
I’ve opened a PR to add this to the README, see here: https://github.com/stan-dev/rstanarm/pull/501. Hopefully @bgoodri and @jonah are happy to add this to the documentation, either via that PR or something similar.
Thanks a lot! Especially for developing these awesome features!
I finally was able to install it (after months and trying for many hours) using:
install.packages("rstanarm", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
Thanks, @rok_cesnovar!
If somebody reads this topic and his/her models do not run, causing R to crash, this thread provides a solution: Stan_surv crashes R repeatedly - #13 by binman
Everything is up-to-date, rstan models and non-survival models of rstanarm run; however, survival functionality of rstanarm is not working. Trying to to run a rstanarm survival model causes R to crash. Haven’t figure it out after 6 hours of trying.
Here’s what I did:
Reinstalled rstan according to the guidelines
https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started
Sample model runs well.
Installed the developer version:
install.packages("rstanarm", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
Installing package into ‘C:/Users/user/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL ‘https://mc-stan.org/r-packages/bin/windows/contrib/4.0/rstanarm_2.21.2.zip’
Content type ‘application/zip’ length 12617689 bytes (12.0 MB)
downloaded 12.0 MB
package ‘rstanarm’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
- C:\Users\Public\Documents\Wondershare\CreatorTemp\RtmpQ55DeO\downloaded_packages*
>
Loading the package
library(rstanarm)
Loading required package: Rcpp
Registered S3 method overwritten by ‘htmlwidgets’:
- method from *
- print.htmlwidget tools:rstudio*
This is rstanarm version 2.21.2
- See Prior Distributions for rstanarm Models • rstanarm for changes to default priors!
- Default priors may change, so it’s safest to specify priors, even if equivalent to the defaults.
- For execution on a local, multicore CPU with excess RAM we recommend calling - options(mc.cores = parallel::detectCores())*
Trying to find stan_surv function
?stan_surv
No documentation for ‘stan_surv’ in specified packages and libraries:
you could try ‘??stan_surv’
However, I tried to run a stan_glm() model and it worked well.
Testing a survival model
#simulating data
library(simsurv)
set.seed(999111)
N <- 500
covs <- data.frame(id = 1:N,
trt = rbinom(N, 1L, 0.5))
dat = simsurv(dist = "weibull",
lambdas = 0.1,
gammas = 1.5,
betas = c(trt = -0.5),
tde = c(trt = 0.2),
x = covs,
maxt = 5)
dat = merge(dat, covs)
head(dat)
#model
mod3 <- stan_surv(
formula = Surv(eventtime, status) ~ tve(trt, degree = 0, knots = 4),
data = dat,
basehaz = "weibull",
chains = 3,
cores = 3,
seed = 1,
iter = 1000)
Rstudio log file: https://www.dropbox.com/s/pcocm29lr559jz5/rsession-user.log?dl=1
R.Version()
$platform
[1] “x86_64-w64-mingw32”
$arch
[1] “x86_64”
$os
[1] “mingw32”
$system
[1] “x86_64, mingw32”
$status
[1] “”
$major
[1] “4”
$minor
[1] “0.4”
$year
[1] “2021”
$month
[1] “02”
day
[1] "15"
svn rev
[1] “80002”
$language
[1] “R”
$version.string
[1] “R version 4.0.4 (2021-02-15)”
$nickname
[1] “Lost Library Book”
PC configuration
Intel(R) Core™ i5-8250U CPU @ 1.60GHz 1.80 GHz, 16GB of RAM, 64-bit OS, SSD HDD, Windows 10 Enterprise 20H2
session_info(pkgs = NULL, include_base = FALSE)
Packages ------------------------------------------------------------
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.4)
base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.0.3)
bayesplot 1.8.0 2021-01-10 [1] CRAN (R 4.0.4)
boot 1.3-27 2021-02-12 [1] CRAN (R 4.0.4)
cachem 1.0.4 2021-02-13 [1] CRAN (R 4.0.4)
callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.4)
cli 2.3.1 2021-02-23 [1] CRAN (R 4.0.4)
codetools 0.2-18 2020-11-04 [2] CRAN (R 4.0.4)
colorspace 2.0-0 2020-11-11 [1] CRAN (R 4.0.4)
colourpicker 1.1.0 2020-09-14 [1] CRAN (R 4.0.4)
crayon 1.4.1 2021-02-08 [1] CRAN (R 4.0.4)
crosstalk 1.1.1 2021-01-12 [1] CRAN (R 4.0.4)
curl 4.3 2019-12-02 [1] CRAN (R 4.0.4)
DBI 1.1.1 2021-01-15 [1] CRAN (R 4.0.4)
desc 1.3.0 2021-03-05 [1] CRAN (R 4.0.4)
devtools * 2.3.2 2020-09-18 [1] CRAN (R 4.0.4)
digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.4)
dplyr 1.0.5 2021-03-05 [1] CRAN (R 4.0.4)
DT 0.17 2021-01-06 [1] CRAN (R 4.0.4)
dygraphs 1.1.1.6 2018-07-11 [1] CRAN (R 4.0.4)
evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.4)
fansi 0.4.2 2021-01-15 [1] CRAN (R 4.0.4)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.0.4)
fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.4)
generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.4)
ggplot2 3.3.3 2020-12-30 [1] CRAN (R 4.0.4)
ggridges 0.5.3 2021-01-08 [1] CRAN (R 4.0.4)
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.4)
gridExtra 2.3 2017-09-09 [1] CRAN (R 4.0.4)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.4)
gtools 3.8.2 2020-03-31 [1] CRAN (R 4.0.3)
htmltools 0.5.1.1 2021-01-22 [1] CRAN (R 4.0.4)
htmlwidgets 1.5.3 2020-12-10 [1] CRAN (R 4.0.4)
httpuv 1.5.5 2021-01-13 [1] CRAN (R 4.0.4)
igraph 1.2.6 2020-10-06 [1] CRAN (R 4.0.4)
inline 0.3.17 2020-12-01 [1] CRAN (R 4.0.4)
jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.0.4)
knitr 1.31 2021-01-27 [1] CRAN (R 4.0.4)
later 1.1.0.1 2020-06-05 [1] CRAN (R 4.0.4)
lattice 0.20-41 2020-04-02 [1] CRAN (R 4.0.4)
lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.0.4)
lme4 1.1-26 2020-12-01 [1] CRAN (R 4.0.4)
loo 2.4.1 2020-12-09 [1] CRAN (R 4.0.4)
magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.4)
markdown 1.1 2019-08-07 [1] CRAN (R 4.0.4)
MASS 7.3-53.1 2021-02-12 [1] CRAN (R 4.0.4)
Matrix 1.3-2 2021-01-06 [1] CRAN (R 4.0.4)
matrixStats 0.58.0 2021-01-29 [1] CRAN (R 4.0.4)
mime 0.10 2021-02-13 [1] CRAN (R 4.0.4)
miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.0.4)
minqa 1.2.4 2014-10-09 [1] CRAN (R 4.0.4)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.4)
nlme 3.1-152 2021-02-04 [1] CRAN (R 4.0.4)
nloptr 1.2.2.2 2020-07-02 [1] CRAN (R 4.0.4)
pillar 1.5.1 2021-03-05 [1] CRAN (R 4.0.4)
pkgbuild 1.2.0 2020-12-15 [1] CRAN (R 4.0.4)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.4)
pkgload 1.2.0 2021-02-23 [1] CRAN (R 4.0.4)
plyr 1.8.6 2020-03-03 [1] CRAN (R 4.0.4)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.4)
processx 3.4.5 2020-11-30 [1] CRAN (R 4.0.4)
promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.0.4)
ps 1.6.0 2021-02-28 [1] CRAN (R 4.0.4)
purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.4)
R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.4)
Rcpp * 1.0.6 2021-01-15 [1] CRAN (R 4.0.4)
RcppParallel 5.0.3 2021-02-24 [1] CRAN (R 4.0.4)
remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.4)
reshape2 1.4.4 2020-04-09 [1] CRAN (R 4.0.4)
rlang 0.4.10 2020-12-30 [1] CRAN (R 4.0.4)
rmarkdown 2.7 2021-02-19 [1] CRAN (R 4.0.4)
rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.4)
rsconnect 0.8.16 2019-12-13 [1] CRAN (R 4.0.4)
rstan 2.21.2 2020-07-27 [1] CRAN (R 4.0.4)
rstanarm * 2.21.2 2020-08-31 [1] local
rstantools 2.1.1 2020-07-06 [1] CRAN (R 4.0.4)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.4)
shiny 1.6.0 2021-01-25 [1] CRAN (R 4.0.4)
shinyjs 2.0.0 2020-09-09 [1] CRAN (R 4.0.4)
shinystan 2.5.0 2018-05-01 [1] CRAN (R 4.0.4)
shinythemes 1.2.0 2021-01-25 [1] CRAN (R 4.0.4)
splines2 0.4.2 2021-02-21 [1] CRAN (R 4.0.4)
StanHeaders 2.21.0-7 2020-12-17 [1] CRAN (R 4.0.4)
statmod 1.4.35 2020-10-19 [1] CRAN (R 4.0.4)
stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.3)
stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.4)
survival 3.2-10 2021-03-16 [1] CRAN (R 4.0.4)
testthat 3.0.2 2021-02-14 [1] CRAN (R 4.0.4)
threejs 0.3.3 2020-01-21 [1] CRAN (R 4.0.4)
tibble 3.1.0 2021-02-25 [1] CRAN (R 4.0.4)
tidyr 1.1.3 2021-03-03 [1] CRAN (R 4.0.4)
tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.4)
usethis * 2.0.1 2021-02-10 [1] CRAN (R 4.0.4)
utf8 1.2.1 2021-03-12 [1] CRAN (R 4.0.4)
V8 3.4.0 2020-11-04 [1] CRAN (R 4.0.4)
vctrs 0.3.6 2020-12-17 [1] CRAN (R 4.0.4)
withr 2.4.1 2021-01-26 [1] CRAN (R 4.0.4)
xfun 0.22 2021-03-11 [1] CRAN (R 4.0.4)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.0.4)
xts 0.12.1 2020-09-09 [1] CRAN (R 4.0.4)
yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.3)
zoo 1.8-9 2021-03-09 [1] CRAN (R 4.0.4)
Makevars.win
CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2
Makewars.win.bak includes
CXX14FLAGS=-O3 -mtune=native
CXX11FLAGS=-O3 -mtune=native
Glad that other post had the solution! I was about to suggest it may be related. The tve()
function use b-splines under the hood.
I am installing with the below command in my R which runs under Ubuntu:
install.packages(“rstanarm”, repos = c(“Repository for distributing (some) stan-dev R packages | r-packages”, getOption(“repos”)))
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
/usr/lib/R/etc/Makeconf:175: recipe for target ‘stan_files/jm.o’ failed
make: *** [stan_files/jm.o] Error 4
make: *** Waiting for unfinished jobs…
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
/usr/lib/R/etc/Makeconf:175: recipe for target ‘stan_files/mvmer.o’ failed
make: *** [stan_files/mvmer.o] Error 4
rm stan_files/jm.cc stan_files/continuous.cc stan_files/bernoulli.cc stan_files/ binomial.cc stan_files/lm.cc stan_files/polr.cc stan_files/surv.cc stan_files/co unt.cc stan_files/mvmer.cc
ERROR: compilation failed for package ‘rstanarm’
- removing ‘/usr/local/lib/R/site-library/rstanarm’
The downloaded source packages are in
‘/tmp/RtmpbwEBgC/downloaded_packages’
Warning message:
In install.packages(“rstanarm”, repos = c(“Repository for distributing (some) stan-dev R packages | r-packages”, :
installation of package ‘rstanarm’ had non-zero exit status
This error can occur when your computer runs out of memory during compilation. As part of the installation rstanarm
compiles several stan models, each requiring ~3gb of RAM. If you have specified some level of parallelism in the build, then this can quickly use up your available RAM.
Try installing using only 1 core at a time:
Sys.setenv(MAKEFLAGS = "-1")
install.packages("rstanarm", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
I follow your instructions to run those 2 lines of code and get below:
/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:23:56: required from ‘double stan::mcmc::dense_e_metric<Model, BaseRNG>::T(stan::mcmc::dense_e_point&) [with Model = model_bernoulli_namespace::model_bernoulli; BaseRNG = boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014, 0, 2147483563>, boost::random::linear_congruential_engine<unsigned int, 40692, 0, 2147483399> >]’
stan_files/bernoulli.cc:29:1: required from here
/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits::type {aka __vector(2) double}’ [-Wignored-attributes]
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
make: *** [stan_files/bernoulli.o] Error 4
ERROR: compilation failed for package ‘rstanarm’
- removing ‘/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/rstanarm’
/usr/lib/R/etc/Makeconf:175: recipe for target ‘stan_files/bernoulli.o’ failed
rm stan_files/jm.cc stan_files/bernoulli.cc stan_files/binomial.cc stan_files/lm.cc stan_files/count.cc stan_files/mvmer.cc
The downloaded source packages are in
‘/tmp/RtmpW9G5p0/downloaded_packages’
How much memory/RAM does your computer have?
Are you able to run the RStan example model:
example(stan_model,package="rstan",run.dontrun=T)
> example(stan_model,package="rstan",run.dontrun=T)
stn_md> stancode <- 'data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}'
stn_md> mod <- stan_model(model_code = stancode, verbose = TRUE)
TRANSLATING MODEL '16a540c6086086816528e4524def24d9' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model '16a540c6086086816528e4524def24d9'.
COMPILING THE C++ CODE FOR MODEL '16a540c6086086816528e4524def24d9' NOW.
OS: x86_64, linux-gnu; rstan: 2.21.2; Rcpp: 1.0.7; inline: 0.3.19
>> setting environment variables:
PKG_LIBS = '/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/rstan/lib//libStanServices.a' -L'/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/lib/' -lStanHeaders -L'/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppParallel/lib/' -ltbb
PKG_CPPFLAGS = -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include/" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/unsupported" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/BH/include" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/src/" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppParallel/include/" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include '/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1
>> Program source :
1 :
2 : // includes from the plugin
3 : // [[Rcpp::plugins(cpp14)]]
4 :
5 :
6 : // user includes
7 : #include <Rcpp.h>
8 : #include <rstan/io/rlist_ref_var_context.hpp>
9 : #include <rstan/io/r_ostream.hpp>
10 : #include <rstan/stan_args.hpp>
11 : #include <boost/integer/integer_log2.hpp>
12 : // Code generated by Stan version 2.21.0
13 :
14 : #include <stan/model/model_header.hpp>
15 :
16 : namespace model1c9126394050_16a540c6086086816528e4524def24d9_namespace {
17 :
18 : using std::istream;
19 : using std::string;
20 : using std::stringstream;
21 : using std::vector;
22 : using stan::io::dump;
23 : using stan::math::lgamma;
24 : using stan::model::prob_grad;
25 : using namespace stan::math;
26 :
27 : static int current_statement_begin__;
28 :
29 : stan::io::program_reader prog_reader__() {
30 : stan::io::program_reader reader;
31 : reader.add_event(0, 0, "start", "model1c9126394050_16a540c6086086816528e4524def24d9");
32 : reader.add_event(3, 1, "end", "model1c9126394050_16a540c6086086816528e4524def24d9");
33 : return reader;
34 : }
35 :
36 : class model1c9126394050_16a540c6086086816528e4524def24d9
37 : : public stan::model::model_base_crtp<model1c9126394050_16a540c6086086816528e4524def24d9> {
38 : private:
39 : double y_mean;
40 : public:
41 : model1c9126394050_16a540c6086086816528e4524def24d9(rstan::io::rlist_ref_var_context& context__,
42 : std::ostream* pstream__ = 0)
43 : : model_base_crtp(0) {
44 : ctor_body(context__, 0, pstream__);
45 : }
46 :
47 : model1c9126394050_16a540c6086086816528e4524def24d9(stan::io::var_context& context__,
48 : unsigned int random_seed__,
49 : std::ostream* pstream__ = 0)
50 : : model_base_crtp(0) {
51 : ctor_body(context__, random_seed__, pstream__);
52 : }
53 :
54 : void ctor_body(stan::io::var_context& context__,
55 : unsigned int random_seed__,
56 : std::ostream* pstream__) {
57 : typedef double local_scalar_t__;
58 :
59 : boost::ecuyer1988 base_rng__ =
60 : stan::services::util::create_rng(random_seed__, 0);
61 : (void) base_rng__; // suppress unused var warning
62 :
63 : current_statement_begin__ = -1;
64 :
65 : static const char* function__ = "model1c9126394050_16a540c6086086816528e4524def24d9_namespace::model1c9126394050_16a540c6086086816528e4524def24d9";
66 : (void) function__; // dummy to suppress unused var warning
67 : size_t pos__;
68 : (void) pos__; // dummy to suppress unused var warning
69 : std::vector<int> vals_i__;
70 : std::vector<double> vals_r__;
71 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
72 : (void) DUMMY_VAR__; // suppress unused var warning
73 :
74 : try {
75 : // initialize data block variables from context__
76 : current_statement_begin__ = 1;
77 : context__.validate_dims("data initialization", "y_mean", "double", context__.to_vec());
78 : y_mean = double(0);
79 : vals_r__ = context__.vals_r("y_mean");
80 : pos__ = 0;
81 : y_mean = vals_r__[pos__++];
82 :
83 :
84 : // initialize transformed data variables
85 : // execute transformed data statements
86 :
87 : // validate transformed data
88 :
89 : // validate, set parameter ranges
90 : num_params_r__ = 0U;
91 : param_ranges_i__.clear();
92 : current_statement_begin__ = 1;
93 : num_params_r__ += 1;
94 : } catch (const std::exception& e) {
95 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
96 : // Next line prevents compiler griping about no return
97 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
98 : }
99 : }
100 :
101 : ~model1c9126394050_16a540c6086086816528e4524def24d9() { }
102 :
103 :
104 : void transform_inits(const stan::io::var_context& context__,
105 : std::vector<int>& params_i__,
106 : std::vector<double>& params_r__,
107 : std::ostream* pstream__) const {
108 : typedef double local_scalar_t__;
109 : stan::io::writer<double> writer__(params_r__, params_i__);
110 : size_t pos__;
111 : (void) pos__; // dummy call to supress warning
112 : std::vector<double> vals_r__;
113 : std::vector<int> vals_i__;
114 :
115 : current_statement_begin__ = 1;
116 : if (!(context__.contains_r("y")))
117 : stan::lang::rethrow_located(std::runtime_error(std::string("Variable y missing")), current_statement_begin__, prog_reader__());
118 : vals_r__ = context__.vals_r("y");
119 : pos__ = 0U;
120 : context__.validate_dims("parameter initialization", "y", "double", context__.to_vec());
121 : double y(0);
122 : y = vals_r__[pos__++];
123 : try {
124 : writer__.scalar_unconstrain(y);
125 : } catch (const std::exception& e) {
126 : stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable y: ") + e.what()), current_statement_begin__, prog_reader__());
127 : }
128 :
129 : params_r__ = writer__.data_r();
130 : params_i__ = writer__.data_i();
131 : }
132 :
133 : void transform_inits(const stan::io::var_context& context,
134 : Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r,
135 : std::ostream* pstream__) const {
136 : std::vector<double> params_r_vec;
137 : std::vector<int> params_i_vec;
138 : transform_inits(context, params_i_vec, params_r_vec, pstream__);
139 : params_r.resize(params_r_vec.size());
140 : for (int i = 0; i < params_r.size(); ++i)
141 : params_r(i) = params_r_vec[i];
142 : }
143 :
144 :
145 : template <bool propto__, bool jacobian__, typename T__>
146 : T__ log_prob(std::vector<T__>& params_r__,
147 : std::vector<int>& params_i__,
148 : std::ostream* pstream__ = 0) const {
149 :
150 : typedef T__ local_scalar_t__;
151 :
152 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
153 : (void) DUMMY_VAR__; // dummy to suppress unused var warning
154 :
155 : T__ lp__(0.0);
156 : stan::math::accumulator<T__> lp_accum__;
157 : try {
158 : stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
159 :
160 : // model parameters
161 : current_statement_begin__ = 1;
162 : local_scalar_t__ y;
163 : (void) y; // dummy to suppress unused var warning
164 : if (jacobian__)
165 : y = in__.scalar_constrain(lp__);
166 : else
167 : y = in__.scalar_constrain();
168 :
169 : // model body
170 :
171 : current_statement_begin__ = 1;
172 : lp_accum__.add(normal_log<propto__>(y, y_mean, 1));
173 :
174 : } catch (const std::exception& e) {
175 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
176 : // Next line prevents compiler griping about no return
177 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
178 : }
179 :
180 : lp_accum__.add(lp__);
181 : return lp_accum__.sum();
182 :
183 : } // log_prob()
184 :
185 : template <bool propto, bool jacobian, typename T_>
186 : T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
187 : std::ostream* pstream = 0) const {
188 : std::vector<T_> vec_params_r;
189 : vec_params_r.reserve(params_r.size());
190 : for (int i = 0; i < params_r.size(); ++i)
191 : vec_params_r.push_back(params_r(i));
192 : std::vector<int> vec_params_i;
193 : return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
194 : }
195 :
196 :
197 : void get_param_names(std::vector<std::string>& names__) const {
198 : names__.resize(0);
199 : names__.push_back("y");
200 : }
201 :
202 :
203 : void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
204 : dimss__.resize(0);
205 : std::vector<size_t> dims__;
206 : dims__.resize(0);
207 : dimss__.push_back(dims__);
208 : }
209 :
210 : template <typename RNG>
211 : void write_array(RNG& base_rng__,
212 : std::vector<double>& params_r__,
213 : std::vector<int>& params_i__,
214 : std::vector<double>& vars__,
215 : bool include_tparams__ = true,
216 : bool include_gqs__ = true,
217 : std::ostream* pstream__ = 0) const {
218 : typedef double local_scalar_t__;
219 :
220 : vars__.resize(0);
221 : stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
222 : static const char* function__ = "model1c9126394050_16a540c6086086816528e4524def24d9_namespace::write_array";
223 : (void) function__; // dummy to suppress unused var warning
224 :
225 : // read-transform, write parameters
226 : double y = in__.scalar_constrain();
227 : vars__.push_back(y);
228 :
229 : double lp__ = 0.0;
230 : (void) lp__; // dummy to suppress unused var warning
231 : stan::math::accumulator<double> lp_accum__;
232 :
233 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
234 : (void) DUMMY_VAR__; // suppress unused var warning
235 :
236 : if (!include_tparams__ && !include_gqs__) return;
237 :
238 : try {
239 : if (!include_gqs__ && !include_tparams__) return;
240 : if (!include_gqs__) return;
241 : } catch (const std::exception& e) {
242 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
243 : // Next line prevents compiler griping about no return
244 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***");
245 : }
246 : }
247 :
248 : template <typename RNG>
249 : void write_array(RNG& base_rng,
250 : Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
251 : Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
252 : bool include_tparams = true,
253 : bool include_gqs = true,
254 : std::ostream* pstream = 0) const {
255 : std::vector<double> params_r_vec(params_r.size());
256 : for (int i = 0; i < params_r.size(); ++i)
257 : params_r_vec[i] = params_r(i);
258 : std::vector<double> vars_vec;
259 : std::vector<int> params_i_vec;
260 : write_array(base_rng, params_r_vec, params_i_vec, vars_vec, include_tparams, include_gqs, pstream);
261 : vars.resize(vars_vec.size());
262 : for (int i = 0; i < vars.size(); ++i)
263 : vars(i) = vars_vec[i];
264 : }
265 :
266 : std::string model_name() const {
267 : return "model1c9126394050_16a540c6086086816528e4524def24d9";
268 : }
269 :
270 :
271 : void constrained_param_names(std::vector<std::string>& param_names__,
272 : bool include_tparams__ = true,
273 : bool include_gqs__ = true) const {
274 : std::stringstream param_name_stream__;
275 : param_name_stream__.str(std::string());
276 : param_name_stream__ << "y";
277 : param_names__.push_back(param_name_stream__.str());
278 :
279 : if (!include_gqs__ && !include_tparams__) return;
280 :
281 : if (include_tparams__) {
282 : }
283 :
284 : if (!include_gqs__) return;
285 : }
286 :
287 :
288 : void unconstrained_param_names(std::vector<std::string>& param_names__,
289 : bool include_tparams__ = true,
290 : bool include_gqs__ = true) const {
291 : std::stringstream param_name_stream__;
292 : param_name_stream__.str(std::string());
293 : param_name_stream__ << "y";
294 : param_names__.push_back(param_name_stream__.str());
295 :
296 : if (!include_gqs__ && !include_tparams__) return;
297 :
298 : if (include_tparams__) {
299 : }
300 :
301 : if (!include_gqs__) return;
302 : }
303 :
304 : }; // model
305 :
306 : } // namespace
307 :
308 : typedef model1c9126394050_16a540c6086086816528e4524def24d9_namespace::model1c9126394050_16a540c6086086816528e4524def24d9 stan_model;
309 :
310 : #ifndef USING_R
311 :
312 : stan::model::model_base& new_model(
313 : stan::io::var_context& data_context,
314 : unsigned int seed,
315 : std::ostream* msg_stream) {
316 : stan_model* m = new stan_model(data_context, seed, msg_stream);
317 : return *m;
318 : }
319 :
320 : #endif
321 :
322 :
323 :
324 : #include <rstan_next/stan_fit.hpp>
325 :
326 : struct stan_model_holder {
327 : stan_model_holder(rstan::io::rlist_ref_var_context rcontext,
328 : unsigned int random_seed)
329 : : rcontext_(rcontext), random_seed_(random_seed)
330 : {
331 : }
332 :
333 : //stan::math::ChainableStack ad_stack;
334 : rstan::io::rlist_ref_var_context rcontext_;
335 : unsigned int random_seed_;
336 : };
337 :
338 : Rcpp::XPtr<stan::model::model_base> model_ptr(stan_model_holder* smh) {
339 : Rcpp::XPtr<stan::model::model_base> model_instance(new stan_model(smh->rcontext_, smh->random_seed_), true);
340 : return model_instance;
341 : }
342 :
343 : Rcpp::XPtr<rstan::stan_fit_base> fit_ptr(stan_model_holder* smh) {
344 : return Rcpp::XPtr<rstan::stan_fit_base>(new rstan::stan_fit(model_ptr(smh), smh->random_seed_), true);
345 : }
346 :
347 : std::string model_name(stan_model_holder* smh) {
348 : return model_ptr(smh).get()->model_name();
349 : }
350 :
351 : RCPP_MODULE(stan_fit4model1c9126394050_16a540c6086086816528e4524def24d9_mod){
352 : Rcpp::class_<stan_model_holder>("stan_fit4model1c9126394050_16a540c6086086816528e4524def24d9")
353 : .constructor<rstan::io::rlist_ref_var_context, unsigned int>()
354 : .method("model_ptr", &model_ptr)
355 : .method("fit_ptr", &fit_ptr)
356 : .method("model_name", &model_name)
357 : ;
358 : }
359 :
360 :
361 : // declarations
362 : extern "C" {
363 : SEXP file1c91487e980e( ) ;
364 : }
365 :
366 : // definition
367 : SEXP file1c91487e980e() {
368 : return Rcpp::wrap("16a540c6086086816528e4524def24d9");
369 : }
make cmd is
make -f '/usr/lib/R/etc/Makeconf' -f '/usr/share/R/share/make/[shlib.mk](http://shlib.mk)' CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB='file1c91487e980e.so' OBJECTS='file1c91487e980e.o'
make would use
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include/" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/unsupported" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/BH/include" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/src/" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppParallel/include/" -I"/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include '/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 -fpic -g -O2 -fdebug-prefix-map=/build/r-base-vB4ZXq/r-base-4.1.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c file1c91487e980e.cpp -o file1c91487e980e.o
if test "zfile1c91487e980e.o" != "z"; then \
echo g++ -std=gnu++14 -shared -L"/usr/lib/R/lib" -Wl,-Bsymbolic-functions -Wl,-z,relro -o file1c91487e980e.so file1c91487e980e.o '/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/rstan/lib//libStanServices.a' -L'/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/lib/' -lStanHeaders -L'/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppParallel/lib/' -ltbb -L"/usr/lib/R/lib" -lR; \
g++ -std=gnu++14 -shared -L"/usr/lib/R/lib" -Wl,-Bsymbolic-functions -Wl,-z,relro -o file1c91487e980e.so file1c91487e980e.o '/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/rstan/lib//libStanServices.a' -L'/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/lib/' -lStanHeaders -L'/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppParallel/lib/' -ltbb -L"/usr/lib/R/lib" -lR; \
fi
stn_md> fit <- sampling(mod, data = list(y_mean = 0))
SAMPLING FOR MODEL '16a540c6086086816528e4524def24d9' NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 1.1e-05 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 1:
Chain 1: Elapsed Time: 0.006707 seconds (Warm-up)
Chain 1: 0.006945 seconds (Sampling)
Chain 1: 0.013652 seconds (Total)
Chain 1:
SAMPLING FOR MODEL '16a540c6086086816528e4524def24d9' NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 7e-06 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 2:
Chain 2: Elapsed Time: 0.007061 seconds (Warm-up)
Chain 2: 0.006988 seconds (Sampling)
Chain 2: 0.014049 seconds (Total)
Chain 2:
SAMPLING FOR MODEL '16a540c6086086816528e4524def24d9' NOW (CHAIN 3).
Chain 3:
Chain 3: Gradient evaluation took 6e-06 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3:
Chain 3:
Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 3:
Chain 3: Elapsed Time: 0.006922 seconds (Warm-up)
Chain 3: 0.006071 seconds (Sampling)
Chain 3: 0.012993 seconds (Total)
Chain 3:
SAMPLING FOR MODEL '16a540c6086086816528e4524def24d9' NOW (CHAIN 4).
Chain 4:
Chain 4: Gradient evaluation took 5e-06 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4:
Chain 4:
Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 4:
Chain 4: Elapsed Time: 0.00682 seconds (Warm-up)
Chain 4: 0.006731 seconds (Sampling)
Chain 4: 0.013551 seconds (Total)
Chain 4:
stn_md> fit2 <- sampling(mod, data = list(y_mean = 5))
SAMPLING FOR MODEL '16a540c6086086816528e4524def24d9' NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 1e-05 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.1 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 1:
Chain 1: Elapsed Time: 0.0067 seconds (Warm-up)
Chain 1: 0.006808 seconds (Sampling)
Chain 1: 0.013508 seconds (Total)
Chain 1:
SAMPLING FOR MODEL '16a540c6086086816528e4524def24d9' NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 6e-06 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 2:
Chain 2: Elapsed Time: 0.006901 seconds (Warm-up)
Chain 2: 0.006555 seconds (Sampling)
Chain 2: 0.013456 seconds (Total)
Chain 2:
SAMPLING FOR MODEL '16a540c6086086816528e4524def24d9' NOW (CHAIN 3).
Chain 3:
Chain 3: Gradient evaluation took 5e-06 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3:
Chain 3:
Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 3:
Chain 3: Elapsed Time: 0.007171 seconds (Warm-up)
Chain 3: 0.006281 seconds (Sampling)
Chain 3: 0.013452 seconds (Total)
Chain 3:
SAMPLING FOR MODEL '16a540c6086086816528e4524def24d9' NOW (CHAIN 4).
Chain 4:
Chain 4: Gradient evaluation took 5e-06 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4:
Chain 4:
Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 4:
Chain 4: Elapsed Time: 0.006721 seconds (Warm-up)
Chain 4: 0.006178 seconds (Sampling)
Chain 4: 0.012899 seconds (Total)
Chain 4:
Ah that’s likely the issue. The rstanarm models will need >3gb RAM to compile and install
let me increase the ram size and let you know. I remember I did that, and I go the same error issue.
my present RAM is 4GB, which is more than 3gb RAM, isn’t it?
Let me increase to 8GB and show you that I get the same error.
And you get the same error? What command are you using to install rstanarm?
stan_files/continuous.cc:29:1: required from here
/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:960:8: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits::type {aka __vector(2) double}’ [-Wignored-attributes]
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
make: *** [stan_files/continuous.o] Error 4
/usr/lib/R/etc/Makeconf:175: recipe for target ‘stan_files/continuous.o’ failed
rm stan_files/jm.cc stan_files/continuous.cc stan_files/bernoulli.cc stan_files/binomial.cc stan_files/lm.cc stan_files/polr.cc stan_files/count.cc stan_files/mvmer.cc
ERROR: compilation failed for package ‘rstanarm’
- removing ‘/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1/rstanarm’
Warning in install.packages :
installation of package ‘rstanarm’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpXWRyQ4/downloaded_packages’
The same error even after increase to 16GB RAM
Restarting R session…
Sys.setenv(MAKEFLAGS = “-1”)
install.packages(“rstanarm”, repos = c(“Repository for distributing (some) stan-dev R packages | r-packages”, getOption(“repos”)))
Installing package into ‘/home/Hutchinson/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
trying URL ‘https://mc-stan.org/r-packages/src/contrib/rstanarm_2.21.2.tar.gz’
Content type ‘application/gzip’ length 755170 bytes (737 KB)
==================================================
downloaded 737 KB
- installing source package ‘rstanarm’ …
** using staged installation
** libs
Ah sorry, I’d mistyped in my earlier post. That should be (note the j):
Sys.setenv(MAKEFLAGS="-j1")