Hi!
Let’s say I want to create a simple binomial model per x
:
import pandas as pd
import bambi as bmb
df_simple = pd.DataFrame({
'x': ['A', 'B', 'C'],
'y': [10, 20, 30],
'n': [100, 100, 100]
})
m = bmb.Model('p(y, n) ~ x', data=df_simple, family='binomial')
idata = m.fit()
m.predict(idata)
I want to have a point estimate (median, can also be mean) for probability of success per x. What’s the best way (fastest / recommended) way to achieve this? I tried with
idata.posterior['p(y, n)_mean'].mean(dim='p(y, n)_obs')
But get mean per chain and x? Can you also show me what’s the best way to add this as column back to the original dataframe df_simple
? Thanks!