tlamadon / pytwoway

Two way models in python
MIT License
24 stars 7 forks source link

AKM: controls should use columns directly #31

Open adamoppenheimer opened 2 years ago

adamoppenheimer commented 2 years ago

AKM with controls should use column names directly, rather than using general column names and requiring that they have only 1 subcolumn.

This way people can more easily specify controls like time variables but for only certain periods, etc.

lizhangecon commented 1 year ago

Regarding this issue, I wonder how to add controls like year effect by gender

adamoppenheimer commented 1 year ago

In order to help others with the same question in the future, it would be great if you could please open your question as a new issue. I will paste the following as my response to the new issue as well:

If you are using year effects as a categorical control, then you can simply construct a new column manually. As an example, if you have the columns t for years (since bipartitepandas does not treat the time column as categorical, you will have to construct a new column that is categorical in order for this to work properly) and gender for genders, and have n_years and n_genders (=2), then you can construct the interacted column as n_genders t + gender, or alternatively as n_years gender + t.

On the other hand, if you want year effects as a continuous variable, unfortunately that is not yet feasible. I already have this issue open about it.

Please let me know if this answers your question, and please feel free to ask any other questions you may have!

lizhangecon commented 1 year ago

In order to help others with the same question in the future, it would be great if you could please open your question as a new issue. I will paste the following as my response to the new issue as well:

If you are using year effects as a categorical control, then you can simply construct a new column manually. As an example, if you have the columns t for years (since bipartitepandas does not treat the time column as categorical, you will have to construct a new column that is categorical in order for this to work properly) and gender for genders, and have n_years and n_genders (=2), then you can construct the interacted column as n_genders t + gender, or alternatively as n_years gender + t.

On the other hand, if you want year effects as a continuous variable, unfortunately that is not yet feasible. I already have this issue open about it.

Please let me know if this answers your question, and please feel free to ask any other questions you may have!

Thanks for your help. However, when I try to add the categorical controls as stated, the following issue occurs:

ValueError('column index exceeds matrix dimensions')

Do you have any idea? I've opened a new issue about this problem, so you can reply there. Thanks