一点也不。系数的大小直接取决于为变量选择的比例,这在某种程度上是建模的决定。
要看到这一点,请考虑一个线性回归模型,该模型在给出虹膜的花瓣长度(以厘米为单位)的情况下预测虹膜的花瓣宽度(以厘米为单位):
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解释了Z中的方差比Y多(线性回归模型预测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
与(大约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几乎不变。