Methods in Political Science

Regression Analysis

Sirus Dehdari

Department of Political Science, Stockholm University

Why regression analysis?

  • We are often interested in examining relationships between different variables
  • Are unemployed citizens more likely to support radical right parties?
  • Is there less corruption in democratic countries?
  • Is there a relationship between income and voter turnout?
  • In generic form: is there a relationship between the variable \(X\) and the variable \(Y\)?

This week we will learn the following

  • Understand how regression analysis can help us examine these types of relationships
  • In particular:
    • Is the relationship positive or negative (or is there no relationship at all)?
    • How strong is the relationship?
    • Is it really a statistically significant relationship?
    • How much of the variation in \(Y\) can be explained by \(X\)?
  • Chapter 5.1 in Österman and Folke
  • Next week: what happens when we “control” for more variables (multiple regression analysis)

Today’s lecture

  • Linear relationships
  • Regression line
  • Model fit
  • Statistical significance (inference)
  • Interpreting regression results

Indoor temperature (again!)

  • We’re back at the Ministry of Rural Affairs and Infrastructure
  • Now we want to understand why some households have lower indoor temperature compared to other households
  • Someone at the ministry suggests there’s a relationship between income and indoor temperature
  • Assume there is a linear relationship between these two variables
  • Usually the simplest way to describe a relationship between two variables is as a linear relationship

Converting from one unit to another

  • What is a linear relationship?
  • Suppose we find a recipe where the measurements are given in cups, but we’re used to ml and dl
  • There’s a relationship between cups and, say, dl:

\[deciliter = 2.366 \times cups\]

  • The recipe says the oven should be at a certain temperature, given in Celsius, but you’re used to Fahrenheit:

\[Fahrenheit = 32 + 1.8 \times Celsius\]

Example: Cups to deciliters

Example: Cups to deciliters

Example: Cups to deciliters

Linear relationship

  • For every value on the \(x\)-axis (cups) we get a value on the \(y\)-axis
  • Example: When \(cups = 1\), \(deciliter = 2.36588\); when \(cups = 2\), \(deciliter = 4.73176\)
  • When \(cups = 0\), \(deciliter = 0\) (of course)
  • However, \(x = 0\) doesn’t have to give \(y = 0\) for other relationships

Celsius to Fahrenheit

Celsius to Fahrenheit

Linear equation

  • A linear relationship can be described with a linear equation:

\[y = kx + m\]

  • The slope of the line is given by \(k\), while \(m\) is the constant
  • Cups to deciliters: \(m = 0\) and \(k= 2.36588\)
  • Celsius to Fahrenheit, \(m=32\) and \(k= 1.8\)

Linear equation

  • In statistics a modified version is used

\[y = a + bx\]

  • The slope, also called the slope coefficient, is given by \(b\), while \(a\) is the constant
  • We call \(y\) the dependent variable, while \(x\) is called the independent variable
  • If \(b\) is greater than zero, the relationship is positive
  • If \(b\) is less than zero, the relationship is negative
  • If \(b\) equals zero, there is no relationship

Positive, negative, or no relationship

Linear equation

  • So far we’ve seen examples of an exact linear relationship
  • The dots represent our data: all dots lie on the line
  • Relationships are rarely exact, though; usually they are inexact
  • This can be because we can’t always make exact measurements
  • More likely, though, is that we’re studying complex relationships

Income and indoor temperature

  • Back to our scenario: we want to understand what determines which indoor temperature households choose to have
  • Those with higher income are more likely to be able to afford higher electricity costs
  • Reasonable to assume a positive relationship between income and indoor temperature
  • But we shouldn’t assume the relationship is exact, since households’ indoor temperature is also affected by other factors

Example: temperature data

  • Suppose we have a random sample of 15 households
Household ID Indoor temperature Monthly income (in thousands of SEK)
1 18.3 13.4
2 19.5 13.6
3 20.5 26.9
4 20.8 33.5
5 18.5 14.4
6 20.4 44.0
7 17.2 20.3
8 15.9 16.6
9 22.3 28.8
10 16.6 35.0
11 21.6 28.9
12 25.4 42.3
13 19.7 27.8
14 23.5 24.7
15 18.0 29.2

Is there a linear relationship?

  • It looks like those with higher income also have higher indoor temperature
  • However, it’s probably not an exact linear relationship
  • We need a modified equation to account for the relationship not being exact:

\[Y_i = a + b X_i + e_i\]

  • The parameters \(a\) and \(b\) represent the constant (intercept) and the slope coefficient, just as in the previous equation
  • The error term \(e_i\) compensates for the fact that the observations deviate from the straight line

Explore the data: temperature and income

The regression line

  • The regression line is meant to fit our data and is given by the equation:

\[\hat{Y_i} = 16.43+0.13 \times X_i\]

  • The “hat” on \(Y_i\) indicates that this is the model’s estimate (or prediction) of \(Y_i\)
  • The slope coefficient (\(b\)) measures the slope of the regression line, and in this case equals 0.13
  • Interpretation of the slope coefficient: a one-unit increase in \(X\) is expected to increase \(Y\) by 0.13 units
  • In our example: an increase of 1000 SEK (why?) is expected to increase indoor temperature by 0.13 degrees Celsius

Predicting the indoor temperature

  • The constant (intercept) equals 16.43
  • Interpretation of the constant: when income equals 0, the room temperature is expected to equal 16.43
  • There isn’t always a sensible interpretation of the constant (what does 0 income mean?)
  • Example: expected indoor temperature for a household with a monthly income of 30,000 SEK: 16.43 \(+\) 0.13 \(\times\) 30 \(=\) 20.33
  • But wait: how do we choose the regression line?
  • Isn’t there another line that fits the data better?

Other possible lines

  • What about these lines?

The method of least squares

  • The method of least squares gives us the line that minimizes the sum of squared deviations
  • Every observation will deviate from the model’s prediction (the regression line)
  • The method of least squares finds the line that makes the sum of the squared deviations as small as possible
  • These deviations are called residuals and equal the actual value minus the predicted value:

\[\hat{e}_i = Y_i - \hat{Y_i}\]

Deviations from the regression line

Residuals

  • As we saw in the graph, the regression line doesn’t fit the data exactly
  • Example: household 12 has an income of 42,300 SEK
  • According to the model, that household’s temperature should equal 16.43 \(+\) 0.13 \(\times\) 42.3 \(=\) 21.9
  • However, their actual temperature equals 25.4, so \(\hat{e}_i =\) 3.5

Model fit

  • For that specific observation, the model wasn’t very good at predicting the temperature
  • But it’s better at predicting other observations
  • Model fit measures how well the regression line fits the data overall
  • The measures are based on the residuals, i.e. the observations’ deviations from the model’s predictions
  • The most common fit measures are \(R^2\) and Root-MSE

\(R\)-squared: \(R^2\)

  • \(R^2\) measures how much of the variation in the dependent variable \(Y\) can be explained by the model (in this case the independent variable \(X\))
  • \(R^2\) takes a value between 0 and 1, where \(R^2\) = 0 means the model doesn’t explain any of the variation in the dependent variable
  • While \(R^2\) = 1 means the model fully explains the variation in the dependent variable
  • In the temperature-and-income example, \(R^2\) = 0.173, which means income explains 17.3% of the variation in temperature

Calculating \(R^2\)

  • In this course you don’t need to learn how to calculate \(R^2\)
  • But you must know how to interpret it
  • Here’s the formula:

\[R^2 = 1 - \frac{RSS}{TSS} = 1 - \frac{\sum_{i = 1}^n(Y_i-\hat{Y_i})^2}{\sum_{i = 1}^n(Y_i-\bar{Y_i})^2}\]

  • \(RSS\) (Residual Sum of Squares) is the sum of the squared residuals
  • \(TSS\) (Total Sum of Squares) is the sum of the squared deviations from the sample mean of \(Y\)

Root-MSE

  • Root-MSE measures the average deviation from the regression line
  • A high value indicates the model doesn’t fit the data very well
  • The measure is given in the same unit as the dependent variable
  • In the room-temperature example: Root-MSE equals 2.21
  • This means that, in our data, household temperature deviates, on average, by 2.21 degrees Celsius from the regression line

Calculating Root-MSE

  • In this course you don’t need to learn how to calculate Root-MSE
  • But you must know how to interpret it
  • Here’s the formula:

\[\textit{Root-MSE} = \sqrt{\frac{RSS}{n-k}} = \sqrt{\frac{\sum_{i = 1}^n(Y_i-\hat{Y_i})^2}{n-k}}\]

  • Where \(k\) is the number of parameters we estimate in the model (in a bivariate regression model we estimate the parameters \(a\) and \(b\))

Assumptions behind the method of least squares

  • The method of least squares relies on a number of assumptions (the Gauss-Markov assumptions)
  • If the assumptions hold, the estimate is BLUE (Best Linear Unbiased Estimator)
  • We won’t go through them in detail in this course, but they’re worth knowing about:
    1. Linearity in parameters
    2. Random sampling
    3. Zero conditional mean (exogeneity)
    4. Homoskedasticity
  • More on each assumption (advanced): Read more

Relationship strength and model fit

  • Important: the strength of a relationship (given by \(b\)) is not the same thing as model fit (given by \(R^2\) or Root-MSE)
Weak fit, strong slope Strong fit, weak slope

Brief summary

  • So far we’ve discussed exact and inexact relationships
  • We specify a regression model denoted by a linear equation
  • We saw an example with a regression line representing the relationship between indoor temperature (dependent variable) and income (independent variable)
  • The data points don’t lie on the regression line: the fit measure tells us how well the line fits our data

Statistical inference

  • How confident are we that the estimated relationship didn’t arise by chance?
  • Compare with last week: could we say with confidence that the population mean \(\mu_X\) isn’t equal to, say, 17, when we estimate \(\bar{X} = 20\)?
  • If \(b = 0\) there is no relationship between the dependent and independent variable; if \(b \neq 0\) there is a positive or negative relationship
  • We can “test” whether the true value of \(b\) is different from zero
  • Since we estimate \(b\) using a random sample, \(b\) is also a random variable, and you know what that means…

Confidence interval

  • All random variables follow a probability distribution, and this also applies to our estimate of \(b\)
  • That distribution is approximately a normal distribution (the Central Limit Theorem)
  • We therefore know that in 95 of 100 samples, our estimate of \(b\) will fall within a certain interval around the true population value
  • And in those 95 samples, a similar interval around our estimate of \(b\) will cover the true population value
  • We therefore construct a (90%, 95%, or 99%) confidence interval around our estimate of \(b\) and compare it with the value zero

Constructing the confidence interval

  • The formula for the confidence interval for the estimate of \(b\) is

\[b \pm t \times se(b)\]

  • Where the standard error of \(b\) is usually denoted \(se(b)\)
  • In this course you don’t need to learn how to calculate \(se(b)\) – it’s almost always given by, e.g., Stata or other statistical software
  • The value of \(t\) is determined by the chosen confidence level (the critical value)
  • In this course you can use \(t\) = 1.65 for 90%, \(t\) = 1.96 for 95%, \(t\) = 2.58 for 99%

Example: temperature and income

  • Consider once again our example with indoor temperature and income
  • The estimated slope coefficient for \(b\) is 0.13, and from Stata (or other statistical softwares) we also get \(se(b) = 0.065\)
  • Suppose we decide on a confidence level of 95%: we then use $t = $ 1.96
  • According to the formula we get

\[0.13 \pm 1.96 \times 0.065 = 0.13 \pm 0.1274\]

  • A 95% confidence interval runs from 0.0026 to 0.2574

Statistically different from 0

  • 95% of the confidence intervals we construct around our estimate of \(b\) will cover the true value of \(b\)
  • Since the confidence interval we constructed (at the 95% level) doesn’t cover 0, we can rule out that 0 is the true population value
  • Of course, we can only rule out 0 with 95% confidence; what if we want to rule out 0 with 99% confidence?
  • If we instead use \(t =\) 2.58 we get

\[0.13 \pm 2.58 \times 0.065 = 0.13 \pm 0.1677\]

  • A 99% confidence interval runs from -0.0377 to 0.2977, i.e. it covers 0

Statistically different from 0

  • We therefore say that the estimated relationship is statistically significant at the 95% confidence level, but not at 99%
  • It can happen that we estimate a non-statistically-significant relationship even when the true relationship actually exists
    • The sample is too small (affects the standard error \(se(b)\))
    • There’s too little variation in the independent variable (this also affects the standard error)
    • We choose a (too) high confidence level when calculating the confidence interval (compare with last week’s lecture)
  • There is therefore a risk of concluding that no relationship exists when one actually does

Regression tables

  • In scientific studies, results are often presented in so-called regression tables
  • The table below shows estimated coefficients for the model where temperature is the dependent variable and income is the independent variable
  • Standard errors are shown in parentheses
(1)
Constant 16.43
(1.858)
Income 0.13
(0.065)
Observations 15
\(R^2\) 0.173

Regression tables, multiple models

  • In scientific studies, results are often presented in so-called regression tables
  • The table below shows estimated coefficients for the model where temperature is the dependent variable and income is the independent variable
  • Standard errors are shown in parentheses
(1) (2)
Constant 16.43
(1.858) (…)
Income 0.13
(0.065)
Years of education
(…)
Observations 15
\(R^2\) 0.173

Assumptions behind the method of least squares (advanced)

← Back

1. Linearity in parameters

  • The model \(Y_i = a + bX_i + e_i\) must be linear in the parameters \(a\) and \(b\) – not necessarily in the variables themselves
  • For example, \(Y_i = a + bX_i^2 + e_i\) is still linear in parameters, even though \(X^2\) is not a linear variable
  • If this assumption is violated (e.g. a genuinely non-linear relationship forced into a straight line), the estimates become misleading

2. Random sampling

  • The observations must come from a random sample of the population
  • Each pair \((Y_i, X_i)\) must be drawn independently from the same underlying distribution
  • A non-random sample (e.g. self-selection) can mean the sample doesn’t represent the population, leading to misleading estimates

3. Zero conditional mean (exogeneity)

  • The expected value of the error term must be zero regardless of the value of \(X\): \(E(e_i \mid X_i) = 0\)
  • This means \(X\) must not be correlated with anything that affects \(Y\) but isn’t included in the model (omitted variable bias)
  • This is often the hardest assumption to satisfy in practice, and the most discussed one in empirical research

4. Homoskedasticity

  • The variance of the error term must be constant regardless of the value of \(X\): \(Var(e_i \mid X_i) = \sigma^2\)
  • The opposite is called heteroskedasticity (the variance differs depending on \(X\))
  • If this assumption is violated, the standard errors become misleading (the coefficients can, however, still be correct on average)