# Endogeneity problem with a dummy variable

I have a panel data model as following, $$Y_{it}=intercept +B_1X_{it}+B_2Q_{it}+error_{it}$$

where $$i$$ is for firm and $$t$$= time.

$$Y$$= trade credit demand, $$X$$= inventory cycle, as inventory moves faster firms demand more trade credit. On the other hand because trade credit means extra inventory, the cycle would be affected by it, too.

I know that the model suffers from endogeneity because $$Y$$ affects $$X$$ and in return $$X$$ affects $$Y$$. Would it be a valid procedure if I tried to work around this issue by assigning a dummy variable and not use $$X$$ in the analysis at all by calculating first yearly average for the cycle and assign 1 if a firm is above the average for that year and 0 if below it. Maybe the code I am using may clarify any vagueness.

in the R code below.

mydata=mydata%>%group_by(year)%>%mutate(mean_x=mean(x))
mydata=mydata%>%mutate(Dummy=case_when(X>=mean_x~1, TRUE~0))


and the model becomes as following:

$$Y_{it}=intercept+B_1 Dummy+B_2 Q_{it}+error_{it}$$

I hope I am clear enough. thanks in advance!