不等分散への対応
次の例では、explanatory 変数が大きくなるにつれて response 変数の分散が大きくなっているように見えます。なお、この演習で行う修正は、ばらつきを変えるだけでなく、関係の線形性にも影響を与える点に注意してください。
この演習はコースの一部です
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
___