Introduction to Linear Regression

The Human Freedom Index is a report that attempts to summarize the idea of “freedom” through a bunch of different variables for many countries around the globe. It serves as a rough objective measure for the relationships between the different types of freedom - whether it’s political, religious, economical or personal freedom - and other social and economic circumstances. The Human Freedom Index is an annually co-published report by the Cato Institute, the Fraser Institute, and the Liberales Institut at the Friedrich Naumann Foundation for Freedom.

In this lab, you’ll be analysing data from the Human Freedom Index reports. Your aim will be to summarize a few of the relationships within the data both graphically and numerically in order to find which variables can help tell a story about freedom.

Getting Started

Load packages

In this lab, you will explore and visualize the data using the tidyverse suite of packages. You will also use the statsr package to select a regression line that minimizes the sum of squared residuals and the broom package to tidy regression output. The data can be found in the openintro package, a companion package for OpenIntro resources.

Let’s load the packages.

library(tidyverse)
library(openintro)
library(statsr)
library(broom)

Creating a reproducible lab report

To create your new lab report, in RStudio, go to New File -> R Markdown… Then, choose From Template and then choose Lab Report for OpenIntro Statistics Labs from the list of templates.

The data

The data we’re working with is in the openintro package and it’s called hfi, short for Human Freedom Index.

Exercise 1

Q. What are the dimensions of the dataset? What does each row represent?

dim(hfi)
## [1] 1458  123

A. hfi has 1,458 rows/observations and 123 columns/variables. Each row represents one country in the Human Freedom Index.

Exercise 2

Q. The dataset spans a lot of years, but we are only interested in data from year 2016. Filter the data hfi data frame for year 2016, select the six variables, and assign the result to a data frame named hfi_2016.

hfi_2016 <- hfi %>%
  filter(year == 2016) %>%
  select(year, hf_score, pf_score, pf_expression_control)
hfi_2016
## # A tibble: 162 x 4
##     year hf_score pf_score pf_expression_control
##    <dbl>    <dbl>    <dbl>                 <dbl>
##  1  2016     7.57     7.60                  5.25
##  2  2016     5.14     5.28                  4   
##  3  2016     5.64     6.11                  2.5 
##  4  2016     6.47     8.10                  5.5 
##  5  2016     7.24     6.91                  4.25
##  6  2016     8.58     9.18                  7.75
##  7  2016     8.41     9.25                  8   
##  8  2016     6.08     5.68                  0.25
##  9  2016     7.40     7.45                  7.25
## 10  2016     6.85     6.14                  0.75
## # … with 152 more rows

Exercise 3

Q. What type of plot would you use to display the relationship between the personal freedom score, ‘pf_score’, and ‘pf_expression_control’? Plot this relationship using the variable pf_expression_control as the predictor. Does the relationship look linear? If you knew a country’s pf_expression_control, or its score out of 10, with 0 being the most, of political pressures and controls on media content, would you be comfortable using a linear model to predict the personal freedom score?

ggplot(hfi_2016, aes(pf_expression_control, pf_score)) +
  geom_point(color = "purple") +
  geom_smooth(method = 'lm', se = TRUE) +
  xlab("Expression Control") +
  ylab ("Pf Score")
## `geom_smooth()` using formula 'y ~ x'

A. Using a scatter-plot we can clearly see there is a linear relationship between pf_expression_control and pf_score.

## get the coefficient to confirm there is a relationship.
hfi_2016 %>%
  summarise(cor(pf_expression_control, pf_score))
## # A tibble: 1 x 1
##   `cor(pf_expression_control, pf_score)`
##                                    <dbl>
## 1                                  0.845

With a correlation coefficient of 0.845 there is a clear positive relationship between pf_expression_control and pf_score.

If the relationship looks linear, we can quantify the strength of the relationship with the correlation coefficient.

hfi_2016 %>%
  summarise(cor(pf_expression_control, pf_score))

Sum of squared residuals

In this section, you will use an interactive function to investigate what we mean by “sum of squared residuals”. You will need to run this function in your console, not in your markdown document. Running the function also requires that the hfi dataset is loaded in your environment. You will also need to make sure the Plots tab in the lower right-hand corner has enough space to make a plot.

Think back to the way that we described the distribution of a single variable. Recall that we discussed characteristics such as center, spread, and shape. It’s also useful to be able to describe the relationship of two numerical variables, such as pf_expression_control and pf_score above.

Exercise 4

Q. Looking at your plot from the previous exercise, describe the relationship between these two variables. Make sure to discuss the form, direction, and strength of the relationship as well as any unusual observations.

A. Based on the scatter-plot we can see there is a positive linear relationship between pf_expression_control and pf_score. As pf_expression_control increases so does pf_score, although outliers appear to be present.

Just as you’ve used the mean and standard deviation to summarize a single variable, you can summarize the relationship between these two variables by finding the line that best follows their association. Use the following interactive function to select the line that you think does the best job of going through the cloud of points.

plot_ss(x = pf_expression_control, y = pf_score, data = hfi_2016)

## Click two points to make a line.
                                
## Call:
## lm(formula = y ~ x, data = pts)
## 
## Coefficients:
## (Intercept)            x  
##      4.2838       0.5418  
## 
## Sum of Squares:  102.213

After running this command, you’ll be prompted to click two points on the plot to define a line. Once you’ve done that, the line you specified will be shown in black and the residuals in blue.

If your plot is appearing below your code chunk and won’t let you select points to make a line, take the following steps:

  • Go to the Tools bar at the top of RStudio

  • Click on “Global Options…”

  • Click on the “R Markdown pane” (on the left)

  • Uncheck the box that says “Show output inline for all R Markdown documents”

Recall that the residuals are the difference between the observed values and the values predicted by the line:

ei=yi−ŷ i

The most common way to do linear regression is to select the line that minimizes the sum of squared residuals. To visualize the squared residuals, you can rerun the plot command and add the argument showSquares = TRUE.

plot_ss(x = pf_expression_control, y = pf_score, data = hfi_2016, showSquares = TRUE)

## Click two points to make a line.
                                
## Call:
## lm(formula = y ~ x, data = pts)
## 
## Coefficients:
## (Intercept)            x  
##      4.2838       0.5418  
## 
## Sum of Squares:  102.213

Note that the output from the plot_ss function provides you with the slope and intercept of your line as well as the sum of squares.

Exercise 5

Q. Using plot_ss, choose a line that does a good job of minimizing the sum of squares. Run the function several times. What was the smallest sum of squares that you got? How does it compare to your neighbours?

plot_ss(x = pf_expression_control, y = pf_score, data = hfi_2016)

## Click two points to make a line.
                                
## Call:
## lm(formula = y ~ x, data = pts)
## 
## Coefficients:
## (Intercept)            x  
##      4.2838       0.5418  
## 
## Sum of Squares:  102.213

Call:

lm(formula = y ~ x, data = pts)

Coefficients:

(Intercept) x 4.7963 0.4348

Sum of Squares: 112.255

A. 112.255 is the smallest sum of squares.

The linear model

It is rather cumbersome to try to get the correct least squares line, i.e. the line that minimizes the sum of squared residuals, through trial and error. Instead, you can use the lm function in R to fit the linear model (a.k.a. regression line).

m1 <- lm(pf_score ~ pf_expression_control, data = hfi_2016)

The first argument in the function lm() is a formula that takes the form y ~ x. Here it can be read that we want to make a linear model of pf_score as a function of pf_expression_control. The second argument specifies that R should look in the hfi data frame to find the two variables.

Note: Piping will not work here, as the data frame is not the first argument!

The output of lm() is an object that contains all of the information we need about the linear model that was just fit. We can access this information using the tidy() function.

tidy(m1)
## # A tibble: 2 x 5
##   term                  estimate std.error statistic  p.value
##   <chr>                    <dbl>     <dbl>     <dbl>    <dbl>
## 1 (Intercept)              4.28     0.149       28.8 4.23e-65
## 2 pf_expression_control    0.542    0.0271      20.0 2.31e-45

Let’s consider this output piece by piece. First, the formula used to describe the model is shown at the top, in what’s displayed as the “Call”. After the formula you find the five-number summary of the residuals. The “Coefficients” table shown next is key; its first column displays the linear model’s y-intercept and the coefficient of pf_expression_control. With this table, we can write down the least squares regression line for the linear model:

ŷ =4.28+0.542×pf_expression_control

This equation tells us two things:

  • For countries with a pf_expression_control of 0 (those with the largest amount of political pressure on media content), we expect their mean personal freedom score to be 4.28.

  • For every 1 unit increase in pf_expression_control, we expect a country’s mean personal freedom score to increase 0.542 units.

We can assess model fit using R^2, the proportion of variability in the response variable that is explained by the explanatory variable. We use the glance() function to access this information.

glance(m1)
## # A tibble: 1 x 12
##   r.squared adj.r.squared sigma statistic  p.value    df logLik   AIC   BIC
##       <dbl>         <dbl> <dbl>     <dbl>    <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1     0.714         0.712 0.799      400. 2.31e-45     1  -193.  391.  400.
## # … with 3 more variables: deviance <dbl>, df.residual <int>, nobs <int>

For this model, 71.4% of the variability in pf_score is explained by pf_expression_control.

Exercise 6

Q. Fit a new model that uses pf_expression_control to predict hf_score, or the total human freedom score. Using the estimates from the R output, write the equation of the regression line. What does the slope tell us in the context of the relationship between human freedom and the amount of political pressure on media content?

exercise_5 <- lm(hf_score ~ pf_expression_control, data = hfi_2016)
summary(exercise_5)
## 
## Call:
## lm(formula = hf_score ~ pf_expression_control, data = hfi_2016)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.68164 -0.45467  0.05692  0.46699  1.88128 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            5.05340    0.12293   41.11   <2e-16 ***
## pf_expression_control  0.36843    0.02236   16.48   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6595 on 160 degrees of freedom
## Multiple R-squared:  0.6291, Adjusted R-squared:  0.6268 
## F-statistic: 271.4 on 1 and 160 DF,  p-value: < 2.2e-16
A. hf_score = 5.05340 + 0.36843 * pf_expression_control
The slope indicates for unit increase of pf_expression_control the hf_score increases by 0.36843. In other words, the less political pressure on the media the more free a population feels.

Prediction and prediction errors

Let’s create a scatter-plot with the least squares line for m1 laid on top.

ggplot(data = hfi_2016, aes(x = pf_expression_control, y = pf_score)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE)
## `geom_smooth()` using formula 'y ~ x'

Here, we are literally adding a layer on top of our plot. geom_smooth creates the line by fitting a linear model. It can also show us the standard error se associated with our line, but we’ll suppress that for now.

This line can be used to predict y at any value of x. When predictions are made for values of x that are beyond the range of the observed data, it is referred to as extrapolation and is not usually recommended. However, predictions made within the range of the data are more reliable. They’re also used to compute the residuals.

Exercise 7

Q. If someone saw the least squares regression line and not the actual data, how would they predict a country’s personal freedom school for one with a 3 rating for pf_expression_control? Is this an overestimate or an underestimate, and by how much? In other words, what is the residual for this prediction?

#using pf_score linear regression formula 

pf_score1 = 4.28 + 0.542 * 3
pf_score1
## [1] 5.906
A. At a rating of 3 for pf_expression_control the pf_score would be 5.906.
pf_expression_control1 <- hfi %>% 
  group_by(pf_score) %>%
  filter(pf_expression_control == 3) %>%
  select(pf_score, pf_expression_control)

pf_expression_control1
## # A tibble: 23 x 2
## # Groups:   pf_score [23]
##    pf_score pf_expression_control
##       <dbl>                 <dbl>
##  1     5.47                     3
##  2     5.62                     3
##  3     5.58                     3
##  4     5.37                     3
##  5     5.95                     3
##  6     5.28                     3
##  7     5.88                     3
##  8     5.84                     3
##  9     5.24                     3
## 10     6.38                     3
## # … with 13 more rows
The closest pf_score at a rating of 3 is 5.95. Therefore 5.906 is an underestimate by 0.044.

Model diagnostics

To assess whether the linear model is reliable, we need to check for (1) linearity, (2) nearly normal residuals, and (3) constant variability.

In order to do these checks we need access to the fitted (predicted) values and the residuals. We can use the augment() function to calculate these.

m1_aug <- augment(m1)

Linearity: You already checked if the relationship between pf_score and pf_expression_control is linear using a scatter-plot. We should also verify this condition with a plot of the residuals vs. fitted (predicted) values.

ggplot(data = m1_aug, aes(x = .fitted, y = .resid)) +
  geom_point() +
  geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
  xlab("Fitted values") +
  ylab("Residuals")

Notice here that m1 can also serve as a data set because stored within it are the fitted values (ŷ) and the residuals. Also note that we’re getting fancy with the code here. After creating the scatter-plot on the first layer (first line of code), we overlay a red horizontal dashed line at y=0y=0 (to help us check whether the residuals are distributed around 0), and we also rename the axis labels to be more informative.

Exercise 8

Q. Is there any apparent pattern in the residuals plot? What does this indicate about the linearity of the relationship between the two variables?

A. There is no discernible pattern in the residual plot, and the values are about evenly placed on either side of the axis. This suggests the data is a good fit for regression.

Nearly normal residuals: To check this condition, we can look at a histogram of the residuals.

ggplot(data = m1_aug, aes(x = .resid)) +
  geom_histogram(fill = "black", colour = "black", alpha = 0.25, binwidth = 0.25) +
  xlab("Residuals") + 
  geom_density(aes(y=0.5*..count..), colour="black", adjust=5) 

Exercise 9

Q. Based on the histogram, does the nearly normal residuals condition appear to be violated? Why or why not?

A. Although slightly skewed to the left, there is only one real peak (uni-modal) on the bell curve in the residual histogram, so the nearly normal condition is met.

Constant variability:

Q. Based on the residuals vs. fitted plot, does the constant variability condition appear to be violated? Why or why not?

qqnorm(m1_aug$.resid)
qqline(m1_aug$.resid)

A. The variance of the residuals appears to be consistent.

Constant variance. Chegg. (n.d.). https://www.chegg.com/learn/statistics/introduction-to-statistics/constant-variance.

LS0tCnRpdGxlOiAiSHVtYW4gRnJlZWRvbSBJbmRleCIKYXV0aG9yOiAiS3JpcyBTdXR0b24iCmRhdGU6ICJgciBTeXMuRGF0ZSgpYCIKb3V0cHV0OiBvcGVuaW50cm86OmxhYl9yZXBvcnQKLS0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