vincentarelbundock / pymarginaleffects

GNU General Public License v3.0
47 stars 8 forks source link

Potential bug #84

Open vincentarelbundock opened 5 months ago

vincentarelbundock commented 5 months ago

newdata = "median" causes problems with both hp and gear if they are not casted with mtcars = mtcars.cast({"gear" : pl.Utf8, "hp" : pl.Float64}). the problem with hp is that it's type is detected as integer by datagrid. Note that the problem occurs with datagrid(model=mod, FUN_numeric=lambda x: x.median()) but not with datagrid(newdata=mtcars, FUN_numeric=lambda x: x.median()). I would have liked to specify that gear is categorical in the formula with smf.ols("mpg ~ hp + C(gear)", data = mtcars.to_pandas()).fit() but this also causes problems with datagrid. I think because it gets its columns from the original data and not from the formula.