View the step-by-step solution to:

What are the differences in the relationship between lifeExp ~ year among continents in the gapminder dataset?

What are the differences in the relationship between lifeExp ~ year among continents in the gapminder dataset?


To answer this question: 

Fit lm models of lifeExp ~ year for each country as described in the ch. 25 text.

 

Use the broom package to make a tidy object of the coefficients (i.e.,the variable named estimate) and their confidence intervals (i.e., the variables named conf.low and conf.high).


Using your own code and style, plot these coefficients along with their confidence intervals for each country grouped by continent using ggplot and one of the facet_* functions such as facet_wrap. 

Hint: remember my lecture and see this blog post http://varianceexplained.org/r/broom-intro/


BONUS +2: Plot the mean coefficient values for each continent. Plot the confidence intervals around these continent means.



My attempt: 

gapminder %>% ggplot(aes(year, lifeExp, group = country))+geom_line(alpha = 1 / 3) +facet_wrap(~continent)


lm(data = gapminder, formula = l

lifeExp ~year+country+continent) 


lot_l <-lm(data = gapminder, formula = lifeExp ~year+country+continent) 


summary(lot_l)


lot_c<-tidy(lot_l,conf.int = TRUE)

summary(lot_c)


lot_c %>% ggplot(aes(estimate, conf.low,conf.high)) +geom_line(aes(group = term), alpha = 1 / 3) + geom_smooth(se = FALSE)+facet_grid(~term)

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question