Description of the data, data_quiz5

Q1 Import data

DataQuiz5 <- read.csv("data_quiz5.csv")

Q2 Review data

head(DataQuiz5, 6)
##     country continent lifeExp      pop gdpPercap
## 1   Albania    Europe  76.423  3600523  5937.030
## 2   Algeria    Africa  72.301 33333216  6223.367
## 3 Argentina  Americas  75.320 40301927 12779.380
## 4 Australia   Oceania  81.235 20434176 34435.367
## 5   Austria    Europe  79.829  8199783 36126.493
## 6   Bahrain      Asia  75.635   708573 29796.048

Q3 Visualize data

library(tidyverse)
ggplot(DataQuiz5, 
       aes(x = lifeExp, 
           y = gdpPercap)) +
  geom_point() +
  geom_smooth(method = "lm")

Q4 Build a regression model to predict GDP per capita using life expectancy.

options(scipen=999)
country_lm <- lm(gdpPercap ~ lifeExp, 
                data = DataQuiz5)

summary(country_lm)
## 
## Call:
## lm(formula = gdpPercap ~ lifeExp, data = DataQuiz5)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -17319.8  -4512.4    -63.2   3443.1  24014.4 
## 
## Coefficients:
##              Estimate Std. Error t value            Pr(>|t|)    
## (Intercept) -215340.5    18057.2  -11.93 <0.0000000000000002 ***
## lifeExp        3075.6      237.6   12.94 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7578 on 81 degrees of freedom
## Multiple R-squared:  0.6741, Adjusted R-squared:  0.6701 
## F-statistic: 167.5 on 1 and 81 DF,  p-value: < 0.00000000000000022

Q5 Is the coefficient of life expectancy statistically significant at 5%?

Yes it is statistically significant at 5% because its P value is smaller than 0.05. Its P value is 0.0000000000000002, which means we are 99.9% confident that the intercept is true.

Q6 Interpret the coefficient of life expectancy.

For every year one lives, they will gain $3,075.60.

Q7 Your friend suggests that the more populous a country, the higher its standard living (GDP per capita) is. Create a new model below by adding an additional predictor to the regression model above to test this hypothesis. Is the new variable statistically significant? What would you say to your friend regarding his/her claim?

options(scipen=999)
country_lm <- lm(gdpPercap ~ lifeExp + pop, 
                data = DataQuiz5)

summary(country_lm)
## 
## Call:
## lm(formula = gdpPercap ~ lifeExp + pop, data = DataQuiz5)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -17337  -4536    -82   3463  23993 
## 
## Coefficients:
##                       Estimate         Std. Error t value
## (Intercept) -215081.8386328746   18328.1060846602 -11.735
## lifeExp        3072.6060571578     240.7532777810  12.762
## pop              -0.0000006064       0.0000056600  -0.107
##                        Pr(>|t|)    
## (Intercept) <0.0000000000000002 ***
## lifeExp     <0.0000000000000002 ***
## pop                       0.915    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7625 on 80 degrees of freedom
## Multiple R-squared:  0.6741, Adjusted R-squared:  0.666 
## F-statistic: 82.75 on 2 and 80 DF,  p-value: < 0.00000000000000022

Q8 Hide the messages, but display the code and its results on the webpage.

Q9 Display the title and your name correctly at the top of the webpage.

Q10 Use the correct slug.