Simple Linear Regression Farideh DehkordiVakil Simple Regression n

  • Slides: 84
Download presentation
Simple Linear Regression Farideh Dehkordi-Vakil

Simple Linear Regression Farideh Dehkordi-Vakil

Simple Regression n Simple regression analysis is a statistical tool That gives us the

Simple Regression n 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.

Introduction • The primary goal of quantitative analysis is to use current information about

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.

Introduction n The goal of the analyst who studies the data is to find

Introduction n 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.

Regression Function The statement that the relation between X and Y is statistical should

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 n the regression function.

Historical Origin of Regression n n Regression Analysis was first developed by Sir Francis

Historical Origin of Regression n n 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.

Historical Origin of Regression

Historical Origin of Regression

Basic Assumptions of a Regression Model n A regression model is based on the

Basic Assumptions of a Regression Model n A regression model is based on the following assumptions: 1. There is a probability distribution of Y for each level of X. 2. 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.

Statistical relation between Lot Size and number of man-Hours-Westwood Company Example

Statistical relation between Lot Size and number of man-Hours-Westwood Company Example

Pictorial Presentation of Linear Regression Model

Pictorial Presentation of Linear Regression Model

Construction of Regression Models Selection of independent variables n • Since reality must be

Construction of Regression Models Selection of independent variables n • 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 n • 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 analyzed. Scope of model n n 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.

Uses of Regression Analysis n n Regression analysis serves Three major purposes. 1. Description

Uses of Regression Analysis n n Regression analysis serves Three major purposes. 1. Description 2. Control 3. Prediction The several purposes of regression analysis frequently overlap in practice

Formal Statement of the Model n General regression model 1. 2. 3. 0, and

Formal Statement of the Model n General regression model 1. 2. 3. 0, and 1 are parameters X is a known constant Deviations are independent N(o, 2)

Meaning of Regression Coefficients n n The values of the regression parameters 0, and

Meaning of Regression Coefficients n n The values of the regression parameters 0, and 1 are not known. We estimate them from data. 1 indicates the change in the mean response per unit increase in X.

Regression Line n n If the scatter plot of our sample data suggests a

Regression Line n n 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.

Regression Line n n We will write an estimated regression line based on sample

Regression Line n n We will write an estimated regression line based on sample data as The method of least squares chooses the values for b 0, and b 1 to minimize the sum of squared errors

Regression Line n Using calculus, we obtain estimating formulas: or

Regression Line n Using calculus, we obtain estimating formulas: or

Estimation of Mean Response n n Fitted regression line can be used to estimate

Estimation of Mean Response n n Fitted regression line can be used to estimate the mean value of y for a given value of x. Example n The weekly advertising expenditure (x) and weekly sales (y) are presented in the following table.

Point Estimation of Mean Response n n From previous table we have: The least

Point Estimation of Mean Response n n From previous table we have: The least squares estimates of the regression coefficients are:

Point Estimation of Mean Response n n The estimated regression function is: This means

Point Estimation of Mean Response n n 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.

Point Estimation of Mean Response n n n Fitted values for the sample data

Point Estimation of Mean Response n n n 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).

Example: Retail sales and floor space n It is customary in retail operations to

Example: Retail sales and floor space n 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 +

Example: Retail sales and floor space n n n The slope 1 is as

Example: Retail sales and floor space n n n 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.

Residual n n The difference between the observed value yi and the corresponding fitted

Residual n n 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.

Example: weekly advertising expenditure

Example: weekly advertising expenditure

Estimation of the variance of the error terms, 2 n The variance 2 of

Estimation of the variance of the error terms, 2 n The variance 2 of the error terms i in the regression model needs to be estimated for a variety of purposes. n n 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.

Regression Standard Error n n To estimate we work with the variance and take

Regression Standard Error n n 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.

Regression Standard Error

Regression Standard Error

Analysis of Residual n n Inference based on regression model can be misleading if

Analysis of Residual n n Inference based on regression model can be misleading if the assumptions are violated. Assumptions for the simple linear regression model are: n n The underlying relation is linear. The errors are independent. The errors have constant variance. The errors are normally distributed.

Analysis of Residual n n To examine whether the regression model is appropriate for

Analysis of Residual n n To examine whether the regression model is appropriate for the data being analyzed, we can check the residual plots. Residual plots are: n n 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.

Analysis of Residual n n n A histogram of the residuals provides a check

Analysis of Residual n n n 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. Moderate departures from a bell shaped curve do not impair the conclusions from tests or prediction intervals. 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.

Analysis of Residual n n Plot of residuals against time provides a check on

Analysis of Residual n n Plot of residuals against time provides a check on the independence of the error terms assumption. Assumption of independence is the most critical one.

Analysis of Residual

Analysis of Residual

Analysis of Residual

Analysis of Residual

Variable transformations n If the residual plot suggests that the variance is not constant,

Variable transformations n 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: n Variance stabilizing transformations are: n n

Inference in Regression Analysis n n n The simple linear regression model imposes several

Inference in Regression Analysis n n n The simple linear regression model imposes several conditions. We should verify these conditions before proceeding to inference. These conditions concern the population, but we can observe only our sample. In doing inference we act as if n n The sample is a SRS from the population. There is a linear relationship in the population. The standard deviation of the responses about the population line is the same for all values of the explanatory variable. The response varies Normally about the population regression line.

Inference in Regression Analysis n Plotting the residuals against the explanatory variable is helpful

Inference in Regression Analysis n Plotting the residuals against the explanatory variable is helpful in checking these conditions because a residual plot magnifies patterns.

Confidence Intervals and Significance Tests n n n In our previous lectures we presented

Confidence Intervals and Significance Tests n n n 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 n n estimate t* Seestimate t* is a critical value of a t distribution.

Confidence Intervals and Significance Tests n n Confidence intervals and tests for the slope

Confidence Intervals and Significance Tests n n Confidence intervals and tests for the slope and intercept are based on the sampling distributions of the estimates b 1 and b 0. Here are the facts: n n n If the simple linear regression model is true, each of b 0 and b 1 has a Normal distribution. The mean of b 0 is 0 and the mean of b 1 is 1. The standard deviations of b 0 and b 1 are multiples of the model standard deviation .

Confidence Intervals and Significance Tests

Confidence Intervals and Significance Tests

Example: Weekly Advertising Expenditure n Let us return to the Weekly advertising expenditure and

Example: Weekly Advertising Expenditure n 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

Example: Weekly Advertising Expenditure n n Hypothesis: Decision Rule: Reject H 0 if or

Example: Weekly Advertising Expenditure n n Hypothesis: Decision Rule: Reject H 0 if or

Example: Weekly Advertising Expenditure n Test statistic:

Example: Weekly Advertising Expenditure n Test statistic:

Example: Weekly Advertising Expenditure n Conclusion: Since t =4. 5 > 2. 306 then

Example: Weekly Advertising Expenditure n Conclusion: Since t =4. 5 > 2. 306 then we reject H 0. There is a linear association between advertising expenditure and weekly sales.

Confidence interval for 1 n Now that our test showed that there is a

Confidence interval for 1 n 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.

Confidence interval for 1 n n For a 95 percent confidence coefficient, we require

Confidence interval for 1 n n For a 95 percent confidence coefficient, we require t (. 025; 8). From table B in appendix III, we find t(. 025; 8) = 2. 306. The 95% confidence interval is:

Example: Do wages rise with experience? n Many factors affect the wages of workers:

Example: Do wages rise with experience? n 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.

Example: Do wages rise with experience?

Example: Do wages rise with experience?

Example: Do wages rise with experience?

Example: Do wages rise with experience?

Example: Do wages rise with experience?

Example: Do wages rise with experience?

Example: Do wages rise with experience? n The hypotheses are: H 0: 1 =

Example: Do wages rise with experience? n The hypotheses are: H 0: 1 = 0, Ha: 1 > 0 The t statistic for the significance of regression is: n The P- value is: P(t > 2. 85) <. 005 The t distribution for this problem have n-2 = 57 degrees of freedom. n Conclusion: n Reject H 0 : There is strong evidence that the mean wages increase as length of service increases.

Example: Do wages rise with experience? n n A 95% confidence interval for the

Example: Do wages rise with experience? n n A 95% confidence interval for the slope 1 of the regression line in the population of all married female customer service workers in Indiana bank is The t distribution for this problem have n-2 = 57 degrees of freedom

Inference about Correlation n The correlation between wages and length of service for the

Inference about Correlation n The correlation between wages and length of service for the 59 bank workers is r = 0. 3535. This appears in the Excel out put, where it is labeled “Multiple R. ” We expect a positive correlation between length of service and wages in the population of all married female bank workers. Is the sample result convincing that this is true? This question concerns a new population parameter, the population correlation. This is correlation between length of service and wages when we measure these variables for every member of the population.

Inference about Correlation n n We will call the population correlation. To assess the

Inference about Correlation n n We will call the population correlation. To assess the evidence that . 0 in the bank worker population, we must test the hypotheses H 0: = 0 Ha : > 0 It is natural to base the test on the sample correlation r. There is a link between correlation and regression slope. The population correlation is zero, positive, negative exactly when the slope 1 of the population regression line is zero, positive, or negative.

Inference about Correlation

Inference about Correlation

Correlation Coefficient n Recall the algebraic expression for the correlation coefficient is.

Correlation Coefficient n Recall the algebraic expression for the correlation coefficient is.

Example: Do wages rise with experience? n n The sample correlation between wages and

Example: Do wages rise with experience? n n The sample correlation between wages and length of service is r = 0. 3535 from a sample of n = 59. To test H 0: = 0 Ha : > 0 Use t statistic

Example: Do wages rise with experience? n n Compare t = 2. 853 with

Example: Do wages rise with experience? n n Compare t = 2. 853 with critical values from the t table with n - 2 = 57 degrees of freedom. Conclusion: n P( t > 2. 853) <. 005, therefore we reject H 0. There is a positive correlation between wages and length of service.

Prediction of a new response ( ) n n We now consider the prediction

Prediction of a new response ( ) n n 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.

Interval Estimation of a new response ( ) n n The following formula gives

Interval Estimation of a new response ( ) n n The following formula gives us the point estimator (forecast) for y. 1 - % prediction interval for a new observation is: n Where

Example n n In our advertising expenditure and weekly sales, the management wishes to

Example n n 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

Example n The 90% prediction interval is:

Example n The 90% prediction interval is:

Analysis of variance approach to Regression analysis n n The analysis of variance approach

Analysis of variance approach to Regression analysis n n The analysis of variance approach is based on the partitioning of sums of squares and degrees of freedom associated with the response variable. 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:

Analysis of variance approach to Regression analysis n n The measure of total variation,

Analysis of variance approach to Regression analysis n n 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:

Analysis of variance approach to Regression analysis n n n The measure of variation

Analysis of variance approach to Regression analysis n n n 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 = 36124. 76 SST = 128552. 5 What accounts for the substantial difference between these two sums of squares?

Analysis of variance approach to Regression analysis n n The difference is another sum

Analysis of variance approach to Regression analysis n n The difference is another sum of squares: SSR stands for regression sum of squares. SSR may be considered as a measure of the variability of the yi that is associated with the regression line. The larger is SSR relative to SST, the greater is the role of regression line in explaining the total variability in y observations.

Analysis of variance approach to Regression analysis n n In our example: This indicates

Analysis of variance approach to Regression analysis n n 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.

Formal Development of the Partitioning n n We can decompose the total variability in

Formal Development of the Partitioning n n We can decompose the total variability in the observations yi as follows: The total deviation can be viewed as the sum of two components: n n The deviation of the fitted value around the mean. The deviation of yi around the fitted regression line.

Formal Development of the Partitioning n n The sums of these squared deviations have

Formal Development of the Partitioning n n The sums of these squared deviations have the same relationship: Breakdown of degree of freedom:

Mean squares n A sum of squares divided by its degrees of freedom is

Mean squares n A sum of squares divided by its degrees of freedom is called a mean square (MS) Regression mean square (MSR) n Error mean square (MSE) n Note: mean squares are not additive. n

Mean squares n In our example:

Mean squares n In our example:

Analysis of Variance Table n The breakdowns of the total sum of squares and

Analysis of Variance Table n 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

Analysis of Variance Table n In our weekly advertising expenditure and weekly sales example

Analysis of Variance Table n In our weekly advertising expenditure and weekly sales example the ANOVA table is: Source of variation SS df MS Regression 92427. 74 1 92427. 74 Error 36124. 76 8 4515. 6 Total 128552. 5 9

F-Test for 1= 0 versus 1 0 n The general analysis of variance approach

F-Test for 1= 0 versus 1 0 n The general analysis of variance approach provides us with a battery of highly useful tests for regression models. For the simple linear regression case considered here, the analysis of variance provides us with a test for:

F-Test for 1= 0 versus 1 0 n n Test statistic: In order to

F-Test for 1= 0 versus 1 0 n n Test statistic: In order to be able to construct a statistical decision rule, we need to know the distribution of our test statistic F. When H 0 is true, our test statistic, F, follows the Fdistribution with 1, and n-2 degrees of freedom. Table C on page 622 of your text gives the critical values of the F-distribution at = 0. 1, 0. 5 and. 01.

F-Test for 1= 0 versus 1 0 n Construction of decision rule: n n

F-Test for 1= 0 versus 1 0 n Construction of decision rule: n n n At = 5% level Reject H 0 if Large values of F support Ha and Values of F near 1 support H 0.

F-Test for 1= 0 versus 1 0 n n Using our example again, let

F-Test for 1= 0 versus 1 0 n n 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 =. 05. Since n=10, we require F(. 05; 1, 8). From table 5 -3 we find that F(. 05; 1, 8) = 5. 32. Therefore the decision rule is: n Reject H 0 if:

F-Test for 1= 0 versus 1 0 n From ANOVA table we have MSR

F-Test for 1= 0 versus 1 0 n From ANOVA table we have MSR = 92427. 74 MSE = 4515. 6 Our test statistic F is: n Decision: n n Since 20. 47> 5. 32, we reject H 0, that is there is a linear association between weekly advertising expenditure and weekly sales.

F-Test for 1= 0 versus 1 0 n Equivalence of F Test and t

F-Test for 1= 0 versus 1 0 n Equivalence of F Test and t Test: n n 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. n The t-test is more flexible since it can be used for one sided test as well.

Analysis of Variance Table n The complete ANOVA table for our example is: Source

Analysis of Variance Table n The complete ANOVA table for our example is: Source of Variation SS df MS F-Test Regressio n 92427. 74 1 92427. 74 20. 47 Error 36124. 76 8 4515. 6 Total 128552. 5 9

Computer Output n The EXCEL out put for our example is:

Computer Output n The EXCEL out put for our example is:

Coefficient of Determination n Recall that SST measures the total variations in yi when

Coefficient of Determination n 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:

Coefficient of Determination n n R 2 is called the coefficient of determination. 0

Coefficient of Determination n n R 2 is called the coefficient of determination. 0 SSE SST, it follows that: We may interpret R 2 as the proportionate reduction of total variability in y associated with the use of the independent variable x. The larger is R 2, the more is the total variation of y reduced by including the variable x in the model.

Coefficient of Determination n n If all the observations fall on the fitted regression

Coefficient of Determination n n If all the observations fall on the fitted regression line, SSE = 0 and R 2 = 1. If the slope of the fitted regression line b 1 = 0 so that , SSE=SST and R 2 = 0. The closer R 2 is to 1, the greater is said to be the degree of linear association between x and y. The square root of R 2 is called the coefficient of correlation.