開始使用免費開始

調整非等變異誤差

在下一個例子中,看起來 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
___
編輯並執行程式碼