Error debugging

Short summary of the problem
I am new to STAN- I have a following error message
Appreciate your help.
code_to_run_your_model(if_applicable)
Try to calibrate Hierarchical Rasch model for item family

data{
int <lower=1> N_student; // number of individuals
int <lower=1> N_testlet; // number of item families
int <lower=1> NObs; // number of observations
int <lower=1> NIC; // number of item clones
int <lower=1> N_item; //number of items
int <lower=1, upper=N_student> ID_Stu[NObs]; // student ID
int <lower=1, upper=N_testlet> ID_Fam[NObs]; // item family ID
int <lower=1, upper=NIC> ID_Clone[NObs]; // item clone ID
int <lower=0, upper=1> Resp[NObs]; // person by person response vector
}

parameters {
vector[N_student] theta; // latent trait
vector[NIC] beta [N_testlet]; // length “NIC”" vector for each item “n_testlet”
real mu_beta [N_testlet]; // mean difficulty
real<lower=0> sigma_beta[N_testlet]; //difficulty sd
}

model{
row_vector[NObs] diff_local;
int fam_n;
theta ~ normal(0,1);
mu_beta ~ normal(0,5);
sigma_beta ~ cauchy(0,5);

for (i in 1: N_testlet){
beta[i] ~ normal(mu_beta[i],sigma_beta[i]);
}

for (j in 1:NObs){
fam_n = ID_Fam[j];
diff_local[j] = theta[ID_Stu[j]]-beta[fam_n, ID_Clone[j]];
}
Resp ~ bernoulli_logit(diff_local);
}

Error message

Error in file(con, “r”) : cannot open the connection
In addition: Warning messages:
1: In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file2ad03cf169a6.cpp 2> file2ad03cf169a6.cpp.err.txt’ had status 1
2: In file(con, “r”) :
cannot open file ‘file2ad03cf169a6.cpp.err.txt’: No such file or directory
Error in sink(type = “output”) : invalid connection

I tried a few solutions suggested by people - but no luck.

Don’t forget to add relevant tags to your topic (top right of this form) especially for application area. Delete this text before posting your question :-) Thx!

If your question relates to installation please provide the following information:

  • Operating System: windows 10
  • RStan Version: R4.02
  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))

writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”)))

Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘C:\Users\Jake Cho\Documents/.R/Makevars’: No such file or directory

  • Output of devtools::session_info("rstan")

devtools::session_info(“rstan”)
==================================================================

  • Session info ---------------------------------------------------------------------------------------
    setting value
    version R version 4.0.2 (2020-06-22)
    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-07-07

  • Packages -------------------------------------------------------------------------------------------
    ! package * version date lib source
    assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
    backports 1.1.8 2020-06-17 [1] CRAN (R 4.0.2)
    BH 1.72.0-3 2020-01-08 [1] CRAN (R 4.0.0)
    callr 3.4.3 2020-03-28 [1] CRAN (R 4.0.0)
    checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.0.0)
    cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0)
    colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.0)
    crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0)
    desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.0)
    digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.0)
    ellipsis 0.3.0 2019-09-20 [1] CRAN (R 4.0.0)
    evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0)
    fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0)
    farver 2.0.3 2020-01-16 [1] CRAN (R 4.0.0)
    ggplot2 * 3.3.2 2020-06-19 [1] CRAN (R 4.0.2)
    glue 1.4.0 2020-04-03 [1] CRAN (R 4.0.0)
    gridExtra 2.3 2017-09-09 [1] CRAN (R 4.0.0)
    gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.0)
    inline 0.3.15 2018-05-18 [1] CRAN (R 4.0.0)
    isoband 0.2.2 2020-06-20 [1] CRAN (R 4.0.2)
    labeling 0.3 2014-08-23 [1] CRAN (R 4.0.0)
    lattice 0.20-41 2020-04-02 [1] CRAN (R 4.0.0)
    lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0)
    loo 2.2.0 2019-12-19 [1] CRAN (R 4.0.0)
    magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0)
    MASS 7.3-51.6 2020-04-26 [1] CRAN (R 4.0.0)
    Matrix 1.2-18 2019-11-27 [2] CRAN (R 4.0.2)
    matrixStats 0.56.0 2020-03-13 [1] CRAN (R 4.0.0)
    mgcv 1.8-31 2019-11-09 [2] CRAN (R 4.0.2)
    munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.0)
    nlme 3.1-148 2020-05-24 [1] CRAN (R 4.0.0)
    pillar 1.4.4 2020-05-05 [1] CRAN (R 4.0.0)
    pkgbuild 1.0.8 2020-05-07 [1] CRAN (R 4.0.0)
    pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0)
    pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.0)
    praise 1.0.0 2015-08-11 [1] CRAN (R 4.0.0)
    prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.0)
    processx 3.4.2 2020-02-09 [1] CRAN (R 4.0.0)
    ps 1.3.2 2020-02-13 [1] CRAN (R 4.0.0)
    R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0)
    RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.0)
    Rcpp 1.0.4.6 2020-04-09 [1] CRAN (R 4.0.0)
    RcppEigen 0.3.3.7.0 2019-11-16 [1] CRAN (R 4.0.0)
    D RcppParallel 5.0.1 2020-05-06 [1] CRAN (R 4.0.0)
    rlang 0.4.6 2020-05-02 [1] CRAN (R 4.0.2)
    rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.0)
    rstan * 2.19.3 2020-02-11 [1] CRAN (R 4.0.2)
    rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.0)
    scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.0)
    StanHeaders * 2.21.0-5 2020-06-09 [1] CRAN (R 4.0.2)
    testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.0)
    tibble 3.0.1 2020-04-20 [1] CRAN (R 4.0.0)
    utf8 1.1.4 2018-05-24 [1] CRAN (R 4.0.0)
    vctrs 0.3.1 2020-06-05 [1] CRAN (R 4.0.2)
    viridisLite 0.3.0 2018-02-01 [1] CRAN (R 4.0.0)
    withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.0)

[1] C:/Users/Jake Cho/Documents/R/win-library/4.0
[2] C:/Program Files/R/R-4.0.2/library

D – DLL MD5 mismatch, broken installation.

If you are reporting a bug (thank you!) please use the issue tracker (github.com/stan-dev/rstan/issues) instead of the forums.

Looking forward to your topic!

Hi Jake,

This is an issue we’re having when using RStan 2.19 with StanHeaders 2.21. As a workaround, you can run your stan models by not loading the RStan package first.

So rather than:

library(rstan)
stan(model, data)

Use:

rstan::stan(model, data)

Thank you for the suggestion.
No luck yet.
Error in file(con, “r”) : cannot open the connection
In addition: Warning messages:
1: In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file2ad039d92147.cpp 2> file2ad039d92147.cpp.err.txt’ had status 1
2: In file(con, “r”) :
cannot open file ‘file2ad039d92147.cpp.err.txt’: No such file or directory
Error in sink(type = “output”) : invalid connection

Do you think my installation causes the problem? since it has "

D – DLL MD5 mismatch, broken installation."

Can you run:

example(stan_model,run.dontrun = TRUE,verbose=TRUE)

And post the line that starts with error: ?

Thanks again for your help.
I do not know what is the best way to post this lengthy output, but here it is.

example(stan_model,run.dontrun = TRUE,verbose=TRUE)
Found file = ‘C:/Users/Jake Cho/Documents/R/win-library/4.0/rstan/help/stan_model’
‘envir’ chosen:<environment: R_GlobalEnv>
encoding = “UTF-8” chosen
–> parsed 4 expressions; now eval(.)ing them:
has srcrefs:
List of 4
: 'srcref' int [1:8] 8 1 8 84 1 84 8 8 ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x000001b56190a020> : ‘srcref’ int [1:8] 9 1 9 56 1 56 9 9
…- attr(, “srcfile”)=Classes ‘srcfilecopy’, ‘srcfile’ <environment: 0x000001b56190a020>
: 'srcref' int [1:8] 10 1 10 45 1 45 10 10 ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x000001b56190a020> : ‘srcref’ int [1:8] 11 1 11 46 1 46 11 11
…- attr(
, “srcfile”)=Classes ‘srcfilecopy’, ‘srcfile’ <environment: 0x000001b56190a020>

eval(expression_nr. 1 )
=================

stn_md> stancode <- ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’
curr.fun: symbol <-
… after ‘expression(stancode <- ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’)’

eval(expression_nr. 2 )
=================

stn_md> mod <- stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL ‘73fc79f8b1915e8208c736914c86d1a1’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘73fc79f8b1915e8208c736914c86d1a1’.
COMPILING THE C++ CODE FOR MODEL ‘73fc79f8b1915e8208c736914c86d1a1’ NOW.
OS: x86_64, mingw32; rstan: 2.19.3; Rcpp: 1.0.4.6; inline: 0.3.15

setting environment variables:
PKG_LIBS = -L"C:/Users/Jake Cho/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders
PKG_CPPFLAGS = -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/Rcpp/include/" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/RcppEigen/include/" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/RcppEigen/include/unsupported" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/BH/include" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/StanHeaders/include/src/" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/StanHeaders/include/" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/rstan/include" -DEIGEN_NO_DEBUG -D_REENTRANT -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp -std=c++1y

Program source :

1 :
2 : // includes from the plugin
3 : // [[Rcpp::plugins(cpp14)]]
4 :
5 : // user includes
6 : #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
7 : #include <rstan/rstaninc.hpp>
8 : // Code generated by Stan version 2.19.1
9 :
10 : #include <stan/model/model_header.hpp>
11 :
12 : namespace model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace {
13 :
14 : using std::istream;
15 : using std::string;
16 : using std::stringstream;
17 : using std::vector;
18 : using stan::io::dump;
19 : using stan::math::lgamma;
20 : using stan::model::prob_grad;
21 : using namespace stan::math;
22 :
23 : static int current_statement_begin__;
24 :
25 : stan::io::program_reader prog_reader__() {
26 : stan::io::program_reader reader;
27 : reader.add_event(0, 0, “start”, “model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1”);
28 : reader.add_event(3, 1, “end”, “model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1”);
29 : return reader;
30 : }
31 :
32 : class model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1 : public prob_grad {
33 : private:
34 : double y_mean;
35 : public:
36 : model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1(stan::io::var_context& context__,
37 : std::ostream* pstream__ = 0)
38 : : prob_grad(0) {
39 : ctor_body(context__, 0, pstream__);
40 : }
41 :
42 : model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1(stan::io::var_context& context__,
43 : unsigned int random_seed__,
44 : std::ostream* pstream__ = 0)
45 : : prob_grad(0) {
46 : ctor_body(context__, random_seed__, pstream__);
47 : }
48 :
49 : void ctor_body(stan::io::var_context& context__,
50 : unsigned int random_seed__,
51 : std::ostream* pstream__) {
52 : typedef double local_scalar_t__;
53 :
54 : boost::ecuyer1988 base_rng__ =
55 : stan::services::util::create_rng(random_seed__, 0);
56 : (void) base_rng__; // suppress unused var warning
57 :
58 : current_statement_begin__ = -1;
59 :
60 : static const char* function__ = “model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1”;
61 : (void) function__; // dummy to suppress unused var warning
62 : size_t pos__;
63 : (void) pos__; // dummy to suppress unused var warning
64 : std::vector vals_i__;
65 : std::vector vals_r__;
66 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
67 : (void) DUMMY_VAR__; // suppress unused var warning
68 :
69 : try {
70 : // initialize data block variables from context__
71 : current_statement_begin__ = 1;
72 : context__.validate_dims(“data initialization”, “y_mean”, “double”, context__.to_vec());
73 : y_mean = double(0);
74 : vals_r__ = context__.vals_r(“y_mean”);
75 : pos__ = 0;
76 : y_mean = vals_r__[pos__++];
77 :
78 :
79 : // initialize transformed data variables
80 : // execute transformed data statements
81 :
82 : // validate transformed data
83 :
84 : // validate, set parameter ranges
85 : num_params_r__ = 0U;
86 : param_ranges_i__.clear();
87 : current_statement_begin__ = 1;
88 : num_params_r__ += 1;
89 : } catch (const std::exception& e) {
90 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
91 : // Next line prevents compiler griping about no return
92 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
93 : }
94 : }
95 :
96 : ~model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1() { }
97 :
98 :
99 : void transform_inits(const stan::io::var_context& context__,
100 : std::vector& params_i__,
101 : std::vector& params_r__,
102 : std::ostream
pstream__) const {
103 : typedef double local_scalar_t__;
104 : stan::io::writer writer__(params_r__, params_i__);
105 : size_t pos__;
106 : (void) pos__; // dummy call to supress warning
107 : std::vector vals_r__;
108 : std::vector vals_i__;
109 :
110 : current_statement_begin__ = 1;
111 : if (!(context__.contains_r(“y”)))
112 : stan::lang::rethrow_located(std::runtime_error(std::string(“Variable y missing”)), current_statement_begin__, prog_reader__());
113 : vals_r__ = context__.vals_r(“y”);
114 : pos__ = 0U;
115 : context__.validate_dims(“parameter initialization”, “y”, “double”, context__.to_vec());
116 : double y(0);
117 : y = vals_r__[pos__++];
118 : try {
119 : writer__.scalar_unconstrain(y);
120 : } catch (const std::exception& e) {
121 : stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable y: ") + e.what()), current_statement_begin__, prog_reader__());
122 : }
123 :
124 : params_r__ = writer__.data_r();
125 : params_i__ = writer__.data_i();
126 : }
127 :
128 : void transform_inits(const stan::io::var_context& context,
129 : Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r,
130 : std::ostream
pstream__) const {
131 : std::vector params_r_vec;
132 : std::vector params_i_vec;
133 : transform_inits(context, params_i_vec, params_r_vec, pstream__);
134 : params_r.resize(params_r_vec.size());
135 : for (int i = 0; i < params_r.size(); ++i)
136 : params_r(i) = params_r_vec[i];
137 : }
138 :
139 :
140 : template <bool propto__, bool jacobian__, typename T__>
141 : T__ log_prob(std::vector<T__>& params_r__,
142 : std::vector& params_i__,
143 : std::ostream
pstream__ = 0) const {
144 :
145 : typedef T__ local_scalar_t__;
146 :
147 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
148 : (void) DUMMY_VAR__; // dummy to suppress unused var warning
149 :
150 : T__ lp__(0.0);
151 : stan::math::accumulator<T__> lp_accum__;
152 : try {
153 : stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
154 :
155 : // model parameters
156 : current_statement_begin__ = 1;
157 : local_scalar_t__ y;
158 : (void) y; // dummy to suppress unused var warning
159 : if (jacobian__)
160 : y = in__.scalar_constrain(lp__);
161 : else
162 : y = in__.scalar_constrain();
163 :
164 : // model body
165 :
166 : current_statement_begin__ = 1;
167 : lp_accum__.add(normal_log<propto__>(y, y_mean, 1));
168 :
169 : } catch (const std::exception& e) {
170 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
171 : // Next line prevents compiler griping about no return
172 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
173 : }
174 :
175 : lp_accum__.add(lp__);
176 : return lp_accum__.sum();
177 :
178 : } // log_prob()
179 :
180 : template <bool propto, bool jacobian, typename T_>
181 : T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
182 : std::ostream
pstream = 0) const {
183 : std::vector<T_> vec_params_r;
184 : vec_params_r.reserve(params_r.size());
185 : for (int i = 0; i < params_r.size(); ++i)
186 : vec_params_r.push_back(params_r(i));
187 : std::vector vec_params_i;
188 : return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
189 : }
190 :
191 :
192 : void get_param_names(std::vectorstd::string& names__) const {
193 : names__.resize(0);
194 : names__.push_back(“y”);
195 : }
196 :
197 :
198 : void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
199 : dimss__.resize(0);
200 : std::vector<size_t> dims__;
201 : dims__.resize(0);
202 : dimss__.push_back(dims__);
203 : }
204 :
205 : template
206 : void write_array(RNG& base_rng__,
207 : std::vector& params_r__,
208 : std::vector& params_i__,
209 : std::vector& vars__,
210 : bool include_tparams__ = true,
211 : bool include_gqs__ = true,
212 : std::ostream
pstream__ = 0) const {
213 : typedef double local_scalar_t__;
214 :
215 : vars__.resize(0);
216 : stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
217 : static const char
function__ = “model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::write_array”;
218 : (void) function__; // dummy to suppress unused var warning
219 :
220 : // read-transform, write parameters
221 : double y = in__.scalar_constrain();
222 : vars__.push_back(y);
223 :
224 : double lp__ = 0.0;
225 : (void) lp__; // dummy to suppress unused var warning
226 : stan::math::accumulator lp_accum__;
227 :
228 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
229 : (void) DUMMY_VAR__; // suppress unused var warning
230 :
231 : if (!include_tparams__ && !include_gqs__) return;
232 :
233 : try {
234 : if (!include_gqs__ && !include_tparams__) return;
235 : if (!include_gqs__) return;
236 : } catch (const std::exception& e) {
237 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
238 : // Next line prevents compiler griping about no return
239 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
240 : }
241 : }
242 :
243 : template
244 : void write_array(RNG& base_rng,
245 : Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
246 : Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
247 : bool include_tparams = true,
248 : bool include_gqs = true,
249 : std::ostream
pstream = 0) const {
250 : std::vector params_r_vec(params_r.size());
251 : for (int i = 0; i < params_r.size(); ++i)
252 : params_r_vec[i] = params_r(i);
253 : std::vector vars_vec;
254 : std::vector params_i_vec;
255 : write_array(base_rng, params_r_vec, params_i_vec, vars_vec, include_tparams, include_gqs, pstream);
256 : vars.resize(vars_vec.size());
257 : for (int i = 0; i < vars.size(); ++i)
258 : vars(i) = vars_vec[i];
259 : }
260 :
261 : static std::string model_name() {
262 : return “model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1”;
263 : }
264 :
265 :
266 : void constrained_param_names(std::vectorstd::string& param_names__,
267 : bool include_tparams__ = true,
268 : bool include_gqs__ = true) const {
269 : std::stringstream param_name_stream__;
270 : param_name_stream__.str(std::string());
271 : param_name_stream__ << “y”;
272 : param_names__.push_back(param_name_stream__.str());
273 :
274 : if (!include_gqs__ && !include_tparams__) return;
275 :
276 : if (include_tparams__) {
277 : }
278 :
279 : if (!include_gqs__) return;
280 : }
281 :
282 :
283 : void unconstrained_param_names(std::vectorstd::string& param_names__,
284 : bool include_tparams__ = true,
285 : bool include_gqs__ = true) const {
286 : std::stringstream param_name_stream__;
287 : param_name_stream__.str(std::string());
288 : param_name_stream__ << “y”;
289 : param_names__.push_back(param_name_stream__.str());
290 :
291 : if (!include_gqs__ && !include_tparams__) return;
292 :
293 : if (include_tparams__) {
294 : }
295 :
296 : if (!include_gqs__) return;
297 : }
298 :
299 : }; // model
300 :
301 : } // namespace
302 :
303 : typedef model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1 stan_model;
304 :
305 : /

306 : * Define Rcpp Module to expose stan_fit’s functions to R.
307 : */
308 : RCPP_MODULE(stan_fit4model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_mod){
309 : Rcpp::class_<rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1,
310 : boost::random::ecuyer1988> >(“stan_fit4model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1”)
311 : // .constructorRcpp::List()
312 : .constructor<SEXP, SEXP, SEXP>()
313 : // .constructor<SEXP, SEXP>()
314 : .method(“call_sampler”,
315 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::call_sampler)
316 : .method(“param_names”,
317 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_names)
318 : .method(“param_names_oi”,
319 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_names_oi)
320 : .method(“param_fnames_oi”,
321 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_fnames_oi)
322 : .method(“param_dims”,
323 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_dims)
324 : .method(“param_dims_oi”,
325 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_dims_oi)
326 : .method(“update_param_oi”,
327 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::update_param_oi)
328 : .method(“param_oi_tidx”,
329 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_oi_tidx)
330 : .method(“grad_log_prob”,
331 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::grad_log_prob)
332 : .method(“log_prob”,
333 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::log_prob)
334 : .method(“unconstrain_pars”,
335 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::unconstrain_pars)
336 : .method(“constrain_pars”,
337 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::constrain_pars)
338 : .method(“num_pars_unconstrained”,
339 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::num_pars_unconstrained)
340 : .method(“unconstrained_param_names”,
341 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::unconstrained_param_names)
342 : .method(“constrained_param_names”,
343 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::constrained_param_names)
344 : .method(“standalone_gqs”,
345 : &rstan::stan_fit<model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1_namespace::model2ad07a996e52_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::standalone_gqs)
346 : ;
347 : }
348 :
349 : // declarations
350 : extern “C” {
351 : SEXP file2ad012024a9d( ) ;
352 : }
353 :
354 : // definition
355 :
356 : SEXP file2ad012024a9d( ){
357 : return Rcpp::wrap(“73fc79f8b1915e8208c736914c86d1a1”);
358 : }
359 :
360 :
Compilation argument:
C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file2ad012024a9d.cpp 2> file2ad012024a9d.cpp.err.txt
“C:/rtools40/mingw64/bin/“g++ -O2 -march=native -mtune=native -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.2/include” -DNDEBUG -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/Rcpp/include/” -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/RcppEigen/include/" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/RcppEigen/include/unsupported" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/BH/include" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/StanHeaders/include/src/" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/StanHeaders/include/" -I"C:/Users/Jake Cho/Documents/R/win-library/4.0/rstan/include" -DEIGEN_NO_DEBUG -D_REENTRANT -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp -std=c++1y -march=core2 -include C:/Users/Jake Cho/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I “C:/Users/Jake Cho/Documents/R/win-library/4.0/StanHeaders/include” -I “C:/Users/Jake Cho/Documents/R/win-library/4.0/RcppEigen/include” -O3 -march=native -mtune=native -c file2ad012024a9d.cpp -o file2ad012024a9d.o
g++.exe: error: Cho/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory
make: *** [C:/PROGRA~1/R/R-40~1.2/etc/x64/Makeconf:229: file2ad012024a9d.o] Error 1
Error in file(con, “r”) : cannot open the connection
In addition: Warning messages:
1: In find.package(package, lib.loc, verbose = verbose) :
package ‘MASS’ found more than once, using the first from
“C:/Users/Jake Cho/Documents/R/win-library/4.0/MASS”,
“C:/Program Files/R/R-4.0.2/library/MASS”
2: In find.package(package, lib.loc, verbose = verbose) :
package ‘base’ found more than once, using the first from
“C:/PROGRA~1/R/R-40~1.2/library/base”,
“C:/Program Files/R/R-4.0.2/library/base”
3: In file(con, “r”) :
cannot open file ‘file2ad012024a9d.cpp.err.txt’: No such file or directory

Thanks! That output means that everything appears to be configured correctly, but that there is the issue that I mentioned earlier.

Can you make sure that you’ve restarted R/RStudio (the .rs.restartR() command is not sufficient, you have to close and re-open the program) before you run rstan::stan(model, data)?

Basically have to make sure that the RStan package is not loaded at any point before you call stan

Hi Andrew,
It worked.
Appreciate your help.
One last thing- would it be possible to activate “Stan” after estimation
to use other functions?