Not sure what error message means.

829 views
Skip to first unread message

Spencer Maynes

unread,
Nov 28, 2012, 3:11:10 PM11/28/12
to stan-...@googlegroups.com
This is the first Stan model I've ever written, so I apologize for having a model that probably has errors in it beyond the one that the parser found, and also for not using enough vectorization. I really just want to know what "Parser expecting: <list><expression>","" means though. I think that it means that I'm missing a comma somewhere in my code, perhaps something along the lines of foo[i] when I define foo as matrix[i,j] foo; but after more than an hour of searching I can't find anything of the sort.

TRANSLATING MODEL 'cowtemp_code' FROM Stan CODE TO C++ CODE NOW.
Error in stanc(file = file, model_code = model_code, model_name = model_name,  : 
  failed to parse Stan model 'cowtemp_code' with error message:
PARSE DID NOT SUCCEED.
ERROR: non-whitespace beyond end of program:
LOCATION: file=input; line=1, column=1

 ^-- starting here

DIAGNOSTICS FROM PARSER:

Parser expecting: <list><expression>","
firstmodel.txt

Jiqiang Guo

unread,
Nov 28, 2012, 3:49:24 PM11/28/12
to stan-...@googlegroups.com
We need to wait for 1.04 to have an more informative error message for parsing stan code.  Actually, the problem is at 

$ stanc test.stan
Model name=test_model
Input file=test.stan
Output file=test_model.cpp

INVALID COMMAND-LINE ARGUMENT
EXPECTATION FAILURE LOCATION: file=test.stan; line=47, column=10

hourpred[,k] <- cowmean[k]+aemean[,k];
         ^-- here


DIAGNOSTIC(S) FROM PARSER:
Parser expecting: <list><expression>","

Currently, Stan does not support referring to a column of a matrix as in R.  So you need something like the following (someone correct me if there is a better way now):

for (i in 1:(Nhour-order))
  hourpred[i,k] <- cowmean[k]+aemean[i,k];


--
Jiqiang 


--
 
 

Bob Carpenter

unread,
Nov 28, 2012, 3:52:31 PM11/28/12
to stan-...@googlegroups.com



On 11/28/12 3:11 PM, Spencer Maynes wrote:
> This is the first Stan model I've ever written,

That's an awfully ambitious first program to write
in any system.

I'd strongly recommend working up to bigger models
a little piece at a time (fewer predictors,
less hierarchical structure, etc.). Then when something
goes wrong, you'll have a more limited set of things
it might be.

> so I apologize for having a model that probably has errors in it beyond
> the one that the parser found, and also for not using enough vectorization. I really just want to know what "Parser
> expecting: <list><expression>","" means though. I think that it means that I'm missing a comma somewhere in my code,
> perhaps something along the lines of foo[i] when I define foo as matrix[i,j] foo; but after more than an hour of
> searching I can't find anything of the sort.

Sorry about that. Our 1.0.3 release broke the
localization of error messages, which is why it's saying
line=1, column=1. The 1.0.4 release which should be
out very soon puts them back.

The "expecting" message indeed means it's expecting
a list of expressions. Here's what the error message looks
like in 1.0.4:

--------------------
~/stan>bin/stanc /Users/carp/temp2/firstmodel.stan
Model name=firstmodel_model
Input file=/Users/carp/temp2/firstmodel.stan
Output file=firstmodel_model.cpp

INVALID COMMAND-LINE ARGUMENT
EXPECTATION FAILURE LOCATION: file=/Users/carp/temp2/firstmodel.stan; line=47, column=10

hourpred[,k] <- cowmean[k]+aemean[,k];
^-- here


DIAGNOSTIC(S) FROM PARSER:
Parser expecting: <list><expression>","
------------------

The issue is that Stan doesn't support partial array/vector/matrix
notation, so you can't do what you're trying to do.

If you have an M x N matrix x, then x[m] is a N-row-vector.
and for an M x N array y, y[m] is an N-array.

- Bob

Spencer Maynes

unread,
Nov 29, 2012, 12:45:06 AM11/29/12
to stan-...@googlegroups.com
Thanks for helping me out so quickly. After I fixed the problem that you guys found the solution for it turned out the model would make R quit whenever I ran it, so I ended up having to completely change most of the model to make it a lot simpler. It finally works, and it's actually really quick for an MCMC model with over 2000 observations. I think it'll only take 30 minutes to do 10000 iterations on 4 chains (1.2 seconds for 10 iterations). Thanks for Stan!

Bob Carpenter

unread,
Nov 29, 2012, 1:08:25 AM11/29/12
to stan-...@googlegroups.com


On 11/29/12 12:45 AM, Spencer Maynes wrote:
> Thanks for helping me out so quickly. After I fixed the problem that you guys found the solution for it turned out the
> model would make R quit whenever I ran it, so I ended up having to completely change most of the model to make it a lot
> simpler. It finally works, and it's actually really quick for an MCMC model with over 2000 observations. I think it'll
> only take 30 minutes to do 10000 iterations on 4 chains (1.2 seconds for 10 iterations). Thanks for Stan!

I'm glad it's working for you. But keep in mind it's
not the number of iterations that matter, it's how many
effective samples they produce.

Stan 1.0.3 can crash R due to index out of bounds
errors in the C++. That should be fixed for 1.0.4
with warning messages.

Stan can also crash R by exhausting memory, but that's
unlikely to happen right out of the gate with the
fairly small data set you have.

So you might want to try ramping the model complexity
back up a bit. I think most of the uncaught errors
were during data ingestion.

The time per iteration is dominated by the gradient calcs,
and we're making those faster all the time.
Daniel's added a whole bunch of vectorized probabilty
function code for 1.0.4 and over the next few months,
we'll have them all properly vectorized, including
multivariates. And we're going to tackle the matrix
ops, too -- right now the gradients are being done
very inefficiently by auto-dif and in many cases, we
have analytic solutions we can plug in to make things
much faster.

- Bob

>
> On Wednesday, November 28, 2012 2:11:10 PM UTC-6, Spencer Maynes wrote:
>
> This is the first Stan model I've ever written, so I apologize for having a model that probably has errors in it
> beyond the one that the parser found, and also for not using enough vectorization. I really just want to know what
> "Parser expecting: <list><expression>","" means though. I think that it means that I'm missing a comma somewhere in
> my code, perhaps something along the lines of foo[i] when I define foo as matrix[i,j] foo; but after more than an
> hour of searching I can't find anything of the sort.
>
> TRANSLATING MODEL 'cowtemp_code' FROM Stan CODE TO C++ CODE NOW.
> Error in stanc(file = file, model_code = model_code, model_name = model_name, :
> failed to parse Stan model 'cowtemp_code' with error message:
> PARSE DID NOT SUCCEED.
> ERROR: non-whitespace beyond end of program:
> LOCATION: file=input; line=1, column=1
>
> ^-- starting here
>
> DIAGNOSTICS FROM PARSER:
>
> Parser expecting: <list><expression>","
>
> --
>
>
Reply all
Reply to author
Forward
0 new messages