In my example I have subject ids directly coded : Show how to fit a random effects models with negative binomial · GitHub
This would require a small update to the input to the stan model highlighted in the above tutorial via
dat = {
'N' : X.shape[0],
'D' : table.shape[0],
'p' : X.shape[1],
'depth' : np.log(table.sum(axis='sample').values),
'x' : X.values,
'y' : table.values.astype(np.int64)
'subj_ids' : <something goes here>
}
where subj_ids is some numeric conversion of your actual host subject ids.
There are also quite a bit of documentation on stan that I recommend checking out : Stan User’s Guide.
Also stan has its own channel ; for instance this page highlights an example fitting mixed effects models : Linear mixed effects model with varying intercept and slope in matrix notation - #3 by Wade - Modeling - The Stan Forums