Good afternoon!
I would like to get the predictions of the model but Stan tells me that something is wrong. Please, help me to understand the problem
predictions_of_bayesian_multi_logit <- "
data {
int N; // number of individuals
int<lower=2> K; // number of alternatives
int<lower=1> D; // number of individual predictors
int<lower=1> C; // number of cards for train sample
int<lower=1> C_tilde; // number of cards for test sample
matrix[K, D] X[N, C]; // individual predictors for train sample
matrix[K,D] X_tilde[N, C_tilde]; // individual predictors for test sample
int<lower=1,upper=5> y[N, C]; // outcomes
}
parameters {
vector[D] beta;
}
model {
for (d in 1:D)
beta[d] ~ normal(0, 5);
for (n in 1:N)
for (c in 1:C)
y[n, c] ~ categorical_logit(X[n, c]*beta);
}
generated quantities {
int<lower=1,upper=5> y_tilde[N, C_tilde];
for (n in 1:N)
for (c in 1:C_tilde)
y_tilde[n, c] = categorical_logit(X_tilde[n, c]*beta);
}
"
data_for_aggregate_logit <- list(N = N, y = y_train, X = X_train, X_tilde = X_test, D = D, C = C, C_tilde = C_tilde, K = K)
fit_aggregate_logit <- stan(model_code = predictions_of_bayesian_multi_logit, data = data_for_aggregate_logit, iter = 1000, chains = 4)
When I`m trying to fit the model, Stan tells me the following:
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
No matches for:
categorical_logit(vector)
Function categorical_logit not found.
ERROR at line 26
24: for (n in 1:N)
25: for (c in 1:C_tilde)
26: y_tilde[n, c] = categorical_logit(X_tilde[n, c]*beta);
^
27: }
Do you know how the given problem can be solved? Thanks in advance!