0
$\begingroup$

I'm new to STAN, and on the job I've been given some sample training code.

data {
  int<lower=1> N_pairs; // number of agent and callgroup pairs in data
  int<lower=1> N_agent; // number of agents
  int<lower=1> N_callgroup; // number of callgroups
  int<lower=1,upper=N_agent> agentid_ix[N_pairs]; // array with agentid
  int<lower=1,upper=N_callgroup> callgroup_ix[N_pairs]; // array with callgroup
  int<lower=0> calls[N_pairs]; // array with calls for each agent callgroup pair
  int<lower=0> outcomes[N_pairs]; // array with outcomes for each agent callgroup pair
}

Every item is defined as an integer, yet the last four line have comments detailing that it is an array assignment, despite the integer declaration. What's going on here?

Additionally, this syntax int<lower=1,upper=N_agent> agentid_ix[N_pairs]; confuses me. Specifically, I have no idea what agentid_ix[N_pairs] is telling STAN to do. Any thoughts?

$\endgroup$
1

2 Answers 2

2
$\begingroup$

A few things

  1. Its Stan, not STAN. The language is named after Stanislov Ulam

  2. int x[n] creates an array of integers (or something equivalent there to). Stan inherits typing from C++.

  3. int x<lower=1,upper=N_agent> x[n] tells stan to create an array x of dimension n. The <lower=1,upper=n> in the data block acts like a check. If you pass data x to stan which has elements smaller than 1 or larger than n then Stan will quit.

$\endgroup$
1
$\begingroup$

The int<lower=0> agentid_ix[N_pairs] is declaring an array of N_pairs integers that are greater or equal to 0.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.