I’m struggling to do matrix-scalar multiplication in Stan. Is it not possible to scale all matrix elements by the same scalar value in stan? Is this done a different way?
data {
int K; //outcome classes
int N; //rows
int D; //input dimensions
int y[N];
matrix[N, D] X;
real days[N];
}
parameters {
matrix[D, K] C;
matrix[D, K] B;
}
model {
matrix[N, K] pred = X*C + days*X*B; // remove days and it compiles fine.
to_vector(pred) ~ normal(0, 5);
for (n in 1:N)
y[n] ~ categorical_logit(pred[n]');
}
Edit: My data looks like:
index, curr_1, curr_2, curr_3, days, end
0, 1, 0, 0, 0, 2
1, 0, 2, 0, 1, 2