Evaluating imputations (many models & variables)
When you build up an imputation model, it's a good idea to compare it to another method.
In this lesson, we are going to get you to add a final imputation model that contains an extra useful piece of information that helps explain some of the variation in the data. You are then going to compare the values, as previously done in the last lesson.
This exercise is part of the course
Dealing With Missing Data in R
Exercise instructions
Using the oceanbuoys
dataset:
- Impute data using
impute_lm()
, addingyear
to the model. - Bind the imputation methods together, placing
ocean_imp_mean
intomean
,ocean_imp_lm_wind
intolm_wind
, andocean_imp_lm_wind_year
intolm_wind_year
. - Look at the values of
air_temp_c
(on the x-axis) andhumidity
(on the y-axis), coloring by any missings, and faceting by imputation model.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Build a model adding year to the outcome
ocean_imp_lm_wind_year <- bind_shadow(___) %>%
impute_lm(air_temp_c ~ wind_ew + wind_ns + ___) %>%
impute_lm(humidity ~ wind_ew + wind_ns + ___) %>%
add_label_shadow()
# Bind the mean, lm_wind, and lm_wind_year models together
bound_models <- bind_rows(mean = ocean_imp_mean,
lm_wind = ocean_imp_lm_wind,
lm_wind_year = ___,
.id = "imp_model")
# Explore air_temp and humidity, coloring by any missings, and faceting by imputation model
ggplot(___, aes(x = ___, y = ___, color = any_missing)) +
geom_point() + facet_wrap(~___)