a is {0, 1} binary variable, X dimension is 3 (first column is all-ones vector, the number of predictor is 2)
If write the expression differently, it becomes like this
y = Xb0 + aX(b1-b0) + e
= b00 + b01X1 + b02X2 + (b10-b00)a + (b11-b01)aX1 + (b12-b02)aX2 + e
What I interest is interaction between a and x so I want to know all the values for beta. \
How to code this using python??
- I made newX = (1, X1, X2, a, aX1, aX2) and using this,
model = ols(formula='Y~X1+X2+a+aX1+aX2', data=data).fit()
but I think this would be inefficient if the input dimension grew.
- I searched and found out 'weights' options in R,
lm(y~x1+x2, weights=(I=a))
Should I find something similar in Python and use it?
Which way is right?? If there is another way, please let me know.