What do brackets mean after a type is specified when declaring variables in Stan?

264 views Asked by At

I saw a Stan program where the data block contained int person[N_obs]. Is this creating an array of integers of size N_obs that is called with person?

1

There are 1 answers

4
LukasNeugebauer On BEST ANSWER

Yes, exactly. Brackets behind the variable names specify an array of the type that was specified before the name. In addition, for collection data types like vector and matrix, you need to specify the size behind the data type:

vector[N] y;
matrix[N, K] X;

You can also create arrays of collection data types. For example

vector[N] X[K];

would specify an array of K vectors of size N.