pkremp/polls

Stan error

Closed this issue · 2 comments

WDee commented

I am very interested in this approach and this code. I am trying to run the code - but got the following error linked to STAN. Any advice on how to resolve this? Many thanks in advance, W

SYNTAX ERROR, MESSAGE(S) FROM PARSER:

Illegal statement beginning with non-void expression parsed as
chol_sigma_walk_b_forecast
Not a legal assignment, sampling, or function statement. Note that

  • Assignment statements only allow variables (with optional indexes) on the left;
    if you see an outer function logical_lt (<) with negated (-) second argument,
    it indicates an assignment statement A <- B with illegal left
    side A parsed as expression (A < (-B)).
  • Sampling statements allow arbitrary value-denoting expressions on the left.
  • Functions used as statements must be declared to have void returns

Illegal statement beginning with non-void expression parsed as
chol_sigma_walk_b_forecast
Not a legal assignment, sampling, or function statement. Note that

  • Assignment statements only allow variables (with optional indexes) on the left;
    if you see an outer function logical_lt (<) with negated (-) second argument,
    it indicates an assignment statement A <- B with illegal left
    side A parsed as expression (A < (-B)).
  • Sampling statements allow arbitrary value-denoting expressions on the left.
  • Functions used as statements must be declared to have void returns

ERROR at line 35

33: vector [S-1] zero_vec;
34: // Cholesky decompositions to speed up sampling from multivariate normal.
35: chol_sigma_walk_b_forecast = cholesky_decompose(sigma_walk_b_forecast);
^
36: chol_sigma_mu_b_end = cholesky_decompose(sigma_mu_b_end);

PARSER EXPECTED: <one of the following:
a variable declaration, beginning with type
(int, real, vector, row_vector, matrix, unit_vector,
simplex, ordered, positive_ordered,
corr_matrix, cov_matrix,
cholesky_corr, cholesky_cov
or a
or '}' to close variable declarations and definitions>
Error in stanc(file = file, model_code = model_code, model_name = model_name, :
failed to parse Stan model 'state and national polls' due to the above error.

I'm not sure. Have you tried the latest version? (pushed 2 days ago or so). That's the version I have on my local machine; and it should work (I think!).

+1 for trying the latest version. its working for me with the versions of R/rstan described below:

 rstan        * 2.12.1  2016-09-12 CRAN (R 3.3.1)
 scales         0.4.0   2016-02-26 CRAN (R 3.3.1)
 shiny        * 0.14.2  2016-11-01 CRAN (R 3.3.1)
 shinyjs        0.8     2016-11-03 CRAN (R 3.3.1)
 shinystan    * 2.2.1   2016-08-31 CRAN (R 3.3.1)
 shinythemes    1.1.1   2016-10-12 CRAN (R 3.3.1)
 StanHeaders  * 2.12.0  2016-09-12 CRAN (R 3.3.1)