在 Applied Linear Statistical Models (Kutner et al) 中给出了一个关于加权最小二乘的例子。
数据集:年龄与舒张压
对年龄进行 DBP 回归得到以下模型
但是残差图显示了类似扩音器的形状,这意味着异方差。
由于残差的绝对值与年龄预测器呈线性趋势,因此对这些残差与年龄进行了 OLS,从而导致
使用这些拟合值作为权重
产生了一个新模型:.
仍然存在一些问题,首先将模型表示为:
为什么不使用残差作为权重的估计量?
自从定义为在哪里和
我真的不明白为什么我们必须再次回归残差才能找到权重。
加权最小二乘法能解决多少问题?
我在 R 中执行了上述分析并绘制了加权最小二乘拟合的新残差图,结果如下:

但这似乎并没有好得多?
R代码
colnames(Blood_Pressure_Example) <- c("Age", "DBP");
attach(Blood_Pressure_Example)
plot(DBP~Age)
fit <- lm(DBP~Age)
abline(fit)
summary(fit)
plot(residuals.lm(fit)~Age)
plot(abs(residuals.lm(fit))~Age)
## Like in the book
fit.res <- lm(abs(residuals.lm(fit))~Age)
wii <- 1/predict.lm(fit.res)^2
fit.end <- lm(DBP~Age, weights = as.vector(wii))
summary(fit.end)
plot(residuals.lm(fit.end)~Age)
## why not use the residuals as weights?
residuals.lm(fit)
wii.test <- 1/(residuals.lm(fit)^2)
wii.test
fit.test <- lm(DBP~Age, weights=as.vector(wii.test))
summary(fit.test)
plot(residuals.lm(fit.test)~Age)
