Getting multivariate Gaussian prior working in a bayesian logistic regression model

Hi all!

I have a Bayesian Logistic Regression Model that runs with univariate Gaussian priors on each element of the parameter vector \beta.

data {
  int<lower = 1> N;
  int K;
  matrix[N,K] x;
  int<lower = 0, upper = 1> y[N];
}
parameters {
  vector[K] beta;
}
model {
  y ~ bernoulli_logit(x*beta);
  beta ~ normal(0, 3);
}

However, I am having difficult converting the prior over the parameter vector \beta to a multivariate Gaussian with a specified mean and covariance matrix.

Here is what I have so far (but it does not work)

data {
  int<lower = 0> N;
  int K;
  matrix[N,K] x;
  int<lower = 0, upper = 1> y[N];
  vector[K] prior_mean;
  matrix[K,K] prior_cov;
}
parameters {
  vector[K] beta;
}
model {
  y ~ bernoulli_logit(x*beta);
  beta ~ multi_normal(prior_mean, prior_cov);
}

Thanks so much in advance!

I think you will need to provide more detail, what about it doesn’t work? Also, welcome to the stan forums :)

Thanks!

It seems to compile, but as soon as I try to fit with MCMC or optimize with “optimizing”, my RStudio session crashes…

After some more tinkering, “multi_normal” works for beta vectors of length 7 or smaller (with corresponding 7x7 prior covariance matrices “prior_cov”), but breaks down when beta vectors have length 8 or greater (with corresponding “prior_cov”).