QCSunny Lab

Logistic Regression (Logit · Probit)逻辑回归(Logit · Probit)

The LAST column is the binary response (0/1); earlier columns are regressors. An intercept is added automatically.最后一列为二分类因变量(0/1),前面各列为自变量,自动添加截距。

Binary outcomes break least squares (predictions outside [0, 1], heteroskedastic errors by construction). Logit and Probit model the probability through a link function and are fitted by iteratively reweighted least squares — Newton's method on the likelihood, which is why it converges in a handful of steps.

Reported alongside the coefficients: the likelihood-ratio test against an intercept-only model, AIC/BIC, and marginal effects — the average derivative of the probability (AME) and the derivative at the average covariate (MEM). Coefficients are on the log-odds scale; marginal effects are on the probability scale, which is usually what a reader wants.

Standard errors use the expected information matrix, the convention of statsmodels' GLM family. A fit that fails to converge usually signals perfect separation — one combination of regressors predicts the outcome exactly — which is a data problem, not a numerical one.

Frequently asked questions

Logit or Probit?

Statistically they rarely disagree in practice; logit's coefficients read as log-odds and its odds ratios are easy to exponentiate. Probit implies normal errors, which matters when the model feeds a simulation.

Why trust AME over the coefficient?

A logit coefficient of 0.8 does not mean "80% more likely". The probability change per unit of x depends on where you stand — AME averages that over the sample, which is the honest summary.

中文说明

二分类结果会破坏最小二乘(预测越出 [0, 1]、误差天然异方差)。Logit 与 Probit 通过连接函数刻画概率,用迭代重加权最小二乘拟合——即似然上的牛顿法,因此几步就收敛。

系数之外还报告:对仅截距模型的似然比检验、AIC/BIC,以及边际效应——概率的平均导数(AME)与平均协变量处的导数(MEM)。系数在对数发生比尺度;边际效应在概率尺度,通常才是读者要的数。

标准误采用期望信息矩阵(statsmodels 的 GLM 家族惯例)。拟合不收敛通常意味着完全分离——某个自变量组合完美预测了结果——这是数据问题,不是数值问题。

常见问题

选 Logit 还是 Probit?

实践中两者结论很少分歧;logit 系数可读作对数发生比、取幂即得发生率比。若模型要接入模拟且误差需正态,则用 probit。

为什么看 AME 而不是系数?

logit 系数 0.8 不等于“可能性高 80%”。x 每单位的概率变化取决于所处位置——AME 在样本上取平均,是诚实的摘要。