Hello,
I am new to Stan and am trying to get Stan working before a workshop I plan to attend.
I am following along with installation, RStan Getting Started · stan-dev/rstan Wiki · GitHub all seems well, until I try and run the sample code in which I get:
install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/R’
(as ‘lib’ is unspecified)
trying URL ‘https://cloud.r-project.org/bin/windows/contrib/3.6/rstan_2.18.2.zip’
Content type ‘application/zip’ length 4451314 bytes (4.2 MB)
downloaded 4.2 MB
package ‘rstan’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\kapitull\AppData\Local\Temp\RtmpmesDjx\downloaded_packages
pkgbuild::has_build_tools(debug = TRUE)
trying URL ‘https://cran.rstudio.com/bin/windows/Rtools/Rtools35.exe’
Content type ‘application/x-msdownload’ length 108622512 bytes (103.6 MB)
downloaded 103.6 MB
[1] FALSE
pkgbuild::has_build_tools(debug = TRUE)
[1] TRUE
library(“rstan”) # observe startup messages
Loading required package: ggplot2
Registered S3 methods overwritten by ‘ggplot2’:
method from
[.quosures rlang
c.quosures rlang
print.quosures rlang
Loading required package: StanHeaders
rstan (Version 2.18.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)
For improved execution time, we recommend calling
Sys.setenv(LOCAL_CPPFLAGS = ‘-march=native’)
although this causes Stan to throw an error on a few processors.
rstan_options(auto_write = TRUE)
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 = ‘8schools.stan’, data = schools_dat)
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! Error in .shlib_internal(commandArgs(TRUE)) :
C++14 standard requested but CXX14 is not defined
Calls: → .shlib_internal
Execution halted
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/R/bin/x64/R CMD SHLIB file34d462f6668e.cpp 2> file34d462f6668e.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection
setwd(“c:/R/work”)
fit ← stan(file = ‘8schools.stan’, data = schools_dat)
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! Error in .shlib_internal(commandArgs(TRUE)) :
C++14 standard requested but CXX14 is not defined
Calls: → .shlib_internal
Execution halted
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/R/bin/x64/R CMD SHLIB file34d430f6ab8.cpp 2> file34d430f6ab8.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection