Skip to content

Instantly share code, notes, and snippets.

@ericnovik
Created November 30, 2018 20:44
Show Gist options
  • Save ericnovik/90e1c2377743135827d50e3313ae8968 to your computer and use it in GitHub Desktop.
Save ericnovik/90e1c2377743135827d50e3313ae8968 to your computer and use it in GitHub Desktop.
data {
int<lower=2> K; // number of categories
int<lower=0> N; // number of observations
int<lower=1> D; // number of predictors
int<lower=1, upper=K> y[N];
matrix[N, D] x;
}
parameters {
vector[D] beta;
ordered[K-1] c; // cutpoints
}
model {
beta ~ normal(0, 1);
c ~ normal(0, 5);
y ~ ordered_logistic(x * beta, c);
}
generated quantities {
vector[N] y_rep;
for(n in 1:N) {
y_rep[n] = ordered_logistic_rng(x[n, ] * beta, c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment