Stan Runtime Error Line Number

Simple question, but I can’t seem to find an answer on my own. I get a runtime error like this:

Chain 1: Exception: assign: Rows of left-hand-side (25) and rows of right-hand-side (19) must match in size (in ‘model22b17ee56514_892f6d2e227201e78655369fc13998ab’ at line 98)

How do I identify line 98 in my Stan code, which is defined as a character string in the R code?

version R version 4.0.3 (2020-10-10)
os Linux Mint 20
system x86_64, linux-gnu
ui RStudio
language en_US
RStan Version 2.21.2

Count from the top. Or save the Stan code as an external file so that you can open it in virtually any editor that either shows the line numbers or can jump to a specified line.

@bgoodri

I am relatively new to using Stan and thus am figuring things out. I program my models in a .stan file. I have noticed that the line numbers suggested in the error message do not match with the ones that I have in my file. I have also noticed that the line numbers match if I remove the comments entirely. So I am guessing stan or my compiler has some hidden code or setting that is disregarding the commented sections of the code.

My questions –

  1. Is there a way to make the compiler consider comments in the stan file as place holder to as to report the lines with better accuracy?

  2. Is there a way to generate a more verbose error message so as to generate some contextual definition of the location of the error just in case number 1 is not possible?

Any help will be appreciated.

Thank you in advance.