0% found this document useful (0 votes)
26 views

Lesson 5 6 Linear Regression Prerequisites II

This document discusses how to perform linear regressions, including how to handle nominal explanatory variables by transforming them into dummy variables. It explains that nominal variables without order should be converted into dummy variables for inclusion in a regression model to test for differences between groups. The document provides an example using R code to create dummy variables from a nominal country variable and use them in a regression to examine if UK and German regions differ in average GDP based on population density.

Uploaded by

Jorge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Lesson 5 6 Linear Regression Prerequisites II

This document discusses how to perform linear regressions, including how to handle nominal explanatory variables by transforming them into dummy variables. It explains that nominal variables without order should be converted into dummy variables for inclusion in a regression model to test for differences between groups. The document provides an example using R code to create dummy variables from a nominal country variable and use them in a regression to examine if UK and German regions differ in average GDP based on population density.

Uploaded by

Jorge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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