Download presentation
Presentation is loading. Please wait.
1
Simple Linear Regression
Dr. Mohammed Alahmed Dr. Mohammed Alahmed (011)
2
Simple Regression Simple regression analysis is a statistical tool that gives us the ability to estimate the mathematical relationship between a dependent variable (usually called y) and an independent variable (usually called x). The dependent variable is the variable for which we want to make a prediction. While various non-linear forms may be used, simple linear regression models are the most common. Dr. Mohammed Alahmed
3
Introduction The primary goal of quantitative analysis is to use current information about a phenomenon to predict its future behavior. Current information is usually in the form of a set of data. In a simple case, when the data form a set of pairs of numbers, we may interpret them as representing the observed values of an independent (or predictor ) variable X and a dependent ( or response) variable Y. Dr. Mohammed Alahmed In the table on the right the response variable Y represents the man-hours of labor for manufacturing a certain product in lots (X) that vary in size as demand fluctuates.
4
Introduction The goal of the analyst who studies the data is to find a functional relation between the response variable y and the predictor variable x. Dr. Mohammed Alahmed The data in this example concerns 10 recent production runs of a spare part manufactured by the Westwood company. Notice that for some values of X (X=30 and X=60) there correspond more than one value of Y. This is not an ordinary functional relationship between X and Y, where to each value of X a unique value of Y must correspond. Question: What is a plausible way of thinking about this situation that would still lead to a model y=F(X) in which we would have a unique value y for each value of X?
5
Regression Function The statement that the relation between X and Y is statistical should be interpreted as providing the following guidelines: 1. Regard Y as a random variable. 2. For each X, take f (x) to be the expected value (i.e., mean value) of y. 3. Given that E (Y) denotes the expected value of Y, call the equation the regression function. Dr. Mohammed Alahmed The idea behind this is: when we have several values of y observed for one value of X we take the average of these values of y to assign to x. This underlying idea is refined and made sophisticated by what we call the theory of regression. According to this theory, we should 1. Decide what distribution y has (often taken to be normal) 2.decide what form F(x) has ( here we have taken it to be a line. And then we use the data to estimate the parameters of our line in such a way that the expectation of Y-f(x) is minimized.
6
Pictorial Presentation of Linear Regression Model
Dr. Mohammed Alahmed The number of man-hours Y is treated in a regression model as a random variable. For each lot size, there is postulated a probability distribution of Y. This figure shows a probability distribution for X= 30, X=50, and X=70. The actual number of man-hours Y is then viewed as a random selection from this probability distribution. The means of the probability distributions have a systematic relation to the level of X. This systematic relationship is called the regression function of Y on X. The graph of regression function is called regression curve. In this figure the regression function is linear. This implies that the mean number of man-hours varies linearly with lot size.
7
Historical Origin of Regression
Regression Analysis was first developed by Sir Francis Galton, who studied the relation between heights of sons and fathers. Heights of sons of both tall and short fathers appeared to “revert” or “regress” to the mean of the group. Dr. Mohammed Alahmed 1. In the latter part of 19th century He considered this tendency to be a regression to “mediocrity. He developed a mathematical description of this regression tendency. Galton’s Model is the precursor of today’s regression models.
8
Construction of Regression Models
Selection of independent variables Since reality must be reduced to manageable proportions whenever we construct models, only a limited number of independent or predictor variables can or should be included in a regression model. Therefore a central problem is that of choosing the most important predictor variables. Functional form of regression relation Sometimes, relevant theory may indicate the appropriate functional form. More frequently, however, the functional form is not known in advance and must be decided once the data have been collected and analyzed. Scope of model In formulating a regression model, we usually need to restrict the coverage of model to some interval or region of values of the independent variables. Dr. Mohammed Alahmed Since reality must be reduced to manageable proportions whenever we construct models, only a limited number of independent or predictor variables can or should be included in a regression model. Therefore a central problem is that of choosing the most important predictor variables. The major considerations are: 1. The extent to which a chosen variable contributes to reducing the remaining variation in Y after allowance is made for the contributions of other variables that have tentatively been included in the model. 2. The importance of the variable as a causal agent in the process under analysis 3. The degree to which the observations on the variable can be obtained more accurately, quickly, or economically. Sometimes, relevant theory may indicate the appropriate functional form. More frequently, however, the functional form is not known in advance and must be decided once the data have been collected and analyzed. In formulating a regression model, we usually need to restrict the coverage of model to some interval or region of values of the independent variables. The scope is determined either by design of the investigation or by the range of data at hand. For example, a company studying the effect of price on sales volume investigated six price levels, ranging from $4.95 to $6.95. Here the scope of the model would be limited to price levels ranging from near $5 to near $7.
9
Uses of Regression Analysis
Regression analysis serves 3 major purposes: Description Control Prediction The several purposes of regression analysis frequently overlap in practice Dr. Mohammed Alahmed In the study of branch office operating costs, the purpose was administrative control; by developing a usable statistical relation between costs and independent variable s in the system, management was able to set cost standard for each branch office in the company chain. The west wood Company lot size example, the knowledge of the relation between lot size and man-hours in past production runs enables management to predict the man-hours for the next production run of a given lot size, for purposes of cost estimation and production scheduling. After the run is completed, management can compare the actual man-hours against the predicted hours for purposes of administrative control
10
Formal Statement of the Model
General regression model: 0, and 1 are parameters X is a known constant Deviations are independent N(o, 2) Dr. Mohammed Alahmed
11
Meaning of Regression Coefficients
The values of the regression parameters 0, and 1 are not known. We estimate them from data. 0 indicates the intercept of Y. 1 indicates the change in the mean response per unit increase in X. Dr. Mohammed Alahmed
12
Regression Line If the scatter plot of our sample data suggests a linear relationship between two variables i.e. we can summarize the relationship by drawing a straight line on the plot. Least squares method give us the “best” estimated line for our set of sample data. Dr. Mohammed Alahmed
13
Regression Line We will write an estimated regression line based on sample data as The method of least squares chooses the values for b0 and b1 to minimize the sum of squared errors Dr. Mohammed Alahmed
14
Regression Line Using calculus, we obtain estimating formulas: or
Dr. Mohammed Alahmed
15
Estimation of Mean Response
Fitted regression line can be used to estimate the mean value of y for a given value of x. Example The weekly advertising expenditure (x) and weekly sales (y) are presented in the following table. Dr. Mohammed Alahmed
16
Point Estimation of Mean Response
From previous table we have: The least squares estimates of the regression coefficients are: Dr. Mohammed Alahmed
17
Point Estimation of Mean Response
The estimated regression function is: This means that if the weekly advertising expenditure is increased by $1 we would expect the weekly sales to increase by $10.8. Dr. Mohammed Alahmed
18
Point Estimation of Mean Response
Fitted values for the sample data are obtained by substituting the x value into the estimated regression function. For example if the advertising expenditure is $50, then the estimated Sales is: This is called the point estimate (forecast) of the mean response (sales). Dr. Mohammed Alahmed
19
Example: Retail sales and floor space
It is customary in retail operations to asses the performance of stores partly in terms of their annual sales relative to their floor area (square feet). We might expect sales to increase linearly as stores get larger, with of course individual variation among stores of the same size. The regression model for a population of stores says that SALES = 0 + 1 AREA + Dr. Mohammed Alahmed
20
Example: Retail sales and floor space
The slope 1 is as usual a rate of change: it is the expected increase in annual sales associated with each additional square foot of floor space. The intercept 0 is needed to describe the line but has no statistical importance because no stores have area close to zero. Floor space does not completely determine sales. The term in the model accounts for difference among individual stores with the same floor space. A store’s location, for example, is important. Dr. Mohammed Alahmed
21
Residual The difference between the observed value yi and the corresponding fitted value Residuals are highly useful for studying whether a given regression model is appropriate for the data at hand. Dr. Mohammed Alahmed
22
Example: weekly advertising expenditure
Dr. Mohammed Alahmed
23
Estimation of the variance of the error terms, 2
The variance 2 of the error terms i in the regression model needs to be estimated for a variety of purposes. It gives an indication of the variability of the probability distributions of y. It is needed for making inference concerning regression function and the prediction of y. Dr. Mohammed Alahmed
24
Regression Standard Error
To estimate we work with the variance and take the square root to obtain the standard deviation. For simple linear regression the estimate of 2 is the average squared residual. To estimate , use s estimates the standard deviation of the error term in the statistical model for simple linear regression. Dr. Mohammed Alahmed
25
Regression Standard Error
Dr. Mohammed Alahmed
26
Basic Assumptions of a Regression Model
A regression model is based on the following assumptions: There is a probability distribution of Y for each level of X. Given that µy is the mean value of Y, the standard form of the model is where is a random variable with a normal distribution with mean 0 and standard deviation . Dr. Mohammed Alahmed
27
Conditions for Regression Inference
You can fit a least-squares line to any set of explanatory-response data when both variables are quantitative. If the scatter plot doesn’t show an approximately linear pattern, the fitted line may be almost useless. Dr. Mohammed Alahmed
28
Conditions for Regression Inference
The simple linear regression model, which is the basis for inference, imposes several conditions. We should verify these conditions before proceeding with inference. The conditions concern the population, but we can observe only our sample. Dr. Mohammed Alahmed
29
Conditions for Regression Inference
In doing Inference, we assume: The sample is an SRS from the population. There is a linear relationship in the population. We can not observe the population , so we check the scatter plot of the sample data. The standard deviation of the responses about the population line is the same for all values of the explanatory variable. The spread of observations above and below the least-squares line should be roughly uniform as x varies. Dr. Mohammed Alahmed
30
Conditions for Regression Inference
Plotting the residuals against the explanatory variable is helpful in checking these conditions because a residual plot magnifies patterns. Dr. Mohammed Alahmed
31
Analysis of Residual To examine whether the regression model is appropriate for the data being analyzed, we can check the residual plots. Residual plots are: Plot a histogram of the residuals Plot residuals against the fitted values. Plot residuals against the independent variable. Plot residuals over time if the data are chronological. Dr. Mohammed Alahmed
32
Analysis of Residual A histogram of the residuals provides a check on the normality assumption. A Normal quantile plot of the residuals can also be used to check the Normality assumptions. Regression Inference is robust against moderate lack of Normality. On the other hand, outliers and influential observations can invalidate the results of inference for regression Dr. Mohammed Alahmed
33
Analysis of Residual Plot of residuals against fitted values or the independent variable can be used to check the assumption of constant variance and the aptness of the model. Plot of residuals against time provides a check on the independence of the error terms assumption. Assumption of independence is the most critical one. Dr. Mohammed Alahmed
34
Residual plots The residuals should have no systematic pattern.
The residual plot to right shows a scatter of the points with no individual observations or systematic change as x increases. Dr. Mohammed Alahmed
35
Residual plots The points in this residual plot have a curve pattern, so a straight line fits poorly Dr. Mohammed Alahmed
36
Residual plots The points in this plot show more spread for larger values of the explanatory variable x, so prediction will be less accurate when x is large. Dr. Mohammed Alahmed
37
Variable transformations
If the residual plot suggests that the variance is not constant, a transformation can be used to stabilize the variance. If the residual plot suggests a non linear relationship between x and y, a transformation may reduce it to one that is approximately linear. Common linearizing transformations are: Variance stabilizing transformations are: Dr. Mohammed Alahmed
38
Inference about the Regression Model
When a scatter plot shows a linear relationship between a quantitative explanatory variable x and a quantitative response variable y, we can use the least square line fitted to the data to predict y for a give value of x. Now we want to do tests and confidence intervals in this setting. Dr. Mohammed Alahmed
39
Inference about the Regression Model
We think of the least square line we calculated from a sample as an estimate of a regression line for the population. Just as the sample mean is an estimate of the population mean µ. Dr. Mohammed Alahmed
40
Inference about the Regression Model
We will write the population regression line as The numbers and are parameters that describe the population. We will write the least-squares line fitted to sample data as This notation reminds us that the intercept b0 of the fitted line estimates the intercept 0 of the population line, and the slope b1 estimates the slope 1 . Dr. Mohammed Alahmed
41
Confidence Intervals and Significance Tests
In our previous lectures we presented confidence intervals and significance tests for means and differences in means. In each case, inference rested on the standard error s of the estimates and on t or z distributions. Inference for the slope and intercept in linear regression is similar in principal, although the recipes are more complicated. All confidence intervals, for example , have the form estimate t* Seestimate t* is a critical value of a t distribution. Dr. Mohammed Alahmed
42
Confidence Intervals and Significance Tests
Confidence intervals and tests for the slope and intercept are based on the sampling distributions of the estimates b1 and b0. Here are the facts: If the simple linear regression model is true, each of b0 and b1 has a Normal distribution. The mean of b0 is 0 and the mean of b1 is 1. That is, the intercept and slope of the fitted line are unbiased estimators of the intercept and slope of the population regression line. Dr. Mohammed Alahmed
43
Confidence Intervals and Significance Tests
The standard deviations of b0 and b1 are multiples of the model standard deviation . Dr. Mohammed Alahmed
44
Confidence Intervals and Significance Tests
Dr. Mohammed Alahmed
45
Example: Weekly Advertising Expenditure
Let us return to the Weekly advertising expenditure and weekly sales example. Management is interested in testing whether or not there is a linear association between advertising expenditure and weekly sales, using regression model. Use = .05 Dr. Mohammed Alahmed
46
Example: Weekly Advertising Expenditure
Hypothesis: Decision Rule: Reject H0 if or Dr. Mohammed Alahmed
47
Example: Weekly Advertising Expenditure
Test statistic: Dr. Mohammed Alahmed
48
Example: Weekly Advertising Expenditure
Conclusion: Since t =4.5 > then we reject H0. There is a linear association between advertising expenditure and weekly sales. Dr. Mohammed Alahmed
49
Confidence interval for 1
Now that our test showed that there is a linear association between advertising expenditure and weekly sales, the management wishes an estimate of 1 with a 95% confidence coefficient. Dr. Mohammed Alahmed
50
Confidence interval for 1
For a 95 percent confidence coefficient, we require t (.025; 8). From table B in appendix III, we find t(.025; 8) = The 95% confidence interval is: Dr. Mohammed Alahmed
51
Example: Do wages rise with experience?
Many factors affect the wages of workers: the industry they work in, their type of job, their education and their experience, and changes in general levels of wages. We will look at a sample of 59 married women who hold customer service jobs in Indiana banks. The following table gives their weekly wages at a specific point in time also their length of service with their employer, in month. The size of the place of work is recorded simply as “large” (100 or more workers) or “small.” Because industry, job type, and the time of measurement are the same for all 59 subjects, we expect to see a clear relationship between wages and length of service. Dr. Mohammed Alahmed
52
Example: Do wages rise with experience?
Dr. Mohammed Alahmed
53
Example: Do wages rise with experience?
Dr. Mohammed Alahmed
54
Example: Do wages rise with experience?
From previous table we have: The least squares estimates of the regression coefficients are: Dr. Mohammed Alahmed
55
Example: Do wages rise with experience?
What is the least-squares regression line for predicting Wages from Los? Suppose a woman has been with her bank for 125 months. What do you predict she will earn? If her actual wages are $433, then what is her residual? The sum of squared residuals for the entire sample is Dr. Mohammed Alahmed
56
Example: Do wages rise with experience?
The hypotheses are: H0: 1 = 0, Ha: 1 > 0 The test statistics The P- value is: Conclusion: Dr. Mohammed Alahmed
57
Example: Do wages rise with experience?
A 95% confidence interval for the average increase in wages per month of stay for the regression line in the population of all married female customer service workers in Indiana bank is The t distribution for this problem has n-2 = 57 degrees of freedom Dr. Mohammed Alahmed
58
Example: Do wages rise with experience?
Regression calculations in Practice are always done by software. The computer out put for the case study is given in the following slide. Dr. Mohammed Alahmed
59
Example: Do wages rise with experience?
Dr. Mohammed Alahmed
60
Using the regression Line
One of the most common reasons to fit a line to data is to predict the response to a particular value of the explanatory variable. In our example, the least square line for predicting the weekly earnings for female bank customer service workers from their length of service is Dr. Mohammed Alahmed
61
Using the regression Line
For a length of service of 125 months, our least-squares regression equation gives There are two different uses of this prediction. We can estimate the mean earnings of all workers in the subpopulation of workers with 125 months on the job. We can predict the earnings of one individual worker with 125 months of service. Dr. Mohammed Alahmed
62
Using the regression Line
For each use, the actual prediction is the same, but the margin of error is different for the two cases. To estimate the mean response, we use a confidence interval. To estimate an individual response y, we use prediction interval. A prediction interval estimates a single random response y rather than a parameter like µy Dr. Mohammed Alahmed
63
Using the regression Line
The main distinction is that it is harder to predict for an individual than for the mean of a population of individuals. Each interval has the usual form The margin of error for the prediction interval is wider than the margin of error for the confidence interval. Dr. Mohammed Alahmed
64
Using the regression Line
The standard error for estimating the mean response when the explanatory variable x takes the value x* is: Dr. Mohammed Alahmed
65
Using the regression Line
The standard error for predicting an individual response when the explanatory variable x takes the value x* is: Dr. Mohammed Alahmed
66
Prediction of a new response ( )
We now consider the prediction of a new observation y corresponding to a given level x of the independent variable. In our advertising expenditure and weekly sales, the management wishes to predict the weekly sales corresponding to the advertising expenditure of x = $50. Dr. Mohammed Alahmed
67
Interval Estimation of a new response ( )
The following formula gives us the point estimator (forecast) for y. 1- % prediction interval for a new observation is: Where Dr. Mohammed Alahmed
68
Example In our advertising expenditure and weekly sales, the management wishes to predict the weekly sales if the advertising expenditure is $50 with a 90 % prediction interval. We require t(.05; 8) = 1.860 Dr. Mohammed Alahmed
69
Example The 90% prediction interval is: Dr. Mohammed Alahmed
70
Analysis of variance approach to Regression analysis
Analysis of Variance is the term for statistical analyses that break down the variation in data into separate pieces that correspond to different sources of variation. It is based on the partitioning of sums of squares and degrees of freedom associated with the response variable. In the regression setting, the observed variation in the responses (yi) comes from two sources. Dr. Mohammed Alahmed
71
Analysis of variance approach to Regression analysis
Consider the weekly advertising expenditure and the weekly sales example. There is variation in the amount ($) of weekly sales, as in all statistical data. The variation of the yi is conventionally measured in terms of the deviations: Dr. Mohammed Alahmed
72
Analysis of variance approach to Regression analysis
The measure of total variation, denoted by SST, is the sum of the squared deviations: If SST = 0, all observations are the same(No variability). The greater is SST, the greater is the variation among the y values. When we use the regression model, the measure of variation is that of the y observations variability around the fitted line: Dr. Mohammed Alahmed
73
Analysis of variance approach to Regression analysis
The measure of variation in the data around the fitted regression line is the sum of squared deviations (error), denoted SSE: For our Weekly expenditure example SSE = SST = What accounts for the substantial difference between these two sums of squares? Dr. Mohammed Alahmed
74
Analysis of variance approach to Regression analysis
The difference is another sum of squares: SSR stands for regression sum of squares. SSR is the variation among the predicted responses The predicted responses lie on the least-square line. They show how y moves in response to x. The larger is SSR relative to SST, the greater is the role of regression line in explaining the total variability in y observations. Dr. Mohammed Alahmed
75
Analysis of variance approach to Regression analysis
In our example: This indicates that most of variability in weekly sales can be explained by the relation between the weekly advertising expenditure and the weekly sales. Dr. Mohammed Alahmed
76
Formal Development of the Partitioning
We can decompose the total variability in the observations yi as follows: The total deviation can be viewed as the sum of two components: The deviation of the fitted value around the mean The deviation of yi around the fitted regression line. Dr. Mohammed Alahmed
77
Formal Development of the Partitioning
Skipping quite a bit of messy algebra, we just state that this analysis of variance equation always holds: Breakdown of degree of freedom: Dr. Mohammed Alahmed
78
Mean squares A sum of squares divided by its degrees of freedom is called a mean square (MS) Regression mean square (MSR) Error mean square (MSE) Note: mean squares are not additive. Dr. Mohammed Alahmed
79
Mean squares In our example: Dr. Mohammed Alahmed
80
Analysis of Variance Table
The breakdowns of the total sum of squares and associated degrees of freedom are displayed in a table called analysis of variance table (ANOVA table) Source of Variation SS df MS F-Test Regression SSR 1 MSR =SSR/1 MSR/MSE Error SSE n-2 MSE =SSE/(n-2) Total SST n-1 Dr. Mohammed Alahmed
81
Analysis of Variance Table
In our weekly advertising expenditure and weekly sales example the ANOVA table is: Source of variation SS df MS Regression 1 Error 8 4515.6 Total 9 Dr. Mohammed Alahmed
82
Analysis of Variance Table
The Analysis of Variance table reports in a different way quantities such as r2 and s that are needed in regression analysis. It also reports in a different way the test for the overall significance of the regression. If regression on x has no value for predicting y, we expect the slope of the population regression line to be close to 0. Dr. Mohammed Alahmed
83
Analysis of Variance Table
That is the null hypothesis of “no linear relationship” is: We standardize the slope of the least-squares line to get a t statistic. Dr. Mohammed Alahmed
84
F-Test for 1= 0 versus 1 0
The analysis of variance approach starts with sums of squares. If regression on x has no value for predicting y, we expect the SSR to be only a small part of the SST, most of which will be made of the SSE. The proper way to standardize this comparison is to use the ratio Dr. Mohammed Alahmed
85
F-Test for 1= 0 versus 1 0
In order to be able to construct a statistical decision rule, we need to know the distribution of our test statistic F. When H0 is true, our test statistic, F, follows the F- distribution with 1, and n-2 degrees of freedom. Table C-5 on page 513 of your text gives the critical values of the F-distribution at = 0.05 and .01. Dr. Mohammed Alahmed
86
F-Test for 1= 0 versus 1 0
Construction of decision rule: At = 5% level Reject H0 if Large values of F support Ha and Values of F near 1 support H0. Dr. Mohammed Alahmed
87
F-Test for 1= 0 versus 1 0
Using our example again, let us repeat the earlier test on 1. This time we will use the F-test. The null and alternative hypothesis are: Let = Since n=10, we require F(.05; 1, 8). From table 5-3 we find that F(.05; 1, 8) = Therefore the decision rule is: Reject H0 if: Dr. Mohammed Alahmed
88
F-Test for 1= 0 versus 1 0
From ANOVA table we have MSR = MSE = Our test statistic F is: Decision: Since 20.47> 5.32, we reject H0, that is there is a linear association between weekly advertising expenditure and weekly sales. Dr. Mohammed Alahmed
89
F-Test for 1= 0 versus 1 0
Equivalence of F Test and t Test: For given level, the F test of 1 = 0 versus 1 0 is equivalent algebraically to the two sided t-test. Thus, at a given level, we can use either the t-test or the F-test for testing 1 = 0 versus 1 0. The t-test is more flexible since it can be used for one sided test as well. Dr. Mohammed Alahmed
90
Analysis of Variance Table
The complete ANOVA table for our example is: Source of Variation SS df MS F-Test Regression 1 20.47 Error 8 4515.6 Total 9 Dr. Mohammed Alahmed
91
Computer Output The EXCEL out put for our example is:
Dr. Mohammed Alahmed
92
Coefficient of Determination
Recall that SST measures the total variations in yi when no account of the independent variable x is taken. SSE measures the variation in the yi when a regression model with the independent variable x is used. A natural measure of the effect of x in reducing the variation in y can be defined as: Dr. Mohammed Alahmed
93
Coefficient of Determination
R2 is called the coefficient of determination. 0 SSE SST, it follows that: We may interpret R2 as the proportionate reduction of total variability in y associated with the use of the independent variable x. The larger is R2, the more is the total variation of y reduced by including the variable x in the model. Dr. Mohammed Alahmed
94
Coefficient of Determination
If all the observations fall on the fitted regression line, SSE = 0 and R2 = 1. If the slope of the fitted regression line b1 = 0 so that , SSE=SST and R2 = 0. The closer R2 is to 1, the greater is said to be the degree of linear association between x and y. The square root of R2 is called the coefficient of correlation. Dr. Mohammed Alahmed
95
Correlation Coefficient
Recall that the algebraic expression for the correlation coefficient is. Dr. Mohammed Alahmed
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.