Is there a current intro to what goes into a successful Makevars file for brms and Stan?
I seem to have a similar issue on Windows 10. I’m pretty sure I last fitted a model a week or so ago using brms in R 3.5.3. I upgraded to R 3.6.0, and now I have problems:
R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (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.
> setwd('<localpathname>')
> library(brms)
Loading required package: Rcpp
Registered S3 method overwritten by 'xts':
method from
as.zoo.xts zoo
Loading 'brms' package (version 2.9.0). Useful instructions
can be found by typing help('brms'). A more detailed introduction
to the package is available through vignette('brms_overview').
> example(brm,run.dontrun = TRUE)
brm> # Poisson regression for the number of seizures in epileptic patients
brm> # using student_t priors for population-level effects
brm> # and half cauchy priors for standard deviations of group-level effects
brm> bprior1 <- prior(student_t(5,0,10), class = b) +
brm+ prior(cauchy(0,2), class = sd)
brm> fit1 <- brm(count ~ zAge + zBase * Trt + (1|patient),
brm+ data = epilepsy, family = poisson(), prior = bprior1)
Compiling the C++ model
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from c:/R/R-3.6.0/library/BH/include/boost/random/detail/integer_log2.hpp:19:0,
from c:/R/R-3.6.0/library/BH/include/boost/random/detail/int_float_pair.hpp:26,
from c:/R/R-3.6.0/library/BH/include/boost/random/exponential_distribution.hpp:27,
from c:/R/R-3.6.0/library/BH/include/boost/random/gamma_distribution.hpp:25,
from c:/R/R-3.6.0/library/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
from c:/R/R-3.6.0/library/StanHeaders/include/stan/math/prim/mat.hpp:292,
from c:/R/R-3.6.0/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
from c:/R/R-3.6.0/library/StanHeaders/include/stan/math.hpp:4,
from c:/R/R-3.6.0/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
from file55ec5a816343.cpp:8:
c:/R/R-3.6.0/library/BH/include/boos
Error in sink(type = "output") : invalid connection
>
I’ve searched for Makevar.win help, and I’ve tried several alternatives, starting with the one created programatically by the snippet on Stan’s R interface page. Here’s the version that created the above trace:
CXX14 = g++ -std=c++1y
CXX14FLAGS=-O3 -Wno-unused-variable -Wno-unused-function
CXX11FLAGS=-O3
Here is a traceback:
> traceback()
21: sink(type = "output")
20: cxxfunctionplus(signature(), body = paste(" return Rcpp::wrap(\"",
model_name, "\");", sep = ""), includes = inc, plugin = "rstan",
save_dso = save_dso | auto_write, module_name = paste("stan_fit4",
model_cppname, "_mod", sep = ""), verbose = verbose)
19: .fun(model_code = .x1) at <text>#1
18: eval(expr, envir, ...)
17: eval(expr, envir, ...)
16: eval2(call, envir = args, enclos = parent.frame())
15: do_call(rstan::stan_model, stan_model_args)
14: eval(expr, envir)
13: eval(expr, envir)
12: eval(expr, pf)
11: eval(expr, pf)
10: withVisible(eval(expr, pf))
9: evalVis(expr)
8: utils::capture.output(out <- eval(expr, envir), type = type,
...)
7: eval_silent(do_call(rstan::stan_model, stan_model_args), silent = silence_stan_model,
type = "message")
6: brm(count ~ zAge + zBase * Trt + (1 | patient), data = epilepsy,
family = poisson(), prior = bprior1) at Rex3c0c7e5b6545#14
5: eval(ei, envir)
4: eval(ei, envir)
3: withVisible(eval(ei, envir))
2: source(tf, local, echo = echo, prompt.echo = paste0(prompt.prefix,
getOption("prompt")), continue.echo = paste0(prompt.prefix,
getOption("continue")), verbose = verbose, max.deparse.length = Inf,
encoding = "UTF-8", skip.echo = skips, keep.source = TRUE)
1: example(brm, run.dontrun = TRUE)
>
Here’s my sessionInfo():
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] brms_2.9.0 Rcpp_1.0.1
loaded via a namespace (and not attached):
[1] mvtnorm_1.0-11 lattice_0.20-38 prettyunits_1.0.2
[4] ps_1.3.0 zoo_1.8-6 gtools_3.8.1
[7] assertthat_0.2.1 digest_0.6.19 mime_0.7
[10] R6_2.4.0 plyr_1.8.4 backports_1.1.4
[13] ggridges_0.5.1 stats4_3.6.0 coda_0.19-2
[16] ggplot2_3.2.0 colourpicker_1.0 pillar_1.4.2
[19] rlang_0.4.0 lazyeval_0.2.2 miniUI_0.1.1.1
[22] callr_3.2.0 Matrix_1.2-17 DT_0.7
[25] shinythemes_1.1.2 shinyjs_1.0 stringr_1.4.0
[28] htmlwidgets_1.3 loo_2.1.0 igraph_1.2.4.1
[31] munsell_0.5.0 shiny_1.3.2 compiler_3.6.0
[34] httpuv_1.5.1 rstan_2.18.2 pkgconfig_2.0.2
[37] base64enc_0.1-3 pkgbuild_1.0.3 rstantools_1.5.1
[40] htmltools_0.3.6 tidyselect_0.2.5 tibble_2.1.3
[43] gridExtra_2.3 threejs_0.3.1 matrixStats_0.54.0
[46] withr_2.1.2 crayon_1.3.4 dplyr_0.8.2
[49] later_0.8.0 grid_3.6.0 nlme_3.1-140
[52] xtable_1.8-4 gtable_0.3.0 magrittr_1.5
[55] StanHeaders_2.18.1-10 scales_1.0.0 cli_1.1.0
[58] stringi_1.4.3 reshape2_1.4.3 promises_1.0.1
[61] dygraphs_1.1.1.6 xts_0.11-2 tools_3.6.0
[64] glue_1.3.1 shinystan_2.5.0 markdown_1.0
[67] purrr_0.3.2 crosstalk_1.0.0 processx_3.3.1
[70] rsconnect_0.8.13 abind_1.4-5 parallel_3.6.0
[73] inline_0.3.15 colorspace_1.4-1 bridgesampling_0.6-0
[76] bayesplot_1.7.0 Brobdingnag_1.2-6
>
I’m running in ESS version 18.10.2 on GNU Emacs version 26.1.
UPDATE: I am running Rtools version 3.4.0.1964. Should I consider 3.5.0?
I don’t know much about C++ or what should go into a Makevars file.
Is there anything I can look at that might help you help me get brms working again?