Why does mean-centering in a univariate logistic regression change p-values? I have a very simple logistic model with a single continuous independent variable and a two-category dependent variable. When I mean-center the IV, the p-value of the coefficient changes significantly, and I'm not sure why.
Example code snippet that reproduces the effect:
import statsmodels.api as sm
import numpy as np
x = [5, 5, 6, 6, 5, 6]
y = [1, 1, 1, 1, 2, 2]
xc = x - np.mean(x)
lr1 = sm.MNLogit(y, x)
model = lr1.fit()
lr2 = sm.MNLogit(y, xc)
model2 = lr2.fit()
print(model.pvalues)
print(model2.pvalues)

0.423
1.

Shouldn't the significance level of the coefficient not depend on the predictor variable's scale? All I can find from other threads is that centering will change the significance of interaction effects, but that's not applicable here.
I'm also wondering which of the two results I should ultimately use to determine if there is a significant relationship between the two variables. Intuitively, the model with centered input seems "more" correct, given that in this data set there is no relationship at all.

The statsmodels package does not include an intercept. When you include an intercept, only the intercept p-value changes (which makes sense for centering the feature).
import numpy as np
import statsmodels.api as sm
x = [5, 5, 6, 6, 5, 6]
y = [1, 1, 1, 1, 2, 2]
xc = x - np.mean(x)
lr3 = sm.MNLogit(y, sm.tools.add_constant(x))
model3 = lr3.fit()
lr4 = sm.MNLogit(y, sm.tools.add_constant(xc))
model4 = lr4.fit()
print(model3.pvalues)
print(model4.pvalues)

This happens in an OLS linear regression, too, and the visualization is easier.
x <- c(1, 2, 3, 4, 5, 6)
xc <- x - mean(x)
y <- c(1, 2, 5, 6, 8, 155)
L1 <- lm(y ~ 0 + x)
L2 <- lm(y ~ x)
L3 <- lm(y ~ 0 + xc)
L4 <- lm(y ~ xc)

par(mfrow = c(1, 2))
plot(x, y)
abline(a = 0, b = summary(L1)$coef[1], col = 'red')
abline(a = summary(L2)$coef[1], b = summary(L2)$coef[2])
plot(xc, y)
abline(a = 0, b = summary(L3)$coef[1], col = 'red')
abline(a = summary(L4)$coef[1], b = summary(L4)$coef[2])
par(mfrow = c(1, 1))


Black represents the regression models with intercepts; red represents the models without intercepts.
When there is an intercept in the model, all the centering does is shift the data to the left or right, but the slope does not change (notice how the black lines are parallel). However, when there is no intercept, the line has to fit the data as best it can while also having a particular y-intercept (zero), resulting in the line twisting and changing the slope (notice how the red lines are not parallel).
