Closed caibengbu closed 2 years ago
Just looking at the formula, there is no way to know that one time category will have to be dropped (since treatment does not appear in the formula). Therefore, it is a problem of collinearity — I think that, in this case, it's fine to drop coefficients randomly.
Maybe this gives something closer to what you want:
res = reg(df, @formula(outcome ~ time&treatment + treatment + fe(id) + fe(time)); contrasts = Dict(:time => DummyCoding(base=0)))
Great! The solution works well.
I think this is an issue about how categorical variables are dealt with in formulas in general (just learned from here that the automatic promotion is actually designed that way), instead of an issue of FixedEffectModels.jl. My initial point was that the decision of promotion to FullDummyCoding would be useful to be left to users.
Thank you for your reply.
Can I close this?
Sure! Thank you again for the advice.
Hello all,
I found DummyCoding very useful in practices, but when used in an interaction term, DummyCoding is automatically converted to FullDummyCoding.
Here is a minimal example:
The result returned is
while
time: 0 & treatment
should be dropped.PS: I found a quick fix to this issue, which is to rewrite line 308 as
StatsModels.collect_matrix_terms(apply_schema(t.rhs, schema.schema, StatisticalModel)))
.https://github.com/FixedEffects/FixedEffectModels.jl/blob/4c1ff7ff9ca9ceba10973476866b1e652d2f0cd2/src/FixedEffectModel.jl#L302-L309
But I am not sure if this will introduce other errors/inconveniences.