It seemed to download and install fine this time (with R 2.15.1).
But then it crashes:
> library(rstan)
Error: package ‘Rcpp’ required by ‘rstan’ could not be found
Then I had the same problem with:
Rcpp
RcppEigen
inline
I've seen some packages auto-install other packages. Can/should
we do this?
Then, when they were all installed, the compiler crashed on
the model. Here's the message I got:
> fit <- stan(model.code = schools.code, data = dat,
+ n.iter = 2012, n.chains = 4)
COMPILING MODEL 'anon_model' FROM Stan CODE TO C++ CODE NOW.
COMPILING THE C++ CODE FOR MODEL 'anon_model' NOW.
filef8ab3cb9ddf2.cpp:6:30: error: rstan/rstaninc.hpp: No such file or directory
filef8ab3cb9ddf2.cpp:9:39: error: stan/model/model_header.hpp: No such file or directory
filef8ab3cb9ddf2.cpp:13: error: ‘std::vector’ has not been declared
filef8ab3cb9ddf2.cpp:14: error: ‘std::string’ has not been declared
filef8ab3cb9ddf2.cpp:15: error: ‘std::stringstream’ has not been declared
filef8ab3cb9ddf2.cpp:16: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:17: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:18: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:19: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:20: error: ‘std::istream’ has not been declared
filef8ab3cb9ddf2.cpp:21: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:21: error: ‘math’ is not a namespace-name
filef8ab3cb9ddf2.cpp:21: error: expected namespace-name before ‘;’ token
filef8ab3cb9ddf2.cpp:22: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:22: error: ‘prob’ is not a namespace-name
filef8ab3cb9ddf2.cpp:22: error: expected namespace-name before ‘;’ token
filef8ab3cb9ddf2.cpp:23: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:23: error: ‘agrad’ is not a namespace-name
filef8ab3cb9ddf2.cpp:23: error: expected namespace-name before ‘;’ token
filef8ab3cb9ddf2.cpp:25: error: ‘Eigen’ has not been declared
filef8ab3cb9ddf2.cpp:25: error: expected initializer before ‘<’ token
filef8ab3cb9ddf2.cpp:26: error: ‘Eigen’ has not been declared
filef8ab3cb9ddf2.cpp:26: error: expected initializer before ‘<’ token
filef8ab3cb9ddf2.cpp:27: error: ‘Eigen’ has not been declared
filef8ab3cb9ddf2.cpp:27: error: expected initializer before ‘<’ token
filef8ab3cb9ddf2.cpp:28: error: ‘Eigen’ has not been declared
filef8ab3cb9ddf2.cpp:28: error: expected initializer before ‘<’ token
filef8ab3cb9ddf2.cpp:29: error: ‘Eigen’ has not been declared
filef8ab3cb9ddf2.cpp:29: error: expected initializer before ‘<’ token
filef8ab3cb9ddf2.cpp:30: error: ‘Eigen’ has not been declared
filef8ab3cb9ddf2.cpp:30: error: expected initializer before ‘<’ token
filef8ab3cb9ddf2.cpp:32: error: expected class-name before ‘{’ token
filef8ab3cb9ddf2.cpp:35: error: ISO C++ forbids declaration of ‘vector’ with no type
filef8ab3cb9ddf2.cpp:35: error: expected ‘;’ before ‘<’ token
filef8ab3cb9ddf2.cpp:36: error: ISO C++ forbids declaration of ‘vector’ with no type
filef8ab3cb9ddf2.cpp:36: error: expected ‘;’ before ‘<’ token
filef8ab3cb9ddf2.cpp:38: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:38: error: expected `)' before ‘&’ token
filef8ab3cb9ddf2.cpp:311: error: expected `}' at end of input
filef8ab3cb9ddf2.cpp:311: error: expected unqualified-id at end of input
filef8ab3cb9ddf2.cpp:311: error: expected `}' at end of input
make: *** [filef8ab3cb9ddf2.o] Error 1
ERROR(s) during compilation: source code errors or compiler configuration errors!
Program source:
1:
2: // includes from the plugin
3:
4:
5: // user includes
6: #include <rstan/rstaninc.hpp>
7: // Code generated by Stan version 1.0
8:
9: #include <stan/model/model_header.hpp>
10:
11: namespace stan_model_namespace {
12:
13: using std::vector;
14: using std::string;
15: using std::stringstream;
16: using stan::agrad::var;
17: using stan::model::prob_grad_ad;
18: using stan::math::get_base1;
19: using stan::io::dump;
20: using std::istream;
21: using namespace stan::math;
22: using namespace stan::prob;
23: using namespace stan::agrad;
24:
25: typedef Eigen::Matrix<double,Eigen::Dynamic,1> vector_d;
26: typedef Eigen::Matrix<double,1,Eigen::Dynamic> row_vector_d;
27: typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> matrix_d;
28: typedef Eigen::Matrix<stan::agrad::var,Eigen::Dynamic,1> vector_v;
29: typedef Eigen::Matrix<stan::agrad::var,1,Eigen::Dynamic> row_vector_v;
30: typedef Eigen::Matrix<stan::agrad::var,Eigen::Dynamic,Eigen::Dynamic> matrix_v;
31:
32: class stan_model : public prob_grad_ad {
33: private:
34: int J;
35: vector<double> y;
36: vector<double> sigma_y;
37: public:
38: stan_model(stan::io::var_context& context__)
39: : prob_grad_ad::prob_grad_ad(0) {
40: static const char* function__ = "stan_model_namespace::stan_model(%1%)";
41: size_t pos__;
42: std::vector<int> vals_i__;
43: std::vector<double> vals_r__;
44: J = int(0);
45: if (!context__.contains_i("J"))
46: throw std::runtime_error("variable J not found.");
47: vals_i__ = context__.vals_i("J");
48: pos__ = 0;
49: J = vals_i__[pos__++];
50: y = std::vector<double>(J,double(0));
51: if (!context__.contains_r("y"))
52: throw std::runtime_error("variable y not found.");
53: vals_r__ = context__.vals_r("y");
54: pos__ = 0;
55: size_t y_limit_0__ = J;
56: for (size_t i_0__ = 0; i_0__ < y_limit_0__; ++i_0__) {
57: y[i_0__] = vals_r__[pos__++];
58: }
59: sigma_y = std::vector<double>(J,double(0));
60: if (!context__.contains_r("sigma_y"))
61: throw std::runtime_error("variable sigma_y not found.");
62: vals_r__ = context__.vals_r("sigma_y");
63: pos__ = 0;
64: size_t sigma_y_limit_0__ = J;
65: for (size_t i_0__ = 0; i_0__ < sigma_y_limit_0__; ++i_0__) {
66: sigma_y[i_0__] = vals_r__[pos__++];
67: }
68: // validate data
69: check_greater_or_equal(function__,J,0,"J");
70: for (int k0__ = 0; k0__ < J; ++k0__) {
71: check_greater_or_equal(function__,sigma_y[k0__],0,"sigma_y[k0__]");
72: }
73:
74: // validate transformed data
75:
76: set_param_ranges();
77: } // dump ctor
78:
79: void set_param_ranges() {
80: num_params_r__ = 0U;
81: param_ranges_i__.clear();
82: num_params_r__ += J;
83: ++num_params_r__;
84: ++num_params_r__;
85: }
86:
87: void transform_inits(const stan::io::var_context& var_context__,
88: std::vector<int>& params_i__,
89: std::vector<double>& params_r__) {
90: params_r__.clear();
91: params_i__.clear();
92: stan::io::writer<double> writer__(params_r__,params_i__);
93: size_t pos__;
94: std::vector<double> vals_r__;
95: std::vector<int> vals_i__;
96:
97:
98: if (!(var_context__.contains_r("theta")))
99: throw std::runtime_error("variable theta missing");
100: if (var_context__.dims_r("theta").size() != 1)
101: throw std::runtime_error("require 1 dimensions for variable theta");
102: vals_r__ = var_context__.vals_r("theta");
103: pos__ = 0U;
104: std::vector<double> theta(J,double(0));
105: for (int i0__ = 0U; i0__ < J; ++i0__)
106: theta[i0__] = vals_r__[pos__++];
107: for (int i0__ = 0U; i0__ < J; ++i0__)
108: writer__.scalar_unconstrain(theta[i0__]);
109:
110: if (!(var_context__.contains_r("mu")))
111: throw std::runtime_error("variable mu missing");
112: if (var_context__.dims_r("mu").size() != 0)
113: throw std::runtime_error("require 0 dimensions for variable mu");
114: vals_r__ = var_context__.vals_r("mu");
115: pos__ = 0U;
116: double mu(0);
117: mu = vals_r__[pos__++];
118: writer__.scalar_unconstrain(mu);
119:
120: if (!(var_context__.contains_r("tau")))
121: throw std::runtime_error("variable tau missing");
122: if (var_context__.dims_r("tau").size() != 0)
123: throw std::runtime_error("require 0 dimensions for variable tau");
124: vals_r__ = var_context__.vals_r("tau");
125: pos__ = 0U;
126: double tau(0);
127: tau = vals_r__[pos__++];
128: writer__.scalar_lb_unconstrain(0,tau);
129: params_r__ = writer__.data_r();
130: params_i__ = writer__.data_i();
131: }
132:
133: var log_prob(vector<var>& params_r__,
134: vector<int>& params_i__) {
135:
136: var lp__(0.0);
137: // model parameters
138: stan::io::reader<var> in__(params_r__,params_i__);
139:
140: vector<var> theta;
141: size_t dim_theta_0__ = J;
142: theta.reserve(dim_theta_0__);
143: for (size_t k_0__ = 0; k_0__ < dim_theta_0__; ++k_0__) {
144: theta.push_back(in__.scalar_constrain(lp__));
145: }
146: var mu = in__.scalar_constrain(lp__);
147: var tau = in__.scalar_lb_constrain(0,lp__);
148:
149: // transformed parameters
150:
151:
152: // validate transformed parameters
153:
154: // model body
155: lp__ += stan::prob::normal_log<true>(theta, mu, tau);
156: lp__ += stan::prob::normal_log<true>(y, theta, sigma_y);
157:
158: return lp__;
159:
160: } // log_prob()
161:
162:
163: void get_param_names(std::vector<std::string>& names__) {
164: names__.resize(0);
165: names__.push_back("theta");
166: names__.push_back("mu");
167: names__.push_back("tau");
168: }
169:
170:
171: void get_dims(std::vector<std::vector<size_t> >& dimss__) {
172: dimss__.resize(0);
173: std::vector<size_t> dims__;
174: dims__.resize(0);
175: dims__.push_back(J);
176: dimss__.push_back(dims__);
177: dims__.resize(0);
178: dimss__.push_back(dims__);
179: dims__.resize(0);
180: dimss__.push_back(dims__);
181: }
182:
183: void write_array(std::vector<double>& params_r__,
184: std::vector<int>& params_i__,
185: std::vector<double>& vars__) {
186: vars__.resize(0);
187: stan::io::reader<double> in__(params_r__,params_i__);
188: static const char* function__ = "stan_model_namespace::write_array(%1%)";
189: // read-transform, write parameters
190: vector<double> theta;
191: size_t dim_theta_0__ = J;
192: for (size_t k_0__ = 0; k_0__ < dim_theta_0__; ++k_0__) {
193: theta.push_back(in__.scalar_constrain());
194: }
195: double mu = in__.scalar_constrain();
196: double tau = in__.scalar_lb_constrain(0);
197: for (int k_0__ = 0; k_0__ < J; ++k_0__) {
198: vars__.push_back(theta[k_0__]);
199: }
200: vars__.push_back(mu);
201: vars__.push_back(tau);
202:
203: // declare and define transformed parameters
204: double lp__ = 0.0;
205:
206:
207: // validate transformed parameters
208:
209: // write transformed parameters
210:
211: // declare and define generated quantities
212:
213:
214: // validate generated quantities
215:
216: // write generated quantities
217: }
218:
219:
220: void write_csv_header(std::ostream& o__) {
221: stan::io::csv_writer writer__(o__);
222: for (int k_0__ = 1; k_0__ <= J; ++k_0__) {
223: writer__.comma();
224: o__ << "theta" << '.' << k_0__;
225: }
226: writer__.comma();
227: o__ << "mu";
228: writer__.comma();
229: o__ << "tau";
230: writer__.newline();
231: }
232:
233: void write_csv(std::vector<double>& params_r__,
234: std::vector<int>& params_i__,
235: std::ostream& o__) {
236: stan::io::reader<double> in__(params_r__,params_i__);
237: stan::io::csv_writer writer__(o__);
238: static const char* function__ = "stan_model_namespace::write_csv(%1%)";
239: // read-transform, write parameters
240: vector<double> theta;
241: size_t dim_theta_0__ = J;
242: for (size_t k_0__ = 0; k_0__ < dim_theta_0__; ++k_0__) {
243: theta.push_back(in__.scalar_constrain());
244: writer__.write(theta[k_0__]);
245: }
246: double mu = in__.scalar_constrain();
247: writer__.write(mu);
248: double tau = in__.scalar_lb_constrain(0);
249: writer__.write(tau);
250:
251: // declare, define and validate transformed parameters
252: double lp__ = 0.0;
253:
254:
255:
256: // write transformed parameters
257:
258: // declare and define generated quantities
259:
260:
261: // validate generated quantities
262:
263: // write generated quantities
264: writer__.newline();
265: }
266:
267: }; // model
268:
269: } // namespace
270:
271: /**
272: * Define Rcpp Module to expose stan_fit's functions to R.
273: */
274: RCPP_MODULE(stan_model){
275: Rcpp::class_<rstan::stan_fit<stan_model_namespace::stan_model,
276: boost::random::ecuyer1988> >("stan_model")
277: // .constructor<Rcpp::List>()
278: .constructor<SEXP>()
279: .constructor<SEXP, SEXP>()
280: .method("call_sampler",
281: &rstan::stan_fit<stan_model_namespace::stan_model, boost::random::ecuyer1988>::call_sampler)
282: .method("param_names",
283: &rstan::stan_fit<stan_model_namespace::stan_model, boost::random::ecuyer1988>::param_names)
284: .method("param_names_oi",
285: &rstan::stan_fit<stan_model_namespace::stan_model, boost::random::ecuyer1988>::param_names_oi)
286: .method("param_fnames_oi",
287: &rstan::stan_fit<stan_model_namespace::stan_model, boost::random::ecuyer1988>::param_fnames_oi)
288: .method("param_dims",
289: &rstan::stan_fit<stan_model_namespace::stan_model, boost::random::ecuyer1988>::param_dims)
290: .method("param_dims_oi",
291: &rstan::stan_fit<stan_model_namespace::stan_model, boost::random::ecuyer1988>::param_dims_oi)
292: .method("permutation",
293: &rstan::stan_fit<stan_model_namespace::stan_model, boost::random::ecuyer1988>::permutation)
294: .method("update_param_oi",
295: &rstan::stan_fit<stan_model_namespace::stan_model, boost::random::ecuyer1988>::update_param_oi)
296: .method("param_oi_tidx",
297: &rstan::stan_fit<stan_model_namespace::stan_model, boost::random::ecuyer1988>::param_oi_tidx)
298: ;
299: }
300:
301:
302: // declarations
303: extern "C" {
304: SEXP filef8ab3cb9ddf2( ) ;
305: }
306:
307: // definition
308:
309: SEXP filef8ab3cb9ddf2( ){
310: return R_NilValue;
311: }
312:
313:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! filef8ab3cb9ddf2.cpp:6:30: error: rstan/rstaninc.hpp: No such
file or directory
filef8ab3cb9ddf2.cpp:9:39: error: stan/model/model_header.hpp: No such file or directory
filef8ab3cb9ddf2.cpp:13: error: ‘std::vector’ has not been declared
filef8ab3cb9ddf2.cpp:14: error: ‘std::string’ has not been declared
filef8ab3cb9ddf2.cpp:15: error: ‘std::stringstream’ has not been declared
filef8ab3cb9ddf2.cpp:16: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:17: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:18: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:19: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:20: error: ‘std::istream’ has not been declared
filef8ab3cb9ddf2.cpp:21: error: ‘stan’ has not been declared
filef8ab3cb9ddf2.cpp:21: error: ‘math’ is not a namespace-name
filef8ab3cb9ddf2.cpp:21: error: expected namespace-name before ‘;’ token
fil
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB filef8ab3cb9ddf2.cpp 2>
filef8ab3cb9ddf2.cpp.err.txt' had status 1
>
- Bob
On 8/8/12 6:09 PM, Jiqiang Guo wrote:
> |
>