stan-dev / rstan

RStan, the R interface to Stan
https://mc-stan.org
1.02k stars 264 forks source link

Syntax error from parser when running BUGS example #1 #1037

Closed Shwoobly closed 1 year ago

Shwoobly commented 1 year ago

Summary:

After running model <- stan_demo() and selecting example 1, a syntax error appeared. I am using a Macbook M2. The 8 schools example worked just fine.

Description:

After running model <- stan_demo() and selecting example 1, a syntax error appeared.

Reproducible Steps:

  1. stan_demo()
  2. Selection: 1

If you have a reproducible example, please include it.

Current Output:

If applicable, any relevant output from RStan.

M <- 14

P <- 6

N0 <- 6

N <-

  • structure(c(64, 89, 70, 76, 73, 78, 61, 67, 63, 67, 71, 64, 64, 71),
  • .Dim = c(14))

N2 <- 100

cases <-

  • structure(c(0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 3, 2, 10, 3, 8, 7, 75, 151, 252, 160, 128, 23, 48, 57, 92, 91, 36, 104, 71, 69, 65, 131, .... [TRUNCATED]

deaths <-

  • structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 0, 2, 3, 4, 0, 11, 8, 2, 7, 11, 13, 7, 5, .... [TRUNCATED]

f <-

  • structure(c(1.02074697882139e-08, 5.10373489410695e-07, 2.3477180512892e-06, 8.30888040760612e-06, 1.9996433315111e-05, 3.69510406333343e-05 .... [TRUNCATED]

X <-

  • structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, .... [TRUNCATED]

EpidemicStart <-

  • structure(c(31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31),
  • .Dim = c(14))

pop <-

  • structure(c(5792203, 60461828, 83783945, 46754783, 67886004, 65273512, 5421242, 11589616, 9006400, 10099270, 8654618, 10423056, 10196707, .... [TRUNCATED]

SI <-

  • structure(c(0.0183261824523828, 0.0665923069549798, 0.10191389126982, 0.11771677925845, 0.118385594423979, 0.1096347062151, 0.0961232167086 .... [TRUNCATED]

SYNTAX ERROR, MESSAGE(S) FROM PARSER: error in 'model160026cc71ed0_imperial_model' at line 5, column 2

 3:   int<lower=1> P; // number of covariates
 4:   int<lower=1> N0; // number of days for which to impute infections
 5:   array[M] int<lower=1> N; // days of observed data for country m. each entry must be <= N2
     ^
 6:   int<lower=1> N2; // days of observed data + # of days to forecast

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 '}' to close variable declarations> Error in stanc(file = file, model_code = model_code, model_name = model_name, : failed to parse Stan model 'imperial_model' due to the above error.

Expected Output:

If applicable, the output you expected from RStan.

No expectation, I was trying out the demo to see what would be the output.

RStan Version:

The version of RStan you are running (e.g., from packageVersion("rstan")) 2.21.8

R Version:

The version of R you are running (e.g., from R.version.string) R version 4.2.2 (2022-10-31)

Operating System:

Your operating system (e.g., OS X 10.11.3) macOS Ventura 13.1

bob-carpenter commented 1 year ago

The problem here is that the RStan available on CRAN is not up to date with our new array syntax (and I doubt it ever will be given CRAN's policies that require multiple small packages without giving you a way to manage dependencies).

I would recommend checking out the cmdstanr interface, which keeps up to date with Stan: https://mc-stan.org/cmdstanr/

If you'd like to continue using RStan, I'd suggest updating to the latest version from GitHub: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

But even the latest RStan is about 1.5 years behind Stan development (we've marked when functions were introduced in the functions reference manual).