You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
To my understanding, plot_hdi() does not currently support categorical x values (see code below), but this isn't explicitly noted in the documentation nor is there a ValueError or TypeError raised. Further, the functions default of smooth=True throws it's own error when a user passes a categorical x.
# Fit a Bayesian ANOVA model using Bambimodel=bmb.Model('y ~ group', data)
idata=model.fit()
preds=model.predict(idata, kind="response_params", inplace=False)
y_mu=az.extract(preds["posterior"])["mu"].valuesgroup=data.loc[:, "group"].valuesaz.plot_hdi(x=group, y=y_mu.T)
Returns:
#UFuncTypeError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U1'), dtype('float64')) -> None
The traceback points to np.linspace under the if smooth: block:
Thanks @milesalanmoore I was able to reproduce everything you gave above, and I thank you greatly for the effort given to the minimum reproducible example.
It looks like you were expecting categorical data to plot similarly to how bambi plots HDI values for categories. What I find interesting is that the ArviZ version is actually returning the same data, but it is connecting all the points together into lines. You can see this by overlaying the bambi plot with the ArviZ one.
I think a better error message at this time would be a NotImplementedError with a message saying plot_hdi does not plot categorical values.
On another note, it looks to me like you are wanting a forest plot. To do that using ArviZ, I would do the following.
Hello arviz-devs! Thanks for a wonderful package. This issue comes from a discussion on the PyMC discourse including @tomicapretto and I.
Describe the bug
To my understanding, plot_hdi() does not currently support categorical x values (see code below), but this isn't explicitly noted in the documentation nor is there a ValueError or TypeError raised. Further, the functions default of
smooth=True
throws it's own error when a user passes a categorical x.To Reproduce
Returns:
The traceback points to
np.linspace
under theif smooth:
block:arviz/arviz/plots/hdiplot.py
Lines 171 to 182 in 0fc1117
Setting smooth to False does not return an expected plot:
Expected behavior
Given the documentation, I'd expect the behavior to mirror the output from
bambi.interpret
Additional context
arviz 0.20.0 via conda-forge
Python 3.12.0
I think a TypeError informing the user of the lack of support for categorical (str) types would be very helpful to future users.
The text was updated successfully, but these errors were encountered: