University Solutions Hub provides Visual Analytics Week 11 solution
(Visual Analytics).
Week 11: working with models3
- Take a slice of the gapminder data showing only 1977
- create a linear model of with lifeexp being the target of the log of
gdpPercap. Save it in a variable called fit and show the summary.
- Group the entire data set by continent and year, pipe it through the
nest() function and store it in a variable called out_le.
- The result will be a tibble of columns of data and columns of
tibbles called list columns with data in them.
- Use the filter() and unnest() functions to see Europe 1977
- create a linear function called function(df) with lifeExp and
log(gdpPercap). Save it in fit.ols
- then use group_by(), nest(), and mutate() to create a tibble called
out_le and show the contents of the tibble.
- type fit.ols to see what it looks like after you have created
it
- type fit.ols(df = gapminder) to see what the new function does.
- using the tidy() function, extract summary statistics from each
model by mapping the tidy() to the model list column. * * * Unnest the
result and drop the other columns. Filter out all the Intercept terms
and drop the few observations from Oceania. Save five rows of this
pipeline in out_tidy.
- Plot the output in a dot and whisker diagram (geom_pointrange())
grouped and colored by continent. Use position_dodge within
geom_pointrange to insure that the results will be nearby but will not
obscure each other
Note:
Only for knowledge gain and helping to the students(who are facing
difficulties when solving to the Assessments/ Home works) with their
course support.