How to match pystan optimizing effect?

I have a same model and same data for pystan and pyMC3. For pystan, I use optimizing function. For pyMC3, I use“advi”,obj_optimizer = pm.adagrad(learning_rate=0.01),obj_n_mc=25,n=10,random_seed=1)
trace_pars_tmp = ff.sample(1000)

The pystan’result is much better(including running time and algorithm accuracy).For pyMC3, what should I do to match pystan optimizaing effect? Thank you.

PyMC3 has a much richer VI module than Stan, so it is hard to use the exact same algorithm. The slowness and inaccuracy is due to your parameter selection in (e.g., suboptimal learning rate, too many obj_n_mc, too few iteration) - you should try with the default first:

with model:
    mean_field ='advi')