ggplot(diamonds2, aes(lcarat, lresid2)) + geom_hex(bins = 50)

这张图表明有一些残差相当大的钻石——请记住,残差为 2 表示该钻石的价格是我们预期价格的 4 倍。逐个查看异常值通常很有用:
diamonds2 %>% filter(abs(lresid2) > 1) %>% add_predictions(mod_diamond2) %>% mutate(pred = round(2 ^ pred)) %>% select(price, pred, carat:table, x:z) %>% arrange(price) #> # A tibble: 16 × 11 #> price pred carat cut color clarity depth table x #>
这里没有什么特别显眼的地方,但值得花时间思考一下:这是否表明我们的模型存在问题,或者数据中存在错误。如果数据中有错误,这可能是一个以被错误标低的低价购买钻石的机会。