Hi everyone. I want to apply the ADVI in some Bayesian Logistic Regression models. I am facing some problems in my Second Model (see below) which includes some hyper-priors.
Fisrt Model:
{y_i} \sim Bernoulli(\frac{e^{x_i \boldsymbol{\beta}}}{1+e^{x_i \boldsymbol{\beta}}}), i \in \{1,\dots,n\}, n \in \mathbb{N}, \boldsymbol{\beta} \sim \mathcal{N}(\boldsymbol{\mu},\boldsymbol{\Sigma}), \boldsymbol{\beta}\in \mathbb{R}^p,
where \boldsymbol{\mu} and \boldsymbol{\Sigma} are given. So, the model in stan file is
data {
int<lower=0> n; // number of observations
int<lower=0> p; // number of parameters
array[n] int<lower=0, upper=1> y; // binary outcome variable
matrix[n, p] X; // matrix of predictor variables
vector[p] mu; // prior mu vector
matrix[p, p] Sigma; // prior Sigma arrray
}
parameters {
vector[p] beta; // coefficients for each predictor variable
}
model {
beta ~ multi_normal(mu, Sigma); // beta prior
y ~ bernoulli_logit(X * beta); // likelihood
}
Second Model: {y_i} \sim Bernoulli(\frac{e^{x_i \boldsymbol{\beta}}}{1+e^{x_i \boldsymbol{\beta}}}), i \in \{1,\dots,n\}, n \in \mathbb{N},
\boldsymbol{\beta} \sim \mathcal{N}(\boldsymbol{\mu},\boldsymbol{\Sigma}), \boldsymbol{\beta}\in \mathbb{R}^p, where \boldsymbol{\mu} is given and \boldsymbol{\Sigma} =A^{-1} where A=diag(\alpha_j), \alpha_j \sim Gamma(a_0,b_0), j \in \{1,\dots,p\}. So, the model in stan file is
data {
int<lower=0> n; // number of observations
int<lower=0> p; // number of parameters
array[n] int<lower=0, upper=1> y; // binary outcome variable
matrix[n, p] X; // matrix of predictor variables
vector[p] mu; // prior mu vector
real<lower=0> a0; // shape of(hyper)prior
real<lower=0> b0; // rate of(hyper)prior
}
parameters {
vector[p] beta; // coefficients for each predictor variable
vector[p] diag_array; // diagonal array parameter
}
transformed parameters {
matrix[p, p] Sigma;
Sigma = inverse(diag_matrix(diag_array)); // convert diag_array to diagonal matrix
}
model {
for (j in 1:p) {
diag_array[j] ~ gamma(a0, b0);
}
beta ~ multi_normal(mu, Sigma); // beta prior
y ~ bernoulli_logit(X * beta); // likelihood
}
Unfortunately, I receive this error Chain 1 stan::variational::advi::calc_ELBO: The number of dropped evaluations has reached its maximum amount (100). Your model may be either severely ill-conditioned or misspecified. Probably my model is not properly defined.
Do you have any idea how to define my Second Model? I am new in stan and don’t have much experience.
Thank you in advance!