How to increase the number of dropped evaluations variational bayes cmdstanr?

Kind regards.

I am running a model using variational Bayes. I am able to run the model using a subsample of the data of 10K observations, but when I try with the full dataset of 500K observations I get the following error

fit_1 <- stan_model$variational(data = stan_data,  seed = 2552,  algorithm="meanfield")
Gradient evaluation took 0.444722 seconds
1000 transitions using 10 leapfrog steps per transition would take 4447.22 seconds.
Adjust your expectations accordingly!


Begin eta adaptation.
Iteration:   1 / 250 [  0%]  (Adaptation)
Iteration:  50 / 250 [ 20%]  (Adaptation)
Iteration: 100 / 250 [ 40%]  (Adaptation)
Iteration: 150 / 250 [ 60%]  (Adaptation)
Iteration: 200 / 250 [ 80%]  (Adaptation)
Success! Found best value [eta = 1] earlier than expected.

Begin stochastic gradient ascent.
  iter             ELBO   delta_ELBO_mean   delta_ELBO_med   notes 
   100     -3055253.022             1.000            1.000
   200     -2470920.159             0.618            1.000
   300     -1904450.061             0.511            0.297
   400     -1800385.422             0.398            0.297
   500     -1710310.475             0.329            0.236
   600     -1636503.457             0.282            0.236
   700     -1678077.168             0.245            0.058
   800     -1677583.595             0.214            0.058
stan::variational::normal_meanfield::calc_grad: The number of dropped evaluations has reached its maximum amount (10). Your model may be either severely ill-conditioned or misspecified.
  • Operating System: Linux
  • CmdStan Version: 2.34.1
  • Compiler/Toolkit: gcc (GCC) 13.2.1 20230801

Can you try with Pathfinder? See Run Stan's Pathfinder Variational Inference Algorithm — model-method-pathfinder • cmdstanr. It’s faster and more stable than the current ADVI implementation used by $variational()

Hi, Thanks for your answer, I was able to solve the problem by reparametrizing my model.

If anyone is fitting a binary model with classification error, this may be useful:

y ~ bernoulli(FPR +  ((1-FPR-FNR) * inv_logit(X * B))  );

Where,
FNR: is the false negative rate
FPR: is the false positive rate