SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
Statistics Lab
Rodolfo Metulini
IMT Institute for Advanced Studies, Lucca, Italy

Lesson 4 - The linear Regression Model: Theory and
Application - 21.01.2014
Introduction

In the past praticals we analyzed one variable.
For certain reasons, it is even usefull to analyze two or more
variables together.
The question we want to asnwer regards what are the relations,
the causal effects determining changes in a variable. Analyze if a
certain phenomenon is endogenous or exogenous.
In symbols, the idea can be represent as follow:
y = f (x1 , x2 , ...)
Y is the response, which is a function (it depends on) one or more
variables.
Objectives

All in all, the regression model is the instrument used to:
measure the entity of the relations between two or more
variables: Y / X ,
and to measure the causal direction ( X −→
viceversa? )

Y or

forecast the value of the variable Y in response to some
changes in the others X1 , X2 , ... (called explanatories),
or for some cases that are not considered in the sample.
Simple linear regression model
The regression model is stochastic, not deterministic.
Giving two sets of values (two variables) from a random sample of
length n: x = {x1 , x2 , ..., xi , ..xn }; y = {y1 , y2 , ..., yi , ..yn }:
Deterministic formula:
yi = β0 + β1 xi , ∀i = 1, .., n
Stochastic formula:
yi = β0 + β1 xi +
where

i

i

∀i = 1, .., n

is the stochastic component.

β1 define the slope in the relations between X and Y (See graph in
chart 1)
Simple linear regression model - 2

ˆ
ˆ ˆ
We need to find β = {β0 , β1 } as estimators of β0 and β1 .
After β is estimated, we can draw the estimated regression line,
which corresponds to the estimated regression model, as
follow:
ˆ
ˆ
yi = β0 + β1 xi
ˆ
Here, ˆi = yi − yi .
ˆ
Where yi is the i-element of the estimated Y vector, and yi is the
ˆ
i-elements of the real Y vector. (see graph in chart 2)
Steps in the Analysis

1. Study the relations (scatterplot, correlations) between two or
more variables.
ˆ
ˆ ˆ
2. Estimation of the parameters of the model β = {β0 , β1 }.
ˆ
3. Hypotesis tests on the estimated β1 to verify the casual
effects between X and Y
4. Robustness check of the model.
5. Use the model to analyze the causal effect and/or to do
forecasting.
Why linear?

It is simple to estimate, to analyze and to interpret
it likely fits with most of empirical cases, in which the
relations between two phenomenon is linear.
There are a lot of implemented methods to transorm variables
in order to obtain a linear relationship (log transformation,
normalization, etc.. )
Model Hypotesis

In order the estimation and the utilization of the model to be
correct, certain hypotesis must hold:
E ( i ) = 0, ∀i −→ E (yi ) = β0 + β1 xi
Omoschedasticity: V ( i ) = σi2 = σ 2 , ∀i
Null covariance: Cov ( i , j ) = 0, ∀i = j
Null covariance among residuals and explanatories:
Cov (xi , i ) = 0, ∀i, since X is deterministic (known)
Normal assumption:

i

∼ N(0, σ 2 )
Model Hypotesis - 2

From the hypotesis above, follow that:
V (yi ) = σ 2 , ∀i. Y is stochastic only for the

component.

Cov (yi , yj ) = 0, ∀i = j. Since the residuals are uncorrelated.
yi ∼ N[(β0 + β1 x1 ), σ 2 ] Since also the residuals are normal in
shape.
Ordinary Least Squares (OLS) Estimation

The OLS is the estimation method used to estimate the vector β.
The idea is to minimize the value of the residuals.
Since ei = yi − yi we are interested in minimize the component
ˆ
ˆ
ˆ
yi − β0 − β1 xi .
N.B.

i

ˆ
ˆ
= β0 − β1 xi , while ei = β0 − β1 xi

The method consist in minimize the sum of the square
differences:
n
i (yi

− yi )2 =
ˆ

n 2
i ei

= Min,

which is equal to solve this 2 equation system derived using
derivates.
Ordinary Least Squares (OLS) Estimation - 2

n

ei2 = 0

(1)

ei2 = 0

δ/δβ0

(2)

i
n

δ/δβ1
i

After some arithmetics, we end up with this estimators for the
vector β:

β0 = y − β1 x
¯ ˆ ¯
n
¯
¯
i (yi − y )(xi − x )
β1 =
n
2
¯
i (xi − x )

(3)
(4)
OLS estimators

ˆ
ˆ
OLS β0 and β1 are stochastic estimators (they have a
distribution in a sample space of all the possible estimtors
define with different samples)
ˆ
β1 : measure the estimated variation in Y determined by a
unitary variation in X (δY /δX )
ˆ
The OLS estimators are correct (E (β1 ) = β1 ),
and they are BLUE (corrects and with the lowest variance)
Linear dependency index (R 2 )
The R 2 index is the most used index to measure the linear fitting
of the model.
R 2 is confined in the boundary [−1, 1], where, values near to 1 (or
-1) means the explanatories are usefull to describe the changes in
Y.
Let define
SQT = SQR + SQE , or
n
i (yi

− y )2 =
¯

n
y
i (ˆi

The R 2 is defined as
R2 =

n
y y 2
i (ˆi −¯)
n
y 2
i (yi −¯)

− y )2 +
¯

SQR
SQT

or 1 −

n
i (yi

− y i )2
ˆ

SQE
SQT .

Or, equivalent:
Hypotesis testing on β1
The estimated slope parameter β1 is stochastic. It distributes as a
gaussian:
ˆ
β1 ∼ N[β1 , σ 2 /SSx]
We can make use of the hypotesis tests approach to investigate on
the causal relation between Y and X :
H0 : β1 = 0
H1 : β1 = 0,
where, alternative hypotesis mean causal relation.
The test is:
z=

ˆ
β1 −β1
sqrt(σ 2 /SSx)

∼ N(0, 1).

When SSx is unknown, we estimate it as : SSx =
and we use t − test with n − 1 degrees of freedom

n
i (xi

− y )2 ,
¯
Forecasting within the regresion model

The question we want to answer is the following: Which is the
expected value of Y (say yn+1 ), for a certain observation that is
not in the sample?.
Suppose we have, for that observation, the value for the variable X
(say xn+1 )
We make use of the estimated β to determine:
ˆ
ˆ
yn+1 = β0 + β1 xn+1
ˆ
Model Checking
Several methods are used to test the robustness of the model,
most of them based on the stochastic part of the the model: the
estimated residuals.
Graphical checks: Plot residuals versus fitted values
qq-plot for the normality
Shapiro wilk test for normality
Durbin-Watson test for serial correlation
Breusch-Pagan test for heteroschedasticity
Moreover, the leverage is used to evaluate th importance of each
observation in determining the estimated coefficients β.
The Stepwise procedure is used to choice between different model
specifications.
Model Checking using estimated residuals - Linearity
An example of departure from the linearity assumption: we can
draw a curve (not a horizontal line) to interpolate the points

Figure: residuals (Y) versus estimated (X) values
Model Checking using estimated residuals Omoscedasticity
An example of departure from the omoschedasticity assumption
(the estimated residuals increases as the predicted values
increase)
Model Checking using estimated residuals - Normality
An example of departure from the normality assumption: the
qq-points do not follow the qq-line

Figure: residuals (Y) versus estimated (X) values
Model Checking using estimated residuals - Serial
correlation
An example of departure from the serial incorrelation assumption:
the residual at i depend on the value at i − 1
Homeworks

1. Using cement data (n = 13), determine the β0 and β1
coefficients manually, using OLS formula at page 11, of the
model y = β0 + β1 x1
2. Using cement data, estimate the R 2 index of the model
y = β0 + β1 x1 , using formula at page 13.
Charts - 1

Figure: Slope coefficient in the linear model
Charts - 2

Figure: Fitted (line) versus real (points) values

Mais conteúdo relacionado

Mais procurados

Regression analysis
Regression analysisRegression analysis
Regression analysis
saba khan
 
Chapter 2 part3-Least-Squares Regression
Chapter 2 part3-Least-Squares RegressionChapter 2 part3-Least-Squares Regression
Chapter 2 part3-Least-Squares Regression
nszakir
 

Mais procurados (20)

T test and types of t-test
T test and types of t-testT test and types of t-test
T test and types of t-test
 
Chap12 simple regression
Chap12 simple regressionChap12 simple regression
Chap12 simple regression
 
Introduction to Generalized Linear Models
Introduction to Generalized Linear ModelsIntroduction to Generalized Linear Models
Introduction to Generalized Linear Models
 
Unit Root Test
Unit Root Test Unit Root Test
Unit Root Test
 
Doe10 factorial2k blocking
Doe10 factorial2k blockingDoe10 factorial2k blocking
Doe10 factorial2k blocking
 
Frequency Distributions
Frequency DistributionsFrequency Distributions
Frequency Distributions
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Regression analysis
Regression analysisRegression analysis
Regression analysis
 
Chapter 2 part3-Least-Squares Regression
Chapter 2 part3-Least-Squares RegressionChapter 2 part3-Least-Squares Regression
Chapter 2 part3-Least-Squares Regression
 
Introduction to Design of Experiments by Teck Nam Ang (University of Malaya)
Introduction to Design of Experiments by Teck Nam Ang (University of Malaya)Introduction to Design of Experiments by Teck Nam Ang (University of Malaya)
Introduction to Design of Experiments by Teck Nam Ang (University of Malaya)
 
Chap11 simple regression
Chap11 simple regressionChap11 simple regression
Chap11 simple regression
 
Laplace transforms
Laplace transformsLaplace transforms
Laplace transforms
 
Panel data analysis
Panel data analysisPanel data analysis
Panel data analysis
 
Multiple Regression Analysis (MRA)
Multiple Regression Analysis (MRA)Multiple Regression Analysis (MRA)
Multiple Regression Analysis (MRA)
 
Basics of Hypothesis Testing
Basics of Hypothesis Testing  Basics of Hypothesis Testing
Basics of Hypothesis Testing
 
1634 time series and trend analysis
1634 time series and trend analysis1634 time series and trend analysis
1634 time series and trend analysis
 
Ch11 slides
Ch11 slidesCh11 slides
Ch11 slides
 
Normal distribution
Normal distributionNormal distribution
Normal distribution
 
Trend analysis - Lecture Notes
Trend analysis - Lecture NotesTrend analysis - Lecture Notes
Trend analysis - Lecture Notes
 
Larson ch 4 Stats
Larson ch 4 StatsLarson ch 4 Stats
Larson ch 4 Stats
 

Destaque

Support vector regression and its application in trading
Support vector regression and its application in tradingSupport vector regression and its application in trading
Support vector regression and its application in trading
Aashay Harlalka
 
Simple Linier Regression
Simple Linier RegressionSimple Linier Regression
Simple Linier Regression
dessybudiyanti
 

Destaque (10)

Careers in botany
Careers in botanyCareers in botany
Careers in botany
 
Science
ScienceScience
Science
 
Tutorialgroups
TutorialgroupsTutorialgroups
Tutorialgroups
 
Application of Regression Analysis: Model Building and Validation
Application of Regression Analysis: Model Building and Validation  Application of Regression Analysis: Model Building and Validation
Application of Regression Analysis: Model Building and Validation
 
Support vector regression and its application in trading
Support vector regression and its application in tradingSupport vector regression and its application in trading
Support vector regression and its application in trading
 
SPSS statistics - get help using SPSS
SPSS statistics - get help using SPSSSPSS statistics - get help using SPSS
SPSS statistics - get help using SPSS
 
Multiple Regression Analysis
Multiple Regression AnalysisMultiple Regression Analysis
Multiple Regression Analysis
 
Simple Linier Regression
Simple Linier RegressionSimple Linier Regression
Simple Linier Regression
 
Role of Statistics in Scientific Research
Role of Statistics in Scientific ResearchRole of Statistics in Scientific Research
Role of Statistics in Scientific Research
 
Multiple linear regression
Multiple linear regressionMultiple linear regression
Multiple linear regression
 

Semelhante a The linear regression model: Theory and Application

Regression analysis ppt
Regression analysis pptRegression analysis ppt
Regression analysis ppt
Elkana Rorio
 

Semelhante a The linear regression model: Theory and Application (20)

Talk 4
Talk 4Talk 4
Talk 4
 
REGRESSION ANALYSIS THEORY EXPLAINED HERE
REGRESSION ANALYSIS THEORY EXPLAINED HEREREGRESSION ANALYSIS THEORY EXPLAINED HERE
REGRESSION ANALYSIS THEORY EXPLAINED HERE
 
ML-UNIT-IV complete notes download here
ML-UNIT-IV  complete notes download hereML-UNIT-IV  complete notes download here
ML-UNIT-IV complete notes download here
 
Chapter 14 Part I
Chapter 14 Part IChapter 14 Part I
Chapter 14 Part I
 
Reg
RegReg
Reg
 
Multivariate reg analysis
Multivariate reg analysisMultivariate reg analysis
Multivariate reg analysis
 
Linear regression analysis
Linear regression analysisLinear regression analysis
Linear regression analysis
 
Chapter 14 Part Ii
Chapter 14 Part IiChapter 14 Part Ii
Chapter 14 Part Ii
 
Regression
RegressionRegression
Regression
 
Regression analysis ppt
Regression analysis pptRegression analysis ppt
Regression analysis ppt
 
Get Multiple Regression Assignment Help
Get Multiple Regression Assignment Help Get Multiple Regression Assignment Help
Get Multiple Regression Assignment Help
 
regression analysis .ppt
regression analysis .pptregression analysis .ppt
regression analysis .ppt
 
Simple Linear Regression.pptx
Simple Linear Regression.pptxSimple Linear Regression.pptx
Simple Linear Regression.pptx
 
Regression
RegressionRegression
Regression
 
Simple egression.pptx
Simple egression.pptxSimple egression.pptx
Simple egression.pptx
 
Stat 1163 -correlation and regression
Stat 1163 -correlation and regressionStat 1163 -correlation and regression
Stat 1163 -correlation and regression
 
Corr And Regress
Corr And RegressCorr And Regress
Corr And Regress
 
SimpleLinearRegressionAnalysisWithExamples.ppt
SimpleLinearRegressionAnalysisWithExamples.pptSimpleLinearRegressionAnalysisWithExamples.ppt
SimpleLinearRegressionAnalysisWithExamples.ppt
 
Linear regression.ppt
Linear regression.pptLinear regression.ppt
Linear regression.ppt
 
lecture13.ppt
lecture13.pptlecture13.ppt
lecture13.ppt
 

Mais de University of Salerno

Poster venezia
Poster veneziaPoster venezia
Poster venezia
University of Salerno
 
Metulini280818 iasi
Metulini280818 iasiMetulini280818 iasi
Metulini280818 iasi
University of Salerno
 
Metulini1503
Metulini1503Metulini1503
Metulini1503
University of Salerno
 
The Water Suitcase of Migrants: Assessing Virtual Water Fluxes Associated to ...
The Water Suitcase of Migrants: Assessing Virtual Water Fluxes Associated to ...The Water Suitcase of Migrants: Assessing Virtual Water Fluxes Associated to ...
The Water Suitcase of Migrants: Assessing Virtual Water Fluxes Associated to ...
University of Salerno
 

Mais de University of Salerno (20)

Modelling traffic flows with gravity models and mobile phone large data
Modelling traffic flows with gravity models and mobile phone large dataModelling traffic flows with gravity models and mobile phone large data
Modelling traffic flows with gravity models and mobile phone large data
 
Regression models for panel data
Regression models for panel dataRegression models for panel data
Regression models for panel data
 
Carpita metulini 111220_dssr_bari_version2
Carpita metulini 111220_dssr_bari_version2Carpita metulini 111220_dssr_bari_version2
Carpita metulini 111220_dssr_bari_version2
 
A strategy for the matching of mobile phone signals with census data
A strategy for the matching of mobile phone signals with census dataA strategy for the matching of mobile phone signals with census data
A strategy for the matching of mobile phone signals with census data
 
Detecting and classifying moments in basketball matches using sensor tracked ...
Detecting and classifying moments in basketball matches using sensor tracked ...Detecting and classifying moments in basketball matches using sensor tracked ...
Detecting and classifying moments in basketball matches using sensor tracked ...
 
BASKETBALL SPATIAL PERFORMANCE INDICATORS
BASKETBALL SPATIAL PERFORMANCE INDICATORSBASKETBALL SPATIAL PERFORMANCE INDICATORS
BASKETBALL SPATIAL PERFORMANCE INDICATORS
 
Human activity spatio-temporal indicators using mobile phone data
Human activity spatio-temporal indicators using mobile phone dataHuman activity spatio-temporal indicators using mobile phone data
Human activity spatio-temporal indicators using mobile phone data
 
Poster venezia
Poster veneziaPoster venezia
Poster venezia
 
Metulini280818 iasi
Metulini280818 iasiMetulini280818 iasi
Metulini280818 iasi
 
Players Movements and Team Performance
Players Movements and Team PerformancePlayers Movements and Team Performance
Players Movements and Team Performance
 
Big Data Analytics for Smart Cities
Big Data Analytics for Smart CitiesBig Data Analytics for Smart Cities
Big Data Analytics for Smart Cities
 
Meeting progetto ode_sm_rm
Meeting progetto ode_sm_rmMeeting progetto ode_sm_rm
Meeting progetto ode_sm_rm
 
Metulini, R., Manisera, M., Zuccolotto, P. (2017), Sensor Analytics in Basket...
Metulini, R., Manisera, M., Zuccolotto, P. (2017), Sensor Analytics in Basket...Metulini, R., Manisera, M., Zuccolotto, P. (2017), Sensor Analytics in Basket...
Metulini, R., Manisera, M., Zuccolotto, P. (2017), Sensor Analytics in Basket...
 
Metulini, R., Manisera, M., Zuccolotto, P. (2017), Space-Time Analysis of Mov...
Metulini, R., Manisera, M., Zuccolotto, P. (2017), Space-Time Analysis of Mov...Metulini, R., Manisera, M., Zuccolotto, P. (2017), Space-Time Analysis of Mov...
Metulini, R., Manisera, M., Zuccolotto, P. (2017), Space-Time Analysis of Mov...
 
Metulini1503
Metulini1503Metulini1503
Metulini1503
 
A Spatial Filtering Zero-Inflated approach to the estimation of the Gravity M...
A Spatial Filtering Zero-Inflated approach to the estimation of the Gravity M...A Spatial Filtering Zero-Inflated approach to the estimation of the Gravity M...
A Spatial Filtering Zero-Inflated approach to the estimation of the Gravity M...
 
The Water Suitcase of Migrants: Assessing Virtual Water Fluxes Associated to ...
The Water Suitcase of Migrants: Assessing Virtual Water Fluxes Associated to ...The Water Suitcase of Migrants: Assessing Virtual Water Fluxes Associated to ...
The Water Suitcase of Migrants: Assessing Virtual Water Fluxes Associated to ...
 
The Global Virtual Water Network
The Global Virtual Water NetworkThe Global Virtual Water Network
The Global Virtual Water Network
 
The Worldwide Network of Virtual Water with Kriskogram
The Worldwide Network of Virtual Water with KriskogramThe Worldwide Network of Virtual Water with Kriskogram
The Worldwide Network of Virtual Water with Kriskogram
 
Ad b 1702_metu_v2
Ad b 1702_metu_v2Ad b 1702_metu_v2
Ad b 1702_metu_v2
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 

Último (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 

The linear regression model: Theory and Application

  • 1. Statistics Lab Rodolfo Metulini IMT Institute for Advanced Studies, Lucca, Italy Lesson 4 - The linear Regression Model: Theory and Application - 21.01.2014
  • 2. Introduction In the past praticals we analyzed one variable. For certain reasons, it is even usefull to analyze two or more variables together. The question we want to asnwer regards what are the relations, the causal effects determining changes in a variable. Analyze if a certain phenomenon is endogenous or exogenous. In symbols, the idea can be represent as follow: y = f (x1 , x2 , ...) Y is the response, which is a function (it depends on) one or more variables.
  • 3. Objectives All in all, the regression model is the instrument used to: measure the entity of the relations between two or more variables: Y / X , and to measure the causal direction ( X −→ viceversa? ) Y or forecast the value of the variable Y in response to some changes in the others X1 , X2 , ... (called explanatories), or for some cases that are not considered in the sample.
  • 4. Simple linear regression model The regression model is stochastic, not deterministic. Giving two sets of values (two variables) from a random sample of length n: x = {x1 , x2 , ..., xi , ..xn }; y = {y1 , y2 , ..., yi , ..yn }: Deterministic formula: yi = β0 + β1 xi , ∀i = 1, .., n Stochastic formula: yi = β0 + β1 xi + where i i ∀i = 1, .., n is the stochastic component. β1 define the slope in the relations between X and Y (See graph in chart 1)
  • 5. Simple linear regression model - 2 ˆ ˆ ˆ We need to find β = {β0 , β1 } as estimators of β0 and β1 . After β is estimated, we can draw the estimated regression line, which corresponds to the estimated regression model, as follow: ˆ ˆ yi = β0 + β1 xi ˆ Here, ˆi = yi − yi . ˆ Where yi is the i-element of the estimated Y vector, and yi is the ˆ i-elements of the real Y vector. (see graph in chart 2)
  • 6. Steps in the Analysis 1. Study the relations (scatterplot, correlations) between two or more variables. ˆ ˆ ˆ 2. Estimation of the parameters of the model β = {β0 , β1 }. ˆ 3. Hypotesis tests on the estimated β1 to verify the casual effects between X and Y 4. Robustness check of the model. 5. Use the model to analyze the causal effect and/or to do forecasting.
  • 7. Why linear? It is simple to estimate, to analyze and to interpret it likely fits with most of empirical cases, in which the relations between two phenomenon is linear. There are a lot of implemented methods to transorm variables in order to obtain a linear relationship (log transformation, normalization, etc.. )
  • 8. Model Hypotesis In order the estimation and the utilization of the model to be correct, certain hypotesis must hold: E ( i ) = 0, ∀i −→ E (yi ) = β0 + β1 xi Omoschedasticity: V ( i ) = σi2 = σ 2 , ∀i Null covariance: Cov ( i , j ) = 0, ∀i = j Null covariance among residuals and explanatories: Cov (xi , i ) = 0, ∀i, since X is deterministic (known) Normal assumption: i ∼ N(0, σ 2 )
  • 9. Model Hypotesis - 2 From the hypotesis above, follow that: V (yi ) = σ 2 , ∀i. Y is stochastic only for the component. Cov (yi , yj ) = 0, ∀i = j. Since the residuals are uncorrelated. yi ∼ N[(β0 + β1 x1 ), σ 2 ] Since also the residuals are normal in shape.
  • 10. Ordinary Least Squares (OLS) Estimation The OLS is the estimation method used to estimate the vector β. The idea is to minimize the value of the residuals. Since ei = yi − yi we are interested in minimize the component ˆ ˆ ˆ yi − β0 − β1 xi . N.B. i ˆ ˆ = β0 − β1 xi , while ei = β0 − β1 xi The method consist in minimize the sum of the square differences: n i (yi − yi )2 = ˆ n 2 i ei = Min, which is equal to solve this 2 equation system derived using derivates.
  • 11. Ordinary Least Squares (OLS) Estimation - 2 n ei2 = 0 (1) ei2 = 0 δ/δβ0 (2) i n δ/δβ1 i After some arithmetics, we end up with this estimators for the vector β: β0 = y − β1 x ¯ ˆ ¯ n ¯ ¯ i (yi − y )(xi − x ) β1 = n 2 ¯ i (xi − x ) (3) (4)
  • 12. OLS estimators ˆ ˆ OLS β0 and β1 are stochastic estimators (they have a distribution in a sample space of all the possible estimtors define with different samples) ˆ β1 : measure the estimated variation in Y determined by a unitary variation in X (δY /δX ) ˆ The OLS estimators are correct (E (β1 ) = β1 ), and they are BLUE (corrects and with the lowest variance)
  • 13. Linear dependency index (R 2 ) The R 2 index is the most used index to measure the linear fitting of the model. R 2 is confined in the boundary [−1, 1], where, values near to 1 (or -1) means the explanatories are usefull to describe the changes in Y. Let define SQT = SQR + SQE , or n i (yi − y )2 = ¯ n y i (ˆi The R 2 is defined as R2 = n y y 2 i (ˆi −¯) n y 2 i (yi −¯) − y )2 + ¯ SQR SQT or 1 − n i (yi − y i )2 ˆ SQE SQT . Or, equivalent:
  • 14. Hypotesis testing on β1 The estimated slope parameter β1 is stochastic. It distributes as a gaussian: ˆ β1 ∼ N[β1 , σ 2 /SSx] We can make use of the hypotesis tests approach to investigate on the causal relation between Y and X : H0 : β1 = 0 H1 : β1 = 0, where, alternative hypotesis mean causal relation. The test is: z= ˆ β1 −β1 sqrt(σ 2 /SSx) ∼ N(0, 1). When SSx is unknown, we estimate it as : SSx = and we use t − test with n − 1 degrees of freedom n i (xi − y )2 , ¯
  • 15. Forecasting within the regresion model The question we want to answer is the following: Which is the expected value of Y (say yn+1 ), for a certain observation that is not in the sample?. Suppose we have, for that observation, the value for the variable X (say xn+1 ) We make use of the estimated β to determine: ˆ ˆ yn+1 = β0 + β1 xn+1 ˆ
  • 16. Model Checking Several methods are used to test the robustness of the model, most of them based on the stochastic part of the the model: the estimated residuals. Graphical checks: Plot residuals versus fitted values qq-plot for the normality Shapiro wilk test for normality Durbin-Watson test for serial correlation Breusch-Pagan test for heteroschedasticity Moreover, the leverage is used to evaluate th importance of each observation in determining the estimated coefficients β. The Stepwise procedure is used to choice between different model specifications.
  • 17. Model Checking using estimated residuals - Linearity An example of departure from the linearity assumption: we can draw a curve (not a horizontal line) to interpolate the points Figure: residuals (Y) versus estimated (X) values
  • 18. Model Checking using estimated residuals Omoscedasticity An example of departure from the omoschedasticity assumption (the estimated residuals increases as the predicted values increase)
  • 19. Model Checking using estimated residuals - Normality An example of departure from the normality assumption: the qq-points do not follow the qq-line Figure: residuals (Y) versus estimated (X) values
  • 20. Model Checking using estimated residuals - Serial correlation An example of departure from the serial incorrelation assumption: the residual at i depend on the value at i − 1
  • 21. Homeworks 1. Using cement data (n = 13), determine the β0 and β1 coefficients manually, using OLS formula at page 11, of the model y = β0 + β1 x1 2. Using cement data, estimate the R 2 index of the model y = β0 + β1 x1 , using formula at page 13.
  • 22. Charts - 1 Figure: Slope coefficient in the linear model
  • 23. Charts - 2 Figure: Fitted (line) versus real (points) values