I do not know Python, but as you can readily illustrate in R
, setting the value of the intercept to 1 is really just a convention (a useful one, though, of course, allowing us to interpret the intercept as the expected effect when $x=0$).
n <- 10
y <- rnorm(n) # some random data
x <- rnorm(n)
intercept <- rep(1,n) # a "hand-made" intercept
lm(y~x) # the default in R which includes an intercept
lm(y~intercept+x-1) # removing the default intercept with -1 and re-adding it manually as another regressor
lm(y~I(2*intercept)+x-1) # removing the default intercept with -1 and re-adding 2 as a constant term
Output:
> lm(y~x)
Call:
lm(formula = y ~ x)
Coefficients:
(Intercept) x
-0.07813 0.55086
> lm(y~intercept+x-1)
Call:
lm(formula = y ~ intercept + x - 1)
Coefficients:
intercept x
-0.07813 0.55086
> lm(y~I(2*intercept)+x-1)
Call:
lm(formula = y ~ I(2 * intercept) + x - 1)
Coefficients:
I(2 * intercept) x
-0.03907 0.55086
As you can see, the first two regressions are exactly the same (as fully expected), and the third has the same coefficient on x
, and exactly half the coefficient on the constant term, to account for the effect that we have multiplied that by two.