I have some data, which looks like:
curr_A, curr_B, curr_C, curr_D, curr_E, days, end_1, end_2, end_3
1, 0, 0, 0, 0, 1, 0.3, 0.7, 0.0
1, 0, 0, 0, 0, 2, 0.2, 0.6, 0.2
My input variables are curr_A...curr_E
and days
. While my output variables are curr_1...curr_3
(note that they sum to 1, so you can think of them as a given row’s affiliation w/ each of the three outputs.) The goal is to use a Dirichlet a distribution to model my outputs.
Currently, an error is being thrown regarding pred~dirichlet(Y[n]);
: Real return type required for probability function. Could anyone explain where I’m going wrong?
Additionally, is a simplex required for what I’m trying to do?
Edit: Stan also takes issue with softmax usage. No idea why.
data {
int K; //outcome classes, 3
int N; //num rows
int D; //input dimensions, 5
row_vector[K] Y[N]; //array of row vectors, each with k elements
matrix[N,D] X;
int days[N];
}
parameters {
matrix[D, K] C; //[5,3]
matrix[D, K] B; //[5,3]
}
model {
for (n in 1:N){
row_vector[K] pred; // [1,3]
row_vector[D] ipt; // [1,5]
ipt = X[n];
// [1,5]*[5,3] + [1,5]*[5,3] => [1,3]
pred = ipt * C + (ipt * days[n]) * B;
pred = softmax(pred);
pred~dirichlet(Y[n]); //
}
}