Presentation on theme: "Linear Regression (LSRL). Bivariate data x – variable: is the independent or explanatory variable y- variable: is the dependent or response variable Use."— Presentation transcript:
Linear Regression (LSRL)
Bivariate data x – variable: is the independent or explanatory variable y- variable: is the dependent or response variable Use x to predict y
b – is the slope –it is the amount by which y increases when x increases by 1 unit a – is the y-intercept –it is the height of the line when x = 0 –in some situations, the y-intercept has no meaning - (y-hat) means the predicted y Be sure to put the hat on the y
Least Squares Regression Line LSRL bestThe line that gives the best fit to the data set minimizesThe line that minimizes the sum of the squares of the deviations from the line
Sum of the squares = 61.25 -4 4.5 -5 y =.5(0) + 4 = 4 0 – 4 = -4 (0,0) (3,10) (6,2) (0,0) y =.5(3) + 4 = 5.5 10 – 5.5 = 4.5 y =.5(6) + 4 = 7 2 – 7 = -5
(0,0) (3,10) (6,2) Sum of the squares = 54 Use a calculator to find the line of best fit Find y - y -3 6 What is the sum of the deviations from the line? Will it always be zero? minimizes LSRL The line that minimizes the sum of the squares of the deviations from the line is the LSRL.
Slope: unitx increase/decreaseby For each unit increase in x, there is an approximate increase/decrease of b in y. Interpretations Correlation coefficient: direction, strength, type xy There is a direction, strength, type of association between x and y.
The ages (in months) and heights (in inches) of seven children are given. x1624426075102120 y24303540485660 Find the LSRL. Interpret the slope and correlation coefficient in the context of the problem.
Correlation coefficient: strong, positive, linear age and height of children There is a strong, positive, linear association between the age and height of children. Slope: age of one month increase.34 inches in heights of children. For an increase in age of one month, there is an approximate increase of.34 inches in heights of children.
The ages (in months) and heights (in inches) of seven children are given. x1624426075102120 y24303540485660 Predict the height of a child who is 4.5 years old. Predict the height of someone who is 20 years old.
Extrapolation should notThe LSRL should not be used to predict y for values of x outside the data set. It is unknown whether the pattern observed in the scatterplot continues outside this range.
The ages (in months) and heights (in inches) of seven children are given. x1624426075102120 y24303540485660 Calculate x & y. Plot the point (x, y) on the LSRL. Will this point always be on the LSRL?
non-resistant The correlation coefficient and the LSRL are both non-resistant measures.
Formulas – on chart
The following statistics are found for the variables posted speed limit and the average number of accidents. Find the LSRL & predict the number of accidents for a posted speed limit of 50 mph.
Suppose we found the age and weight of a sample of 10 adults. Create a scatterplot of the data below. Is there any relationship between the age and weight of these adults? Age 24304128504649352039 Wt256124320185158129103196110130
Suppose we found the height and weight of a sample of 10 adults. Create a scatterplot of the data below. Is there any relationship between the height and weight of these adults? Ht74657772686062736164 Wt256124320185158129103196110130 Is it positive or negative? Weak or strong?
The closer the points in a scatterplot are to a straight line - the stronger the relationship. The farther away from a straight line – the weaker the relationship
positive negativeno Identify as having a positive association, a negative association, or no association. 1.Heights of mothers & heights of their adult daughters + 2. Age of a car in years and its current value 3.Weight of a person and calories consumed 4.Height of a person and the person ’ s birth month 5.Number of hours spent in safety training and the number of accidents that occur - + NO -
Correlation Coefficient (r)- quantitativeA quantitative assessment of the strength & direction of the linear relationship between bivariate, quantitative data Pearson ’ s sample correlation is used most parameter – rho) statistic - r
Calculate r. Interpret r in context. Speed Limit (mph) 555045403020 Avg. # of accidents (weekly) 28252117116 There is a strong, positive, linear relationship between speed limit and average number of accidents per week.
Moderate Correlation Strong correlation Properties of r (correlation coefficient) legitimate values of r are [-1,1] No Correlation Weak correlation
unitvalue of r does not depend on the unit of measurement for either variable x (in mm) 12152132261924 y 4710149812 Find r. Change to cm & find r. The correlations are the same.
value of r does not depend on which of the two variables is labeled x x 12152132261924 y4710149812 Switch x & y & find r. The correlations are the same.
non-resistantvalue of r is non-resistant x 12152132261924 y4710149822 Find r. Outliers affect the correlation coefficient
linearlyvalue of r is a measure of the extent to which x & y are linearly related A value of r close to zero does not rule out any strong relationship between x and y. definite r = 0, but has a definite relationship!
Minister data: (Data on Elmo) r =.9999 cause So does an increase in ministers cause an increase in consumption of rum?
Residuals (error) - The vertical deviation between the observations & the LSRL always zerothe sum of the residuals is always zero error = observed - expected
Residual plot A scatterplot of the (x, residual) pairs. Residuals can be graphed against other statistics besides x linear associationPurpose is to tell if a linear association exist between the x & y variables no pattern linearIf no pattern exists between the points in the residual plot, then the association is linear.
Linear Not linear
AgeRange of Motion 35154 24142 40137 31133 28122 25126 26135 16135 14108 20120 21127 30122 One measure of the success of knee surgery is post-surgical range of motion for the knee joint following a knee dislocation. Is there a linear relationship between age & range of motion? Sketch a residual plot. Since there is no pattern in the residual plot, there is a linear relationship between age and range of motion x Residuals
AgeRange of Motion 35154 24142 40137 31133 28122 25126 26135 16135 14108 20120 21127 30122 Plot the residuals against the y- hats. How does this residual plot compare to the previous one? Residuals
Residual plots are the same no matter if plotted against x or y-hat. x Residuals
Coefficient of determination- r 2 variationygives the proportion of variation in y that can be attributed to an approximate linear relationship between x & y remains the same no matter which variable is labeled x
AgeRange of Motion 35154 24142 40137 31133 28122 25126 26135 16135 14108 20120 21127 30122 Let ’ s examine r 2. Suppose you were going to predict a future y but you didn ’ t know the x-value. Your best guess would be the overall mean of the existing y ’ s. Now, find the sum of the squared residuals (errors). L3 = (L2- 130.0833)^2. Do 1VARSTAT on L3 to find the sum. SSE y = 1564.917 Sum of the squared residuals (errors) using the mean of y.
AgeRange of Motion 35154 24142 40137 31133 28122 25126 26135 16135 14108 20120 21127 30122 Now suppose you were going to predict a future y but you DO know the x-value. Your best guess would be the point on the LSRL for that x-value (y-hat). Find the LSRL & store in Y1. In L3 = Y1(L1) to calculate the predicted y for each x-value. Now, find the sum of the squared residuals (errors). In L4 = (L2-L3)^2. Do 1VARSTAT on L4 to find the sum. Sum of the squared residuals (errors) using the LSRL. SSE y = 1085.735
AgeRange of Motion 35154 24142 40137 31133 28122 25126 26135 16135 14108 20120 21127 30122 By what percent did the sum of the squared error go down when you went from just an “ overall mean ” model to the “ regression on x ” model? SSE y = 1085.735 SSE y = 1564.917 This is r 2 – the amount of the variation in the y-values that is explained by the x-values.
AgeRange of Motion 35154 24142 40137 31133 28122 25126 26135 16135 14108 20120 21127 30122 How well does age predict the range of motion after knee surgery? Approximately 30.6% of the variation in range of motion after knee surgery can be explained by the linear regression of age and range of motion.
Interpretation of r 2 r 2 % y xy Approximately r 2 % of the variation in y can be explained by the LSRL of x & y.
Computer-generated regression analysis of knee surgery data: PredictorCoefStdevTP Constant107.5811.129.670.000 Age0.87100.41462.100.062 s = 10.42R-sq = 30.6%R-sq(adj) = 23.7% What is the equation of the LSRL? Find the slope & y-intercept. NEVER use adjusted r 2 ! before Be sure to convert r 2 to decimal before taking the square root! What are the correlation coefficient and the coefficient of determination?
Outlier – In a regression setting, an outlier is a data point with a large residual
Influential point- A point that influences where the LSRL is located If removed, it will significantly change the slope of the LSRL
RacketResonance Acceleration (Hz) (m/sec/sec) 110536.0 210635.0 311034.5 411136.8 511237.0 611334.0 711334.2 811433.8 911435.0 1011935.0 1112033.6 1212134.2 1312636.2 1418930.0 One factor in the development of tennis elbow is the impact-induced vibration of the racket and arm at ball contact. Sketch a scatterplot of these data. Calculate the LSRL & correlation coefficient. Does there appear to be an influential point? If so, remove it and then calculate the new LSRL & correlation coefficient.
Which of these measures are resistant? LSRL Correlation coefficient Coefficient of determination NONE NONE – all are affected by outliers
Heigh t Weight How much would an adult female weigh if she were 5 feet tall? She could weigh varying amounts – in other words, there is a distribution of weights for adult females who are 5 feet tall. This distribution is normally distributed. (we hope) What would you expect for other heights? Where would you expect the TRUE LSRL to be? What about the standard deviations of all these normal distributions? We want the standard deviations of all these normal distributions to be the same.
Regression Model The mean response y has a straight-line relationship with x: –Where: slope β and intercept α are unknown parameters For any fixed value of x, the response y varies according to a normal distribution. Repeated responses of y are independent of each other. The standard deviation of y ( y ) is the same for all values of x. ( y is also an unknown parameter)
The slope b of the LSRL is an unbiased estimator of the true slope β. The intercept a of the LSRL is an unbiased estimator of the true intercept α. The standard error s is an unbiased estimator of the true standard deviation of y ( y ). Note: df = n-2 We use to estimate
Do sampling distribution of slopes activity
Heigh t Weight Suppose you took many samples of the same size from this population & calculated the LSRL for each. Using the slope from each of these LSRLs – we can create a sampling distribution for the slope of the true LSRL. bbbb b b b What shape will this distribution have? What is the mean of the sampling distribution equal? μ b = What is the standard deviation of the sampling distribution ?
Assumptions for inference on slope The observations are independent –Check that you have an SRS The true relationship is linear –Check the scatter plot & residual plot The standard deviation of the response is constant. –Check the scatter plot & residual plot The responses vary normally about the true regression line. –Check a histogram or boxplot of residuals
Formulas: Confidence Interval: Hypothesis test: df = n -2 Because there are two unknowns &
Hypotheses H 0 : = 0 H a : > 0 H a : < 0 H a : ≠ 0 This implies that there is no relationship between x & y Or that x should not be used to predict y What would the slope equal if there were a perfect relationship between x & y? 1 Be sure to define !
Example: It is difficult to accurately determine a person ’ s body fat percentage without immersing him or her in water. Researchers hoping to find ways to make a good estimate immersed 20 male subjects, and then measured their weights. a)Find the LSRL, correlation coefficient, and coefficient of determination. Body fat = -27.376 + 0.250 weight r = 0.697 r 2 = 0.485
b) Explain the meaning of slope in the context of the problem. There is approxiamtely.25% increase in body fat for every pound increase in weight. c) Explain the meaning of the coefficient of determination in context. Approximately 48.5% of the variation in body fat can be explained by the regression of body fat on weight.
d) Estimate , , and . = -27.376 = 0.25 = 7.049 e) Create a scatter plot and residual plot for the data. Weight Residuals Weight Body fat
f) Is there sufficient evidence that weight can be used to predict body fat? Assumptions: Have an SRS of male subjects Since the residual plot is randomly scattered, weight & body fat are linear Since the points are evenly spaced across the LSRL on the scatterplot, y is approximately equal for all values of weight Since the boxplot of residual is approximately symmetrical, the responses are approximately normally distributed. H 0 : = 0Where is the true slope of the LSRL of weight H a : ≠ 0& body fat Since the p-value < α, I reject H 0. There is sufficient evidence to suggest that weight can be used to predict body fat.
g) Give a 95% confidence interval for the true slope of the LSRL. Assumptions: Have an SRS of male subjects Since the residual plot is randomly scattered, weight & body fat are linear Since the points are evenly spaced across the LSRL on the scatterplot, y is approximately equal for all values of weight Since the boxplot of residual is approximately symmetrical, the responses are approximately normally distributed. We are 95% confident that the true slope of the LSRL of weight & body fat is between 0.12 and 0.38. Be sure to show all graphs!
h) Here is the computer-generated result from the data: Sample size: 20 R-square = 43.83% s = 7.0491323 ParameterEstimateStd. Err. Intercept-27.37626311.547428 Weight0.249874140.060653996 df? Correlation coeficient? Be sure to write as decimal first! What does “ s ” represent (in context)? What do these numbers represent? What does this number represent?