regression analysis regression models

Click here to load reader

Post on 26-Feb-2022

1 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

RSH_10_Ch_04 [Compatibility Mode]Introduction
Regression analysisRegression analysis is a very valuable tool for a manager
There are generally two purposes for regression analysis
4 – 2
regression analysis 1. To understand the relationship between
variables E.g. the relationship between the sales volume
and the advertising spending amount, the relationship between the price of a house and the square footage, etc.
2. To predict the value of one variable based on the value of another variable
Introduction
4 – 3
Multiple regression models have more than two variables
Nonlinear regression models are used when the relationships between the variables are not linear
Introduction
The variable to be predicted is called the dependent variabledependent variable Sometimes called the response variableresponse variable
The value of this variable depends on the value of the independent variableindependent variable
4 – 4
the value of the independent variableindependent variable Sometimes called the explanatoryexplanatory or
predictor variablepredictor variable
Independent variable1
Dependent variable
Independent variable2= + + ...
Prediction Relationship
Scatter Diagram
One way to investigate the relationship between variables is by plotting the data on a graph
Such a graph is often called a scatter scatter diagramdiagram or a scatter plotscatter plot
4 – 5
diagramdiagram or a scatter plotscatter plot The independent variable is normally
plotted on the X axis The dependent variable is normally
plotted on the Y axis
Triple A Construction renovates old homes They have found that the dollar volume of
renovation work each year is dependent on the area payroll
Triple A’s revenues and the total wage earnings for the past six years are listed below
Triple A Construction Example
TRIPLE A’S SALES ($100,000’s)
LOCAL PAYROLL ($100,000,000’s)
6 3 8 4 9 6 5 4 4.5 2 9.5 5Table 4.1
dependentdependent variablevariable
independentindependent variablevariable
4 – 7
Figure 4.1: Scatter Diagram for Triple A Constructi on Company Data in Table 4.1
6 –
4 –
2 –
0 –
| | | | | | | | 0 1 2 3 4 5 6 7 8
The graph indicates higher payroll seem to result in higher sales
A line has been drawn to show the relationship between the payroll and the sales
There is not a perfect relationship because not
Triple A Construction Example
4 – 8
There is not a perfect relationship because not all points lie in a straight line
Errors are involved if this line is used to predict sales based on payroll
Many lines could be drawn through these points, but which one best represents the true relationship ?
Simple Linear Regression
Regression models are used to find the relationship between variables – i.e. to predict the value of one variable based on the other
4 – 9
However there is some random error that cannot be predicted
Regression models can also be used to test if a relationship exists between variables
Simple Linear Regression
εεεεββββββββ ++++++++==== XY 10
where Y = dependent variable (response) X = independent variable (predictor or
explanatory) ββββ0 = intercept (value of Y when X = 0) ββββ1 = slope of the regression line εεεε = random error
Simple Linear Regression
The random error cannot be predicted. So an approximation of the model is used
XbbY 10 ++++====ˆ
Y = predicted value of Y X = independent variable (predictor or
explanatory) b0 = estimate of ββββ0
b1 = estimate of ββββ1
Triple A Construction
Triple A Construction is trying to predict sales based on area payroll
Y = Sales X = Area payroll
4 – 12
X = Area payroll
The line chosen in Figure 4.1 is the one that best fits the sample data by minimizing the sum of all errors
Error = (Actual value) – (Predicted value)
YYe ˆ−−−−====
Triple A Construction
The errors may be positive or negative – large positive and negative errors may cancel each other – result in very small average error – thus errors are squared
Error 2 = [(Actual value) – (Predicted value)] 2
4 – 13
22 )Y(Ye ˆ−−−−====
The best regression line is defined as the one that minimize the sum of squared errors, i.e. the total distance between the actual data points and the line
Triple A Construction
For the simple linear regression model, the values of the intercept and slope can be calculated from n sample data using the formulas below
XbbY 10 ++++====ˆ
X X ======== ∑∑∑∑
Y Y ======== ∑∑∑∑
Y X (X – X)2 (X – X)(Y – Y)
6 3 (3 – 4)2 = 1 (3 – 4)(6 – 7) = 1 8 4 (4 – 4)2 = 0 (4 – 4)(8 – 7) = 0
Regression calculations
4 – 15
8 4 (4 – 4)2 = 0 (4 – 4)(8 – 7) = 0 9 6 (6 – 4)2 = 4 (6 – 4)(9 – 7) = 4 5 4 (4 – 4)2 = 0 (4 – 4)(5 – 7) = 0 4.5 2 (2 – 4)2 = 4 (2 – 4)(4.5 – 7) = 5
9.5 5 (5 – 4)2 = 1 (5 – 4)(9.5 – 7) = 2.5
ΣY = 42 Y = 42/6 = 7
ΣX = 24 X = 24/6 = 4
Σ(X – X)2 = 10 Σ(X – X)(Y – Y) = 12.5
Table 4.2
4 – 17
Measuring the Fit of the Regression Model
Regression models can be developed for any variables X and Y
How do we know the model is good enough (with small errors) in predicting Y based on X ?
4 – 18
describing the accuracy of the model Three measures of variability
SST – Total variability about the mean SSE – Variability about the regression line SSR – Total variability that is explained by the
model
Sum of the squared error
∑∑∑∑ ∑∑∑∑ −−−−======== 22 )ˆ( YYeSSE
∑∑∑∑ −−−−==== 2)ˆ( YYSSR
Y X (Y – Y)2 Y (Y – Y)2 (Y – Y)2
^ ^^
9 6 (9 – 7)2 = 4 2 + 1.25(6) = 9.50 0.25 6.25
5 4 (5 – 7)2 = 4 2 + 1.25(4) = 7.00 4 0
4.5 2 (4.5 – 7)2 = 6.25 2 + 1.25(2) = 4.50 0 6.25
9.5 5 (9.5 – 7)2 = 6.25 2 + 1.25(5) = 8.25 1.5625 1.563
∑(Y – Y)2 = 22.5 ∑(Y – Y)2 = 6.875 ∑(Y – Y)2 = 15.625
Y = 7 SST = 22.5 SSE = 6.875 SSR = 15.625
^^
Measuring the Fit of the Regression Model
SST = 22.5 is the variability of the prediction using mean value of Y
SSE = 6.875 is the variability of the prediction using regression line
Prediction using regression line has reduced the
4 – 21
Prediction using regression line has reduced the variability by 22.5 −−−− 6.875 = 15.625
SSR = 15.625 indicates how much of the total variability in Y is explained by the regression model
Note: SST = SSR + SSE SSR – explained variability SSE – unexplained variability
Measuring the Fit of the Regression Model
12 –
10 –
8 –
4 – 22
Figure 4.2
Coefficient of Determination
The proportion of the variability in Y explained by regression equation is called the coefficient of coefficient of determinationdetermination
The coefficient of determination is r2
SSESSR r −−−−======== 12
625152 . .
. ========r
About 69% of the variability in Y is explained by the equation based on payroll ( X)
If SSE 0, then r 2 100%
Correlation Coefficient
It will always be between +1 and –1
2rr ±±±±====
4 – 24
It will always be between +1 and –1 Negative slope r < 0; positive slope r > 0 The correlation coefficient is r For Triple A Construction
8333069440 .. ========r
Correlation Coefficient
X
X
Y
4 – 26
Program 4.1A
4 – 27
Program 4.1B
4 – 28
Program 4.1C
Correlation coefficient ( r) is Multiple R in Excel
4 – 29
1. Errors are independent 2. Errors are normally distributed
If we make certain assumptions about the errors in a regression model, we can perform statistical tests to determine if the model is useful
4 – 30
2. Errors are normally distributed 3. Errors have a mean of zero 4. Errors have a constant variance
A plot of the residuals (errors) will often highlig ht any glaring violations of the assumption
Residual Plots
4 – 31
Figure 4.4A
E rr
Nonconstant error variance – violation Errors increase as X increases, violating the
constant variance assumption
decreasing indicate that the model is not linear (perhaps quadratic)
4 – 33
Figure 4.4C
E rr
Estimating the Variance
Errors are assumed to have a constant variance ( σσσσ 2), but we usually don’t know this
It can be estimated using the mean mean squared errorsquared error (MSEMSE), s2
4 – 34
1 2
MSEs
where n = number of observations in the sample k = number of independent variables
Estimating the Variance
4 – 35
We can estimate the standard deviation, s This is also called the standard error of the standard error of the
estimateestimate or the standard deviation of the standard deviation of the regressionregression
31171881 .. ============ MSEs
A small s2 or s means the actual data deviate within a small range from the predicted result
Testing the Model for Significance
Both r2 and the MSE (s2) provide a measure of accuracy in a regression model
However when the sample size is too small, you can get good values for MSE and r2
even if there is no relationship between the
4 – 36
even if there is no relationship between the variables
Testing the model for significance helps determine if r2 and MSE are meaningful and if a linear relationship exists between the variables
We do this by performing a statistical hypothesis test
Testing the Model for Significance
We start with the general linear model
εεεεββββββββ ++++++++==== XY 10
If ββββ1 = 0, the null hypothesis is that there is nono relationship between X and Y
4 – 37
nono relationship between X and Y The alternate hypothesis is that there isis a
linear relationship ( ββββ1 ≠ 0) If the null hypothesis can be rejected, we
have proven there is a linear relationship We use the F statistic for this test
A continuous probability distribution (Fig. 2.15) The area underneath the curve represents
probability of the F statistic value falling within a particular interval.
The F statistic is the ratio of two sample variances
The F Distribution
4 – 38
The F statistic is the ratio of two sample variances F distributions have two sets of degrees of
freedom Degrees of freedom are based on sample size and
used to calculate the numerator and denominator
df1 = degrees of freedom for the numerator df2 = degrees of freedom for the denominator
The F Distribution
Consider the example:
4 – 39
Fαααα, df1, df2 = F0.05, 5, 6 = 4.39
This means
P(F > 4.39) = 0.05
There is only a 5% probability that F will exceed 4.39 (see Fig. 2.16)
The F Distribution
The F Distribution
F value for 0.05 probability with 5 and 6 degrees of freedom
4 – 41
Figure 2.16
F = 4.39
Testing the Model for Significance
The F statistic for testing the model is based on the MSE (s2) and mean squared regression ( MSR)
k SSR
MSR ==== where
4 – 42
The F statistic is
F ====
This describes an F distribution with degrees of freedom for the numerator = df1 = k degrees of freedom for the denominator = df2 = n – k – 1
Testing the Model for Significance
If there is very little error, the MSE would be small and the F-statistic would be large indicating the model is useful
If the F-statistic is large, the significance level ( p-value) will be low, indicating it is
4 – 43
level ( p-value) will be low, indicating it is unlikely this would have occurred by chance
So when the F-value is large, we can reject the null hypothesis and accept that there is a linear relationship between X and Y and the values of the MSE and r2 are meaningful
Steps in a Hypothesis Test
1. Specify null and alternative hypotheses 010 ====ββββ:H 011 ≠≠≠≠ββββ:H
2. Select the level of significance ( αααα). Common
4 – 44
2. Select the level of significance ( αααα). Common values are 0.01 and 0.05
3. Calculate the value of the test statistic using the formula
MSE MSR
Steps in a Hypothesis Test
4. Make a decision using one of the following methods a) Reject the null hypothesis if the test statistic is
greater than the FF--valuevalue from the table in Appendix D. Otherwise, do not reject the null hypothesis:
4 – 45
kdf ====1
12 −−−−−−−−==== kndf
b) Reject the null hypothesis if the observed signific ance level, or pp--value,value, is less than the level of significance (αααα). Otherwise, do not reject the null hypothesis:
)( statistictest calculatedvalue- >>>>==== FPp αααα<<<<value- ifReject p
Triple A Construction Step 1.Step 1.
H0: ββββ1 = 0 (no linear relationship between X and Y)
H1: ββββ1 ≠ 0 (linear relationship exists between X and Y)
Step 2.Step 2.
625015 1 625015
Step 3.Step 3. Calculate the value of the test statistic
Triple A Construction Step 4.Step 4.
Reject the null hypothesis if the test statistic is greater than the F-value in Appendix D
df1 = k = 1 df2 = n – k – 1 = 6 – 1 – 1 = 4
4 – 47
df2 = n – k – 1 = 6 – 1 – 1 = 4
The value of F associated with a 5% level of significance and with degrees of freedom 1 and 4 is found in Appendix D
F0.05,1,4 = 7.71 Fcalculated = 9.09 Reject H0 because 9.09 > 7.71
Triple A Construction
We can conclude there is a statistically significant relationship between X and Y
The r2 value of 0.69 means about 69% of the variability in
4 – 48
F = 7.71
9.09Figure 4.5
about 69% of the variability in sales ( Y) is explained by local payroll ( X)
Triple A Construction
The F-test determines whether or not there is a relationship between the variables
r2 (coefficient of determination) is the best measure of the strength of the prediction
4 – 49
measure of the strength of the prediction relationship between the X and Y variables Values closer to 1 indicate a strong prediction
relationship Good regression models have a low
significance level for the F-test and high r2
value.
Analysis of Variance (ANOVA) Table
When software is used to develop a regression model, an ANOVA table is typically created that shows the observed significance level ( p-value) for the calculated F value
This can be compared to the level of significance (αααα) to make a decision
4 – 50
Regression k SSR MSR = SSR/k MSR/MSE P(F > MSR/MSE)
Residual n - k - 1 SSE MSE = SSE/(n - k - 1)
Total n - 1 SST
4 – 51
Because this probability is less than 0.05, we reject the null hypothesis of no linear relationshi p and conclude there is a linear relationship between X and Y
Program 4.1D (partial)
P(F > 9.0909) = 0.0394
Multiple Regression Analysis
Multiple regression modelsMultiple regression models are extensions to the simple linear model and allow the creation of models with several independent variables
4 – 52
Y = dependent variable (response variable) Xi = ith independent variable (predictor or explanatory
variable) ββββ0 = intercept (value of Y when all Xi = 0) ββββI = coefficient of the ith independent variable k = number of independent variables εεεε = random error
Multiple Regression Analysis
To estimate these values, samples are taken and the following equation is developed
kk XbXbXbbY ++++++++++++++++==== ...ˆ 22110
where = predicted value of Y
b0 = sample intercept (and is an estimate of ββββ0) bi = sample coefficient of the ith variable (and is
an estimate of ββββi)
Jenny Wilson Realty
Jenny Wilson wants to develop a model to determine the suggested listing price for houses based on the size and age of the house
22110 ˆ XbXbbY ++++++++====
where = predicted value of dependent variable (selling pri ce)
b0 = Y intercept X1 and X2 = value of the two independent variables (square
footage and age) respectively b1 and b2 = slopes for X1 and X2 respectively
Y
She selects a few samples of the houses sold recently and records the data shown in Table 4.5
She also saves information on house condition to be used later
Jenny Wilson Realty SELLING PRICE ($)
SQUARE FOOTAGE AGE CONDITION
95,000 1,926 30 Good
119,000 2,069 40 Excellent
124,800 1,720 30 Excellent
135,000 1,396 15 Good
142,000 1,706 32 Mint
Jenny Wilson Realty
0021788.0
Evaluating Multiple Regression Models
Evaluation is similar to simple linear regression models The p-value for the F-test and r2 are
interpreted the same
4 – 57
The hypothesis is different because there is more than one independent variable The F-test is investigating whether all
the coefficients are equal to 0 If the F-test is significant, it does not
mean all independent variables are significant
Evaluating Multiple Regression Models
To determine which independent variables are significant, tests are performed for each variable
010 ====ββββ:H
4 – 58
010 ====ββββ:H 011 ≠≠≠≠ββββ:H
The test statistic is calculated and if the p-value is lower than the level of significance ( αααα), the null hypothesis is rejected
Jenny Wilson Realty
The model is statistically significant The p-value for the F-test is 0.002 r2 = 0.6719 so the model explains about 67% of
the variation in selling price ( Y) But the F-test is for the entire model and we can’t
4 – 59
But the F-test is for the entire model and we can’t tell if one or both of the independent variables ar e significant
By calculating the p-value of each variable, we can assess the significance of the individual variables
Since the p-value for X1 (square footage) and X2 (age) are both less than the significance level of 0.05, both null hypotheses can be rejected
Binary or Dummy Variables
BinaryBinary (or dummydummy or indicatorindicator) variables are special variables created for qualitative data
A binary variable is assigned a value of 1 if a particular qualitative condition is met and
4 – 60
a particular qualitative condition is met and a value of 0 otherwise
Adding binary variables may increase the accuracy of the regression model
The number of binary variables must be one less than the number of categories of the qualitative variable
Jenny Wilson Realty
Jenny believes a better model can be developed if she includes information about the condition of the property
X3 = 1 if house is in excellent condition = 0 otherwise
4 – 61
= 0 otherwise X4 = 1 if house is in mint (perfect) condition
= 0 otherwise
Two binary variables are used to describe the three categories of condition
No variable is needed for “good” condition since if both X3 = 0 and X4 = 0, the house must be in good condition
Jenny Wilson Realty
Model explains about 89.8% of the variation in selling price
F-value
4 – 64
Program 4.3 – The two additional dummy variables result in higher r2 and smaller significance value.
F-value indicates significance
Model Building
The best model is a statistically significant model with a high r2 and few variables
As more variables are added to the model, the r2-value usually increases However more variables does not
4 – 65
However more variables does not necessarily mean better model
For this reason, the adjusted adjusted rr22 value…