一点也不。系数的大小直接取决于为变量选择的尺度,这是一个有点武断的建模决策。
为了看到这一点,考虑一个线性回归模型,在给定花瓣长度(以厘米为单位)的情况下预测虹膜的花瓣宽度(以厘米为单位):
summary(lm(Petal.Width~Petal.Length, data=iris))
# Call:
# lm(formula = Petal.Width ~ Petal.Length, data = iris)
#
# Residuals:
# Min 1Q Median 3Q Max
# -0.56515 -0.12358 -0.01898 0.13288 0.64272
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) -0.363076 0.039762 -9.131 4.7e-16 ***
# Petal.Length 0.415755 0.009582 43.387 < 2e-16 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Residual standard error: 0.2065 on 148 degrees of freedom
# Multiple R-squared: 0.9271, Adjusted R-squared: 0.9266
# F-statistic: 1882 on 1 and 148 DF, p-value: < 2.2e-16
我们的模型实现了调整后的 R^2 值 0.9266,并将系数值 0.415755 分配给 Petal.Length 变量。
然而,以厘米为单位定义 Petal.Length 的选择非常随意,我们可以改为以米为单位定义变量:
iris$Petal.Length.Meters <- iris$Petal.Length / 100
summary(lm(Petal.Width~Petal.Length.Meters, data=iris))
# Call:
# lm(formula = Petal.Width ~ Petal.Length.Meters, data = iris)
#
# Residuals:
# Min 1Q Median 3Q Max
# -0.56515 -0.12358 -0.01898 0.13288 0.64272
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) -0.36308 0.03976 -9.131 4.7e-16 ***
# Petal.Length.Meters 41.57554 0.95824 43.387 < 2e-16 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Residual standard error: 0.2065 on 148 degrees of freedom
# Multiple R-squared: 0.9271, Adjusted R-squared: 0.9266
# F-statistic: 1882 on 1 and 148 DF, p-value: < 2.2e-16
当然,这并不会真正影响拟合模型——我们只是为 Petal.Length.Meters (41.57554) 分配了比 Petal.Length (0.415755) 大 100 倍的系数。模型的所有其他属性(调整后的 R^2、t 统计量、p 值等)都是相同的。
通常,在拟合正则化线性模型时,首先将变量归一化(例如,具有均值 0 和单位方差)以避免基于所选尺度偏爱某些变量。
假设归一化数据
即使您已经对所有变量进行了归一化,具有较高系数的变量在预测中可能仍然没有那么有用,因为很少设置自变量(具有低方差)。例如,考虑具有因变量 Z 和自变量 X 和 Y 取二进制值的数据集
set.seed(144)
dat <- data.frame(X=rep(c(0, 1), each=50000),
Y=rep(c(0, 1), c(1000, 99000)))
dat$Z <- dat$X + 2*dat$Y + rnorm(100000)
通过构造,当两者都用于通过线性回归预测 Z 时,Y 的系数大约是 X 的系数的两倍:
summary(lm(Z~X+Y, data=dat))
# Call:
# lm(formula = Z ~ X + Y, data = dat)
#
# Residuals:
# Min 1Q Median 3Q Max
# -4.4991 -0.6749 -0.0056 0.6723 4.7342
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) -0.094793 0.031598 -3.00 0.0027 **
# X 0.999435 0.006352 157.35 <2e-16 ***
# Y 2.099410 0.031919 65.77 <2e-16 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Residual standard error: 0.9992 on 99997 degrees of freedom
# Multiple R-squared: 0.2394, Adjusted R-squared: 0.2394
# F-statistic: 1.574e+04 on 2 and 99997 DF, p-value: < 2.2e-16
尽管如此,X 比 Y 解释了更多 Z 的方差(用 X 预测 Z 的线性回归模型的 R^2 值为 0.2065,而用 Y 预测 Z 的线性回归模型的 R^2 值为 0.0511):
summary(lm(Z~X, data=dat))
# Call:
# lm(formula = Z ~ X, data = dat)
#
# Residuals:
# Min 1Q Median 3Q Max
# -5.2587 -0.6759 0.0038 0.6842 4.7342
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 1.962629 0.004564 430.0 <2e-16 ***
# X 1.041424 0.006455 161.3 <2e-16 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Residual standard error: 1.021 on 99998 degrees of freedom
# Multiple R-squared: 0.2065, Adjusted R-squared: 0.2065
# F-statistic: 2.603e+04 on 1 and 99998 DF, p-value: < 2.2e-16
相对:
summary(lm(Z~Y, data=dat))
# Call:
# lm(formula = Z ~ Y, data = dat)
#
# Residuals:
# Min 1Q Median 3Q Max
# -5.0038 -0.7638 -0.0007 0.7610 5.2288
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) -0.09479 0.03529 -2.686 0.00724 **
# Y 2.60418 0.03547 73.416 < 2e-16 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Residual standard error: 1.116 on 99998 degrees of freedom
# Multiple R-squared: 0.05114, Adjusted R-squared: 0.05113
# F-statistic: 5390 on 1 and 99998 DF, p-value: < 2.2e-16
多重共线性的情况
大系数值可能具有欺骗性的第三种情况是变量之间存在显着的多重共线性的情况。例如,考虑一个数据集,其中 X 和 Y 高度相关,但 W 与其他两个不高度相关;我们试图预测 Z:
set.seed(144)
dat <- data.frame(W=rnorm(100000),
X=rnorm(100000))
dat$Y <- dat$X + rnorm(100000, 0, 0.001)
dat$Z <- 2*dat$W+10*dat$X-11*dat$Y + rnorm(100000)
cor(dat)
# W X Y Z
# W 1.000000e+00 5.191809e-05 5.200434e-05 0.8161636
# X 5.191809e-05 1.000000e+00 9.999995e-01 -0.4079183
# Y 5.200434e-05 9.999995e-01 1.000000e+00 -0.4079246
# Z 8.161636e-01 -4.079183e-01 -4.079246e-01 1.0000000
这些变量几乎具有相同的均值 (0) 和方差 (~1),线性回归分配给 X(大约 15)和 Y(大约 -16)的系数值(绝对值)比分配给 W(大约2):
summary(lm(Z~W+X+Y, data=dat))
# Call:
# lm(formula = Z ~ W + X + Y, data = dat)
#
# Residuals:
# Min 1Q Median 3Q Max
# -4.1886 -0.6760 0.0026 0.6679 4.2232
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 1.831e-04 3.170e-03 0.058 0.954
# W 2.001e+00 3.172e-03 630.811 < 2e-16 ***
# X 1.509e+01 3.177e+00 4.748 2.05e-06 ***
# Y -1.609e+01 3.177e+00 -5.063 4.13e-07 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Residual standard error: 1.002 on 99996 degrees of freedom
# Multiple R-squared: 0.8326, Adjusted R-squared: 0.8326
# F-statistic: 1.658e+05 on 3 and 99996 DF, p-value: < 2.2e-16
尽管如此,在模型的三个变量中,W 是最重要的:如果从完整模型中删除 W,R^2 从 0.833 下降到 0.166,而如果删除 X 或 Y,R^2 几乎没有变化。