Presentation is loading. Please wait.

Presentation is loading. Please wait.

Regression For the purposes of this class: –Does Y depend on X? –Does a change in X cause a change in Y? –Can Y be predicted from X? Y= mX + b Predicted.

Similar presentations


Presentation on theme: "Regression For the purposes of this class: –Does Y depend on X? –Does a change in X cause a change in Y? –Can Y be predicted from X? Y= mX + b Predicted."— Presentation transcript:

1 Regression For the purposes of this class: –Does Y depend on X? –Does a change in X cause a change in Y? –Can Y be predicted from X? Y= mX + b Predicted values Overall Mean Actual values

2 When analyzing a regression-type data set, the first step is to plot the data: XY 35114 45120 55150 65140 75166 55138 The next step is to determine the line that ‘best fits’ these points. It appears this line would be sloped upward and linear (straight).

3 1) The regression line passes through the point (X avg, Y avg ). 2) Its slope is at the rate of “m” units of Y per unit of X, where m = regression coefficient (slope; y=mx+b) The line of best fit is the sample regression of Y on X, and its position is fixed by two results: (55, 138) Y = 1.24(X) + 69.8 slopeY-intercept Rise/Run

4 Testing the Regression Line for Significance An F-test is used based on Model, Error, and Total SOS. –Very similar to ANOVA Basically, we are testing if the regression line has a significantly different slope than a line formed by using just Y_avg. –If there is no difference, then that means that Y does not change as X changes (stays around the average value) To begin, we must first find the regression line that has the smallest Error SOS.

5 100 120 140 160 180 304050607080 Independent Value Dependent Value Error SOS The regression line should pass through the overall average with a slope that has the smallest Error SOS (Error SOS = the distance between each point and predicted line: gives an index of the variability of the data points around the predicted line). overall average is the pivot point 55 138

6 For each X, we can predict Y:Y = 1.24(X) + 69.8 XY_ActualY_PredSOS Error 35114113.20.64 45120125.631.36 55150138144 65140150.4108.16 75166162.810.24 294.4 Error SOS is calculated as the sum of (Y Actual – Y Predicted ) 2 This gives us an index of how scattered the actual observations are around the predicted line. The more scattered the points, the larger the Error SOS will be. This is like analysis of variance, except we are using the predicted line instead of the mean value.

7 Total SOS Calculated as the sum of (Y – Y avg ) 2 Gives us an index of how scattered our data set is around the overall Y average. Overall Y average Regression line not shown

8 XY_ActualY AverageSOS Total 35114138576 45120138324 55150138144 651401384 75166138784 1832 Total SOS gives us an index of how scattered the data points are around the overall average. This is calculated the same way for a single treatment in ANOVA. What happens to Total SOS when all of the points are close to the overall average? What happens when the points form a non-horizontal linear trend?

9 Model SOS Calculated as the Sum of (Y Predicted – Y avg ) 2 Gives us an index of how far all of the predicted values are from the overall average. Distance between predicted Y and overall mean

10 Model SOS Gives us an index of how far away the predicted values are from the overall average value What happens to Model SOS when all of the predicted values are close to the average value? XY_PredY AverageSOS Model 35113.2138615.04 45125.6138153.76 55138 0 65150.4138153.76 75162.8138615.04 1537.6

11 All Together Now!! XY_ActualY_PredSOS Error Y_AvgSOS Total SOS Model 35114113.20.64138576615.04 45120125.631.36138324153.76 551501381441381440 65140150.4108.161384153.76 75166162.810.24138784615.04 294.418321537.6 SOS Error =  (Y_Actual – Y_Pred) 2 SOS Total =  (Y_Actual –Y_ Avg) 2 SOS Model =  (Y_Pred – Y_Avg) 2

12 Using SOS to Assess Regression Line Model SOS gives us an index on how ‘different’ the predicted values are from the average values. – Bigger Model SOS = more different –Tells us how different a sloped line is from a line made up only of Y_avg. –Remember, the regression line will pass through the overall average point. Error SOS gives us an index of how different the predicted values are from the actual values –More variability = larger Error SOS = large distance between predicted and actual values

13 Magic of the F-test The ratio of Model SOS to Error SOS (Model SOS divided by Error SOS) gives us an overall index (the F statistic) used to indicate the relative ‘difference’ between the regression line and a line with slope of zero (all values = Y_avg. –A large Model SOS and small Error SOS = a large F statistic. Why does this indicate a significant difference? –A small Model SOS and a large Error SOS = a small F statistic. Why does this indicate no significant difference?? Based on sample size and alpha level (P-value), each F statistic has an associated P-value. –P < 0.05 (Large F statistic) there is a significant difference between the regression line a the Y_avg line. –P ≥ 0.05 (Small F statistic) there is NO significant difference between the regression line a the Y_avg line.

14 Mean Model SOS Mean Error SOS 100 120 140 160 180 304050607080 Independent Value Dependent Value Basically, this is an index that tells us how different the regression line is from Y_avg, and the scatter of the data around the predicted values. = F

15 Data production; input X Y; cards; 35 114 45 120 55 150 65 140 75 166 ; proc print; run; proc reg; {Tells SAS to do the regression procedure} model Y=X; {Tells SAS that Y is the dependent value and X is the independent value} run; SAS Code for Regression

16 Sum of Mean Source DF Squares Square F Value Pr > F Model 1 1537.60000 1537.60000 15.67 0.0288 Error 3 294.40000 98.13333 Corrected Total 4 1832.00000 Root MSE 9.90623 R-Square 0.8393 Dependent Mean 138.00000 Adj R-Sq 0.7857 Coeff Var 7.17843 Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept 1 69.80000 17.78988 3.92 0.0295 X 1 1.24000 0.31326 3.96 0.0288 Y = [mX + b] = [(1.24)(X) + 69.8]

17 Correlation (r): A nother measure of the mutual linear relationship between two variables. ‘r’ is a pure number without units or dimensions ‘r’ is always between –1 and 1 Positive values indicate that y increases when x does and negative values indicate that y decreases when x increases. –What does r = 0 mean? ‘r’ is a measure of intensity of association observed between x and y. –‘r’ does not predict – only describes associations between variables

18 r > 0 r < 0 r = 0 r is also called Pearson’s correlation coefficient.

19 SAS Code for Correlation Proc corr; {Tells SAS to do the correlation procedure} var y x; (Tells SAS to determine the correlation between these variables) run; The CORR Procedure 2 Variables: Y X Simple Statistics Variable N Mean Std Dev Sum Minimum Maximum Y 5 138.00000 21.40093 690.00000 114.00000 166.00000 X 5 55.00000 15.81139 275.00000 35.00000 75.00000 Pearson Correlation Coefficients, N = 5 Prob > |r| under H0: Rho=0 Y X Y 1.00000 0.91613 0.0288 X 0.91613 1.00000 0.0288 Significant correlation high correlation

20 R-square If we square r, we get rid of the negative value if it is negative) and we get an index of how close the data points are to the regression line. Allows us to decide how much confidence we have in making a prediction based on our model. Is calculated as Model SOS / Total SOS

21 r 2 = Model SOS / Total SOS = Model SOS = Total SOS

22 = Model SOS = Total SOS r2 = Model SOS / Total SOS  numerator/denominator Small numerator Big denominator R 2 = 0.8393

23 R-square and Prediction Confidence

24 Sum of Mean Source DF Squares Square F Value Pr > F Model 1 1537.60000 1537.60000 15.67 0.0288 Error 3 294.40000 98.13333 Corrected Total 4 1832.00000 Root MSE 9.90623 R-Square 0.8393 Dependent Mean 138.00000 Adj R-Sq 0.7857 Coeff Var 7.17843 Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept 1 69.80000 17.78988 3.92 0.0295 X 1 1.24000 0.31326 3.96 0.0288 Y = [mX + b] = [(1.24)(X) + 69.8]

25 Finally…….. If we have a significant relationship (based on the p-value), we can use the r-square value to judge how sure we are in making a prediction.


Download ppt "Regression For the purposes of this class: –Does Y depend on X? –Does a change in X cause a change in Y? –Can Y be predicted from X? Y= mX + b Predicted."

Similar presentations


Ads by Google