Category interaction in statsmodels

24 zobrazení
Přeskočit na první nepřečtenou zprávu

Richard Schwenke

nepřečteno,
1. 9. 2022 7:04:4901.09.22
komu: pystatsmodels
Dear statsmodels community,

I am trying to fit a model with statsmodels that estimates treatment effects for different treatment levels given in treatment_levels for different item_categories.

So basically what I am looking for is the effect of each treatment level per each single item_category

This is what I am using so far:

results = smf.ols("y ~ treatment_levels:item_category + date", data=parent_agg).fit()

Now here comes the issue: In my dataset, not all item_categories received ALL treatment_levels. So there might be some item_categories that got all treatment_levels, but some others might have only received a subset.

Due to this, statsmodels gives me a singularity warning, since it tries to estimate the treatment effect for level-category combinations which do not appear in the dataset and the coefficients are very close to zero with standard-deviation=nan.

I'd assume it should be possible to encode this in a better way to avoid this issue, but I was not able to find a good hint to it.

Any help is highly appreciated!!

Thanks a lot,
Richard

Odpovědět všem
Odpověď autorovi
Přeposlat
0 nových zpráv