I’m trying to create a simple sequence in Stan that would be done in R with a colon for something like 1:10. When I try the following code:
model {
int Wgts[200];
Wgts = 1:200;
}
I get a dimension mismatch error. Is there a way to create this sequence in Stan? I’ve found the colon to be useful for indexing in Stan but perhaps it can’t be used for this purpose.
I might be wrong, but I don’t think that has been added to the language yet. For now you can do something like
int x[200];
for (i in 1:200) x[i] = i;
Also, if you’re not going to use them as indexes you can just make a vector or array of reals.
@Bob_Carpenter do you know if there are plans to add this or improve the error message? Right now the error message looks like this:
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
Variable definition base type mismatch,
variable declared as base type int[ ] variable definition has base type int
Variable definition dimensions mismatch,
definition specifies 1, declaration specifies 0