評估與比較插補結果
建立插補模型時,最好與其他方法比較。在本課中,我們要將先前用 impute_lm() 產生的插補資料集,與以平均值插補的資料集進行比較。這兩個資料集已包含在本練習中,分別為 ocean_imp_lm_wind 與 ocean_imp_mean。
本練習屬於課程
在 R 中處理遺漏值
練習說明
- 使用
bind_rows()將兩個模型合併,把ocean_imp_mean指定到mean,把ocean_imp_lm_wind指定到lm_wind。 - 以散佈圖檢視
air_temp與humidity的數值,將air_temp_c放在 x 軸、humidity放在 y 軸,依是否為遺漏值著色,並依所使用的插補模型(imp_model)進行分面。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Bind the models together
bound_models <- bind_rows(mean = ___,
lm_wind = ___,
.id = "imp_model")
# Inspect the values of air_temp and humidity as a scatter plot
ggplot(___,
aes(x = ___,
y = ___,
color = any_missing)) +
geom_point() +
facet_wrap(~___)