stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
389 stars 133 forks source link

rstanarm: CRAN vs Development version installation issues #429

Closed Jack-FG closed 4 years ago

Jack-FG commented 4 years ago

I can not download the development version of rstanarm but have no issues with the CRAN version.

I have been able to successfully follow: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started to get started.

I have installed rstan and rstanarm (Cran) and have been able to succesfully run models with rstanarm (e.g. stan_glm).

However, I now want to access the stan_surv function which is only available in the github developement version of rstanarm. When I go to download this it fails to compile and install. Please see code attached for installation.

Remove packages and start with clean slate

remove.packages("rstan") Removing package from ‘C:/Users/21307937/OneDrive/R Packages’ (as ‘lib’ is unspecified) remove.packages("rstanarm") Removing package from ‘C:/Users/21307937/OneDrive/R Packages’ (as ‘lib’ is unspecified) Error in remove.packages : there is no package called ‘rstanarm’ if (file.exists(".RData")) file.remove(".RData")

Establish compiler

dotR <- file.path(Sys.getenv("HOME"), ".R") if (!file.exists(dotR)) dir.create(dotR) M <- file.path(dotR, ifelse(.Platform$OS.type == "windows", "Makevars.win", "Makevars")) if (!file.exists(M)) file.create(M) cat("\nCXX14FLAGS=-O3 -march=native -mtune=native",

  • if( grepl("^darwin", R.version$os)) "CXX14FLAGS += -arch x86_64 -ftemplate-depth-256" else
  • if (.Platform$OS.type == "windows") "CXX11FLAGS=-O3 -march=corei7 -mtune=corei7" else
  • "CXX14FLAGS += -fPIC",
  • file = M, sep = "\n", append = TRUE)

Install rstan

install.packages("rstan") Installing package into ‘C:/Users/21307937/OneDrive/R Packages’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rstan_2.19.3.zip' Content type 'application/zip' length 4734192 bytes (4.5 MB) downloaded 4.5 MB

package ‘rstan’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in C:\Users\21307937\AppData\Local\Temp\RtmpO2IHtu\downloaded_packages

pkgbuild::has_build_tools(debug = TRUE) [1] TRUE

Install development version of rstanarm

if (!require(devtools)) {

  • install.packages("devtools")
  • library(devtools)
  • } Loading required package: devtools Loading required package: usethis devtools::install_github("stan-dev/rstanarm", build_vignettes = FALSE) Downloading GitHub repo stan-dev/rstanarm@master stan-dev-rstanarm-8709540/tests/testthat/include: Can't create '\\?\C:\Users\21307937\AppData\Local\Temp\RtmpO2IHtu\remotes146ec886613f\stan-dev-rstanarm-8709540\tests\testthat\include' stan-dev-rstanarm-8709540/tests/testthat/stan_files: Can't create '\\?\C:\Users\21307937\AppData\Local\Temp\RtmpO2IHtu\remotes146ec886613f\stan-dev-rstanarm-8709540\tests\testthat\stan_files' tar.exe: Error exit delayed from previous errors.

√ checking for file 'C:\Users\21307937\AppData\Local\Temp\RtmpO2IHtu\remotes146ec886613f\stan-dev-rstanarm-8709540/DESCRIPTION' ...

Installing package into ‘C:/Users/21307937/OneDrive/R Packages’ (as ‘lib’ is unspecified)

*** arch - i386 "C:/PROGRA~1/R/R-35~1.2/bin/i386/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" stan_files/continuous.stan Wrote C++ file "stan_files/continuous.cc"

C:/Rtools/mingw_64/bin/g++.exe -m32 -std=c++1y -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -I"../inst/include" -I"C:/Users/21307937/OneDrive/R Packages/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG "C:/PROGRA~1/R/R-35~1.2/bin/Rscript" -e "RcppParallel::CxxFlags()" "C:/PROGRA~1/R/R-35~1.2/bin/Rscript" -e "StanHeaders:::CxxFlags()" -I"C:/Users/21307937/OneDrive/R Packages/StanHeaders/include" -I"C:/Users/21307937/OneDrive/R Packages/rstan/include" -I"C:/Users/21307937/OneDrive/R Packages/BH/include" -I"C:/Users/21307937/OneDrive/R Packages/Rcpp/include" -I"C:/Users/21307937/OneDrive/R Packages/RcppEigen/include" -I"C:/Users/21307937/OneDrive/R Packages/RcppParallel/include" -O3 -march=native -mtune=native -c stan_files/continuous.cc -o stan_files/continuous.o Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : object 'CxxFlags' not found Calls: ::: -> get Execution halted In file included from C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/random:49:0, from C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/bits/stl_algo.h:66, from C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/algorithm:62, from C:/Users/21307937/OneDrive/R Packages/Rcpp/include/RcppCommon.h:63, from C:/Users/21307937/OneDrive/R Packages/Rcpp/include/Rcpp.h:27, from stan_files/continuous.cc:1: C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/bits/random.h:106:26: error: expected unqualified-id before 'int128' { typedef unsigned int128 type; }; ^ make: *** [C:/PROGRA~1/R/R-35~1.2/etc/i386/Makeconf:213: stan_files/continuous.o] Error 1 rm stan_files/continuous.cc ERROR: compilation failed for package 'rstanarm'

session_info()

  • Session info ---------------------------------------------------------------------------------------------------------- setting value
    version R version 3.5.2 (2018-12-20) os Windows 10 x64
    system x86_64, mingw32
    ui RStudio
    language (EN)
    collate English_Australia.1252
    ctype English_Australia.1252

date 2020-04-17

[1] C:/Users/21307937/OneDrive/R Packages [2] C:/Program Files/R/R-3.5.2/library

sealavi commented 4 years ago

I am having this same issue. Did you find a solution before you closed this topic?

jgabry commented 4 years ago

I think this is the same issue that was being discussed on the Stan forums: https://discourse.mc-stan.org/t/rstanarm-cran-vs-development-version-installation-issues/14399

Here are the two comments on that thread from @bgoodri that seemed to fix the issue for the original poster:

Does that work for you? If not definitely feel free to also follow up on that discussion on the Stan forum (or start a new one).

Jack-FG commented 4 years ago

Yes it is the same issue, following @bgoodri notes allowed me to fix.

Jack-FG commented 4 years ago

They are just the links posted by @jgabry

sambrilleman commented 4 years ago

@sealavi See Jonah's comment in this issue thread. He posted the links there.