Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

How to do a linear regression?

Tom Broekel
Prerequisites II

1 © TBroekel
How to do linear regressions: Prerequisites
Nominal (no order of values) explanatory variables?
70

60

c
GDP

50

40

1000 2000 3000 4000 5000


POPDEN

2 © TBroekel
How to do linear regressions: Prerequisites

Nominal (no order of values) explanatory variable

∆ X “change in explanatory variable” not useful concep

Values of X indicate group membershi

Test for differences between group

X decided into set of “Dummy” variables with 0/1 value

Each dummy variable indicates belonging to a specific group

3 © TBroekel
s

How to do linear regressions: Prerequisites


Nominal (no order of values) explanatory variable

Test for differences between group

Include dummy variables as explanatory variables into regression equatio

At least one dummy variable not included as reference grou

Interpretation: Dummy variables = change in the intercept’s value between


group

By how much are values of dependent variable higher for a group (dummy=1)
than for the reference group

4 © TBroekel
s

How to do linear regressions: Prerequisites

How to do dummy variables from nominal variable in R

Create variable indicating country (from regional NUTS2 codes

Do UK regions differ in their average GDP than German regions?

5 © TBroekel
?

How to do linear regressions: Prerequisites

Create dummies with fastDummies packag

Function dummy_cols() creates individual dummy variables for a selected


nominal variable’s categories

6 © TBroekel
e

How to do linear regressions: Prerequisites

Individual dummies can be added to regression formul

Allows for manual selection of reference category - dummy variable that


is not include

Alternative: transform nominal variable into factor or character - most


regression commands will automatically create dummy variable

However: More difficult to set reference category

7 © TBroekel
d

How to do linear regressions: Prerequisites

50000

Fitted values GDP/c in EUR


40000

30000

20000

0 1000 2000 3000


Pop_Den

UK DE Both

8 © TBroekel
How to do linear regressions: Prerequisites

Prerequisites linear regressio

Sufficiently large number of observation

Continuous dependent variabl

Main relationship linear in natur

Nominal explanatory variables transformed into “Dummy” variables

9 © TBroekel
e

How to do a linear regression? Tom Broekel


Prerequisites II

10 © TBroekel

You might also like