dr-jojo
November 6, 2020, 3:08pm
16
And then:
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 model242412b94d4b_efb77423d7adb44255913eac3d9377e8_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”, “model242412b94d4b_efb77423d7adb44255913eac3d9377e8”);
32 : reader.add_event(3, 1, “end”, “model242412b94d4b_efb77423d7adb44255913eac3d9377e8”);
33 : return reader;
34 : }
35 :
36 : class model242412b94d4b_efb77423d7adb44255913eac3d9377e8
37 : : public stan::model::model_base_crtp<model242412b94d4b_efb77423d7adb44255913eac3d9377e8> {
38 : private:
39 : double y_mean;
40 : public:
41 : model242412b94d4b_efb77423d7adb44255913eac3d9377e8(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 : model242412b94d4b_efb77423d7adb44255913eac3d9377e8(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__ =
dr-jojo
November 6, 2020, 3:08pm
17
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 vals_i__;
70 : std::vector vals_r__;
71 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::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 : ~model242412b94d4b_efb77423d7adb44255913eac3d9377e8() { }
dr-jojo
November 6, 2020, 3:09pm
18
102 :
103 :
104 : void transform_inits(const stan::io::var_context& context__,
105 : std::vector& params_i__,
106 : std::vector& params_r__,
107 : std::ostream* pstream__) const {
108 : typedef double local_scalar_t__;
109 : stan::io::writer writer__(params_r__, params_i__);
110 : size_t pos__;
111 : (void) pos__; // dummy call to supress warning
112 : std::vector vals_r__;
113 : std::vector 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 params_r_vec;
137 : std::vector 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& 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::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 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::vectorstd::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
211 : void write_array(RNG& base_rng__,
212 : std::vector& params_r__,
213 : std::vector& params_i__,
214 : std::vector& 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__ = “model242412b94d4b_efb77423d7adb44255913eac3d9377e8_namespace::write_array”;
dr-jojo
November 6, 2020, 3:10pm
19
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 lp_accum__;
232 :
233 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::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 : }
dr-jojo
November 6, 2020, 3:11pm
20
247 :
248 : template
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 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 vars_vec;
259 : std::vector 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 “model242412b94d4b_efb77423d7adb44255913eac3d9377e8”;
268 : }
269 :
270 :
271 : void constrained_param_names(std::vectorstd::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::vectorstd::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 model242412b94d4b_efb77423d7adb44255913eac3d9377e8_namespace::model242412b94d4b_efb77423d7adb44255913eac3d9377e8 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)
fi
dr-jojo
November 6, 2020, 3:11pm
21
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::XPtrstan::model::model_base model_ptr(stan_model_holder* smh) {
339 : Rcpp::XPtrstan::model::model_base model_instance(new stan_model(smh->rcontext_, smh->random_seed_), true);
340 : return model_instance;
341 : }
342 :
343 : Rcpp::XPtrrstan::stan_fit_base fit_ptr(stan_model_holder* smh) {
344 : return Rcpp::XPtrrstan::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_fit4model242412b94d4b_efb77423d7adb44255913eac3d9377e8_mod){
352 : Rcpp::class_<stan_model_holder>(“stan_fit4model242412b94d4b_efb77423d7adb44255913eac3d9377e8”)
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 file24241c9c430e( ) ;
364 : }
365 :
366 : // definition
367 :
368 : SEXP file24241c9c430e( ){
369 : return Rcpp::wrap(“efb77423d7adb44255913eac3d9377e8”);
370 : }
371 :
372 :
make cmd is
make -f “C:/PROGRA~1/R/R-40~1.3/etc/x64/Makeconf” -f “C:/PROGRA~1/R/R-40~1.3/share/make/winshlib.mk” CXX=’(CXX14) (CXX14STD)’ CXXFLAGS=’(CXX14FLAGS)' CXXPICFLAGS=' (CXX14PICFLAGS)’ SHLIB_LDFLAGS=’(SHLIB_CXX14LDFLAGS)' SHLIB_LD=' (SHLIB_CXX14LD)’ SHLIB=“file24241c9c430e.dll” WIN=64 TCLBIN=64 OBJECTS=“file24241c9c430e.o”
make would use
“C:/rtools40/mingw64/bin/“g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.3/include” -DNDEBUG -I"C:/Users/JoJo/Documents/R/win-library/4.0/Rcpp/include/” -I"C:/Users/JoJo/Documents/R/win-library/4.0/RcppEigen/include/" -I"C:/Users/JoJo/Documents/R/win-library/4.0/RcppEigen/include/unsupported" -I"C:/Users/JoJo/Documents/R/win-library/4.0/BH/include" -I"C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/include/src/" -I"C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/include/" -I"C:/Users/JoJo/Documents/R/win-library/4.0/RcppParallel/include/" -I"C:/Users/JoJo/Documents/R/win-library/4.0/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include “C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp” -std=c++1y -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c file24241c9c430e.cpp -o file24241c9c430e.o
if test “zfile24241c9c430e.o” != “z”; then
if test -e “file24241c9c430e-win.def”; then
echo “C:/rtools40/mingw64/bin/“g++ -shared -s -static-libgcc -o file24241c9c430e.dll file24241c9c430e-win.def file24241c9c430e.o “C:/Users/JoJo/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a” -L"C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/libs/x64” -lStanHeaders -L"C:/Users/JoJo/Documents/R/win-library/4.0/RcppParallel/lib/x64” -ltbb -L"C:/PROGRA~1/R/R-40~1.3/bin/x64" -lR ;
“C:/rtools40/mingw64/bin/“g++ -shared -s -static-libgcc -o file24241c9c430e.dll file24241c9c430e-win.def file24241c9c430e.o “C:/Users/JoJo/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a” -L"C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/libs/x64” -lStanHeaders -L"C:/Users/JoJo/Documents/R/win-library/4.0/RcppParallel/lib/x64” -ltbb -L"C:/PROGRA~1/R/R-40~1.3/bin/x64" -lR ;
else
echo EXPORTS > tmp.def;
“C:/rtools40/mingw64/bin/“nm file24241c9c430e.o | sed -n ‘s/^.* [BCDRT] / /p’ | sed -e ‘/[.]refptr[.]/d’ -e ‘/[.]weak[.]/d’ | sed 's/[^ ][^ ]*/”&”/g’ >> tmp.def;
echo “C:/rtools40/mingw64/bin/“g++ -shared -s -static-libgcc -o file24241c9c430e.dll tmp.def file24241c9c430e.o “C:/Users/JoJo/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a” -L"C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/libs/x64” -lStanHeaders -L"C:/Users/JoJo/Documents/R/win-library/4.0/RcppParallel/lib/x64” -ltbb -L"C:/PROGRA~1/R/R-40~1.3/bin/x64" -lR ;
“C:/rtools40/mingw64/bin/“g++ -shared -s -static-libgcc -o file24241c9c430e.dll tmp.def file24241c9c430e.o “C:/Users/JoJo/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a” -L"C:/Users/JoJo/Documents/R/win-library/4.0/StanHeaders/libs/x64” -lStanHeaders -L"C:/Users/JoJo/Documents/R/win-library/4.0/RcppParallel/lib/x64” -ltbb -L"C:/PROGRA~1/R/R-40~1.3/bin/x64" -lR ;
rm -f tmp.def;
fi \
dr-jojo
November 6, 2020, 3:12pm
22
CHECKING DATA AND PREPROCESSING FOR MODEL ‘efb77423d7adb44255913eac3d9377e8’ NOW.
COMPILING MODEL ‘efb77423d7adb44255913eac3d9377e8’ NOW.
STARTING SAMPLER FOR MODEL ‘efb77423d7adb44255913eac3d9377e8’ NOW.
SAMPLING FOR MODEL ‘efb77423d7adb44255913eac3d9377e8’ NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 0 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0 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.011 seconds (Warm-up)
Chain 1: 0.014 seconds (Sampling)
Chain 1: 0.025 seconds (Total)
Chain 1:
Inference for Stan model: efb77423d7adb44255913eac3d9377e8.
1 chains, each with iter=2000; warmup=1000; thin=1;
post-warmup draws per chain=1000, total post-warmup draws=1000.
mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat
y -0.04 0.06 1.02 -2.00 -0.71 -0.04 0.67 2.04 343 1.00
lp__ -0.52 0.03 0.74 -2.71 -0.70 -0.25 -0.05 0.00 494 1.01
Samples were drawn using NUTS(diag_e) at Fri Nov 06 10:01:28 2020.
For each parameter, n_eff is a crude measure of effective sample size,
and Rhat is the potential scale reduction factor on split chains (at
convergence, Rhat=1).
Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
Hmm, I’ve never seen this before (RStan working but brms crashing). Sorry for the trouble!
The next test is to get the model and data that brms
creates and try running that through rstan.
Can you try the following:
library(brms)
library(rstan)
stancode = make_stancode(formula = time | cens(censored) ~ age * sex + disease
+ (1 + age|patient), cores = 4,
data = kidney, family = lognormal(),
prior = c(set_prior("normal(0,5)", class = "b"),
set_prior("cauchy(0,2)", class = "sd"),
set_prior("lkj(2)", class = "cor")))
standata = make_standata(formula = time | cens(censored) ~ age * sex + disease
+ (1 + age|patient), cores = 4,
data = kidney, family = lognormal(),
prior = c(set_prior("normal(0,5)", class = "b"),
set_prior("cauchy(0,2)", class = "sd"),
set_prior("lkj(2)", class = "cor")))
mod = stan(model_code=stancode,data=standata)
hola,
I wanna install rstan in windows, the only problem is that I don´t have my Rtools in the default location I have to put it somewhere else, so I put in makevar.win the new location and follow the instalion steps but when I call the library or run stan I got the following error:
Error in cleanup_makevar(old) :
argument "RMU" is missing, with no default
In addition: Warning messages:
1: In readLines(file, warn = TRUE) :
incomplete final line found on '\\home.org.aalto.fi\alonzoi1\data\Documents\school.stan'
2: In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
'Z:/rtools40/usr/mingw_/bin/g++' not found
3: In readLines(file.path(makevar_files)) :
incomplete final line found on '//home.org.aalto.fi/alonzoi1/data/Documents/.R/Makevars.win'
4: In readLines(old_path) :
incomplete final line found on '//home.org.aalto.fi/alonzoi1/data/Documents/.R/Makevars.win'
@andrjohns do you know how an I fix this error?
RStan on windows currently doesn’t like a Makevars.win
file and throws that error. You have a couple of options here. First, you can use the .Renviron
and/or .Rprofile
files to configure where R looks for compilers and remove your Makevars file.
Instead (or in addition to), you can downgrade your withr
package to 2.20, which should work:
devtools::install_version("withr",version="2.20")
Then restart R and try again.
Also, add a blank line to the end of your Makevars.win
file and stan code to remove the incomplete final line
errors
1 Like
dr-jojo
November 9, 2020, 2:54pm
26
So the first parts of the stan code run just fine. Then when I try to run the mod code it crashed on me twice. Then when I got it to not crash it gave me this again:
Error in unserialize(socklist[[n]]) : error reading from connection
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
Error in serialize(data, node$con, xdr = FALSE) :
error writing to connection
Can you post the output from:
Sys.getenv("PATH")
Sys.getenv("BINPREF")
readLines("~/.R/Makevars.win")
readLines("~/.Rprofile")
readLines("~/.Renviron")
devtools::session_info("rstan")
I know you’ve already posted it, but I just need to double-check that nothing’s changed
dr-jojo
November 9, 2020, 3:06pm
28
Sys.getenv(“PATH”)
[1] “C:\rtools40\usr\bin;C:\Program Files\R\R-4.0.3\bin\x64;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;D:\JRE\bin;C:\Users\JoJo\AppData\Local\Microsoft\WindowsApps”
Sys.getenv(“BINPREF”)
[1] “”
readLines(“~/.R/Makevars.win”)
Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘C:/Users/JoJo/Documents/.R/Makevars.win’: No such file or directory
readLines(“~/.Rprofile”)
Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘C:/Users/JoJo/Documents/.Rprofile’: No such file or directory
readLines(“~/.Renviron”)
[1] “PATH="{RTOOLS40_HOME}\\usr\\bin; {PATH}"”
devtools::session_info(“rstan”)
Session info ---------------------------------------------------------------------------------------------------------------------------
setting value
version R version 4.0.3 (2020-10-10)
os Windows 10 x64
system x86_64, mingw32
ui RStudio
language (EN)
collate English_United States.1252
ctype English_United States.1252
tz America/New_York
date 2020-11-09
Packages -------------------------------------------------------------------------------------------------------------------------------
! package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.3)
backports 1.1.10 2020-09-15 [1] CRAN (R 4.0.3)
BH 1.72.0-3 2020-01-08 [1] CRAN (R 4.0.3)
callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.3)
checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.0.3)
cli 2.1.0 2020-10-12 [1] CRAN (R 4.0.3)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.3)
crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.3)
curl 4.3 2019-12-02 [1] CRAN (R 4.0.3)
desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.3)
digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.3)
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.3)
evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.3)
fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.3)
farver 2.0.3 2020-01-16 [1] CRAN (R 4.0.3)
ggplot2 * 3.3.2 2020-06-19 [1] CRAN (R 4.0.3)
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.3)
gridExtra 2.3 2017-09-09 [1] CRAN (R 4.0.3)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.3)
inline 0.3.16 2020-09-06 [1] CRAN (R 4.0.3)
isoband 0.2.2 2020-06-20 [1] CRAN (R 4.0.3)
jsonlite 1.7.1 2020-09-07 [1] CRAN (R 4.0.3)
labeling 0.4.2 2020-10-20 [1] CRAN (R 4.0.3)
lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.3)
lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.3)
loo 2.3.1 2020-07-14 [1] CRAN (R 4.0.3)
magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.3)
MASS 7.3-53 2020-09-09 [2] CRAN (R 4.0.3)
Matrix 1.2-18 2019-11-27 [2] CRAN (R 4.0.3)
matrixStats 0.57.0 2020-09-25 [1] CRAN (R 4.0.3)
mgcv 1.8-33 2020-08-27 [2] CRAN (R 4.0.3)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.3)
nlme 3.1-149 2020-08-23 [2] CRAN (R 4.0.3)
pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.3)
pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.3)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.3)
pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.3)
praise 1.0.0 2015-08-11 [1] CRAN (R 4.0.3)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.3)
processx 3.4.4 2020-09-03 [1] CRAN (R 4.0.3)
ps 1.4.0 2020-10-07 [1] CRAN (R 4.0.3)
R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.3)
RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.3)
Rcpp * 1.0.5 2020-07-06 [1] CRAN (R 4.0.3)
RcppEigen 0.3.3.7.0 2019-11-16 [1] CRAN (R 4.0.3)
D RcppParallel 5.0.2 2020-06-24 [1] CRAN (R 4.0.3)
rlang 0.4.8 2020-10-08 [1] CRAN (R 4.0.3)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.3)
rstan * 2.21.2 2020-07-27 [1] CRAN (R 4.0.3)
rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.3)
scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.3)
StanHeaders * 2.21.0-6 2020-08-16 [1] CRAN (R 4.0.3)
testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.3)
tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.3)
utf8 1.1.4 2018-05-24 [1] CRAN (R 4.0.3)
V8 3.3.1 2020-10-26 [1] CRAN (R 4.0.3)
vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.3)
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 4.0.3)
withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.3)
[1] C:/Users/JoJo/Documents/R/win-library/4.0
[2] C:/Program Files/R/R-4.0.3/library
D – DLL MD5 mismatch, broken installation.
Thanks! I’ll have to call in for help with debugging this.
@bgoodri This user is getting crashes in RStan. The example model compiles & samples, but more complex models like this brms model crash.
A quick config summary:
No Makevars.win or .Rprofile
RStan, StanHeaders, and inline all up-to-date
make statement in this post
dr-jojo
November 17, 2020, 2:37pm
30
Do you know if there is any updates on this, I have not seen any replies? Thanks
Hi @andrjohns I am trying to install rstan in windows, and after following all the procedures in the stan repository, but I still have some problems. When I ran
example(stan_model, package = “rstan”, run.dontrun = TRUE)
I got this error:
Error in compileCode(f, code, language = language, verbose = verbose) :
cc1plus.exe: fatal error: \home.org.aalto.fi/alonzoi1/data/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directorycompilation terminated.make: *** [C:/PROGRA~1/R/R-40~1.3/etc/x64/Makeconf:229: file20869442cca.o] Error 1
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
Thank you in advance.
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Yep that error happens when your R package directory is on a network drive, you need to move your packages to a location on your local computer
thanks for your reply, but I don´t understand, both R and Rtools are in the window default C: directory…How do I do that?
While the R and RStudio programs themselves are installed on the C:/ drive, your R packages (rstan
, etc.) are installed in your ‘Home’ directory, which the error message above indicates is on an external network drive (\home.org.aalto.fi/alonzoi1/data/Documents
). You need to move your R packages to a folder on your local C:/ Drive.
I posted some instructions on how to do this over in this post . Those instructions were putting the R packages in the C:/Users/R
folder, so just change that path to wherever you want to move your R packages to
2 Likes