针对非恒定误差进行调整
在下一个示例中,response 变量的方差似乎会随着 explanatory 变量的增大而增大。请注意,本练习中的修正会同时影响变异性,并且会改变两者关系的线性程度。
本练习是课程的一部分
R 中的线性回归推断
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Run this to see how the model looks
ggplot(hypdata_nonequalvar, aes(x = explanatory, y = response)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE)
# Model response vs. explanatory
model <- ___
# Extract observation-level information
modeled_observations <- ___
# See the result
modeled_observations
# Using modeled_observations, plot residuals vs. fitted values
___