Category interaction in statsmodels

Skip to first unread message

Richard Schwenke

Sep 1, 2022, 7:04:49 AM9/1/22
to 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,

Reply all
Reply to author
0 new messages