You are on page 1of 32

BA 340 : DATA ANALYTICS

Linear Regression

Course By : Nabil Chaabane


How to fit the best line?
Wages
Wages
Wages
Wages
Wages
Wages
Wages

● Create a data frame


● Evaluate the model using the predict function.
Categorical Data
Categorical Data
Categorical Data
Categorical Data
Categorical Data
Categorical Data
Model earn on sex with a linear model.

Does the output suggest there is a difference between male


and female salaries (at a statistically significant level)?

Bonus: make male salaries the baseline.


Categorical Data
Categorical Data
Categorical Data
Multivariate Functions
Multivariate Functions
Multivariate Functions
Multivariate Functions
Multivariate Functions
Multivariate Functions
Multivariate Functions
Multivariate Functions
Multivariate Functions
Interaction Effect
Multivariate functions can be written as :

● earn ~ a1 * height + intercept ; for females


● earn ~ a1 * height + intercept + b1 ; for males

This can be reformulated as :

● earn ~ a1 * height + intercept + b1 * sex; where sex = 1 if female


and 0 if male

Models might be more complex and need to take into account the
interaction between the variables height and sex.

● earn ~ a2 * height + intercept + b2 * sex + a2 * b2 * sex * height


Interaction Effect
Interaction Effect
Interaction Effect
Interaction Effect

You might also like