Is one-hot encoding required for a binary categorical variable? We are performing multiple linear regression.
Dataset:

*

*let's call the response Y and the predictors X1, X2 and X3,

*where Y, X1, X2 are continuous, whereas X3 is binary categorical variable (i.e. it can take either two values, 1 or 2).

Now, we have two choices

*

*Choice #1: Without one-hot encoding of X3

*

*i.e. Linear regression on raw variables lm(Y ~ X1 + X2 + X3)



*Choice #2: With one-hot encoding of X3

*

*i.e. X3 is one-hot encoding in [X3a, X3b]

*e.g. Possible values: [1, 0] and [0, 1]

*Hence, the linear regression model is lm(Y ~ X1 + X2 + X3a + X3b)
Question:
Since X3 is a binary variable, whether or not we one-hot encode (i.e. Choice#1 or Choice#2), will it make any difference (especially in terms of the model's loss)?

There's a better approach than both. With dummy coding, you would end up with a simpler model that is easier to interpret.
In the first case, you are forcing $\beta_3 X_3$ to be twice higher (or lower) for group coded 2 vs 1. To adapt to a specific difference between groups, the parameter, and intercept need to adapt. It's much easier to interpret the parameters using 0 and 1 codes, so $\beta_3 \times 1$ (vs $0$) serves as an additional intercept for the group coded as 1.
In the second case $X_{3a}$ and $X_{3b}$ are colinear and cannot be used. What you need to do is to encode the categories as 0 and 1, so you encode the presence of one category that has an additive effect $\beta_3 X_3 = \beta_3 1 = \beta_3$.
