251solnK1 3/28/06 (Open this document in 'Page Layout' view!) K. Two Random Variables. 1. Regression (Summary). 2. Covariance ( xy and s xy ) 3. The Correlation Coefficient ( xy and rxy ) 4. Functions of Two Random Variables. 5. Sums of Random Variables, Independence. In the following problems (I) check for independence, (ii) Compute Covx, y , Corr x, y and, (iii) Compute Ex y and Var x y : D&C pg. 221 3, 4, 7, 14. In problem 3, find the following: Px y 4 , P x y 4 x 0 Downing and Clark (formerly pg. 348 now posted at end of 251hwkadd) Old Computational Problem 1: For the sample data below b) Compute Cov x, y and Corr x, y . c) Compute the mean of x y and Var x y . x 34 26 9 30 47 10 34 34 45 10 47 32 47 8 45 y 6 57 89 60 95 42 31 28 90 25 45 23 52 95 48 Text 5.8 (Compute Var x y ), 5.9, 5.11, 5.16, 5.17 [5.8, 5.9, 5.10, 5.13] (5.8, 5.10), K1-K4 . The Downing and Clark problems are in this document. ----------------------------------------------------------------------------------------------------------------------------Downing and Clark, pg. 219, Computational Problem 3: Using the joint probability table below, (a) check for independence, (b) Compute Covx, y , Corr x, y , (c) Compute Ex y and Var x y . (d) y Find Px y 4 and P x y 4 x 0 . 0 2 4 6 2 .1 0 .1 .2 x 4 0 .1 0 .1 5 .1 0 .1 .2 Solution: a) Check for independence: Look at the upper left hand probability below. Its value is .1 and it represents Px 2 y 0 . If x and y were independent, we would have Px 2 y 0 Px 2 P y 0 .4.2 .08 . Since this is not true, x and y are not independent. b) Compute Covx, y and Corr x, y . y 2 x 4 5 P y yP y y P y 2 0 2 .1 0 0 .1 .1 0 .2 .1 0 .1 .2 6 .2 .1 .2 .5 0 0.2 0.8 3.0 0 .4 3.2 18 Px xPx x 2 Px .4 0.8 1.6 .2 0.8 3.2 .4 2.0 10 .0 1.0 2.0 14 .8 4.0 21 .6 Px 1 , Ex xPx 2.0 , E x x E y yP y 4.0 and E y y P y 21 .6 To summarize - y 4 .1 2 x 2 2 2 Px 14 .8 , P y 1 , 251solnK1 3/28/06 (Open this document in 'Page Layout' view!) E xy .1 20 0 22 .1 24 .2 26 xyPxy 040 .142 044 .146 .150 052 .154 .256 0 0.8 2.4 0 0 0.8 0 2.4 8.0 0 2 6.0 0 xy Covxy Exy x y 8 24 0 , x2 E x 2 x2 14.8 2.02 10 .8 and y2 E y 2 y2 21.6 4.02 5.6 . So that xy xy 0 0. x y 10 .8 5.6 c) Compute Ex y and Var x y . Ex y Ex E y x y 2.0 4.0 6.0 and Var x y x2 y2 2 xy Var x Var y 2Covx, y 10 .8 5.6 20 16 .4 d) Find Px y 4 , P x y 4 x 0 y 6 . If we compute the sum of x y and .2 .1 0 .1 0 .1 .2 y place it in our joint probability table in place of the probabilities, we get 0 2 4 6 . 2 2 0 2 4 x 4 4 6 8 10 5 5 7 9 11 The first five of these, -2, 0, 2, 4, and 4 are less than or equal to 4. If we read their probabilities off the joint probability table, we get Px y 4 .1 0 .1 .2 0 .4 . P A B From the multiplication Rule we know P A B , so P B Px y 4 x 0 . The sums for which x is zero or lower are those in the top P x y 4x 0 P x 0 row, and we have already found that Px 0 Px 2 .4 . But the only sums for which both Remember our original probabilities: 0 2 .1 x 4 0 5 .1 2 0 4 .1 x y 4 and x 0 are exactly the same sums in the top row, so that Px y 4 x 0 .4 too. Thus P x y 4 x 0 Px y 4 x 0 .4 1. P x 0 .4 251solnK1 3/28/06 (Open this document in 'Page Layout' view!) Downing and Clark, pg. 219, Computational Problem 4: Using the joint probability table below, (a) check for independence, (b) Compute Covx, y , Corr x, y , (c) Compute Ex y and Var x y . y 2 1 x 0 1 2 3 .15 .05 0 .15 0 5 7 .05 0 0 .20 .10 0 0 .20 .10 0 Solution: a) Check for independence: The big giveaway in any of these is the presence of a zero. Look at the lower right hand corner. The probability there is 0 Px 2 y 7 . If x and y were independent, we would have to have either Px 2 0 or P y 3 0 because Px 2 y 7 would equal Px 2 P y 7 . Since this is not true, x and y are not independent. b) Compute Covx, y and Corr x, y . y x 2 1 0 1 2 P y yP y y 2 P y 3 5 .15 .05 .05 0 0 .10 .15 0 0 .10 .35 .25 1.05 1.25 3.15 6.25 xPx 0.40 .025 0 0.35 0.20 0.10 x 2 Px 0.80 0.25 0 0.35 0.40 1.80 xPx 0.10 , E x x Px 1.80 , P y 1 , E y yP y 5.9 and E y y P y 41 .8 . To summarize - y 7 Px 0 .20 .20 .25 0 .10 .20 .35 0 .10 .40 1.00 3.60 5.9 32 .4 41 .8 Px 1 , x E x 2 E xy 2 2 2 0 .15 23 .05 25 0 29 0.9 0.5 .05 13 0 15 .20 19 0.15 0 1.8 xyPxy 003 .10 05 009 0 0 0 0.1 015 .20 19 0.45 0 1.8 .1513 023 .10 25 029 0 1.0 0 xy Covxy Exy x y 0.1 0.105.90 0.49 , x2 E x 2 x2 1.8 0.10 2 1.79 and y2 E y 2 y2 41.8 5.92 6.99 . So that xy c) Compute Ex y and Var x y . xy 0.49 .1385 . x y 1.79 6.99 Ex y Ex E y x y 0.10 5.90 5.80 and Var x y x2 y2 2 xy Var x Var y 2Covx, y 1.79 6.99 20.49 9.76 251solnK1 3/28/06 (Open this document in 'Page Layout' view!) Downing and Clark, pg. 219, Computational Problem 7: Using the joint probability table below, (a) check for independence, (b) Compute Covx, y , Corr x, y , (c) Compute Ex y and Var x y . y 1 2 x 3 4 1 .2 0 0 0 2 .1 0 .1 0 3 .1 0 .1 .1 4 0 0 .2 .1 Solution: a) Check for independence: The row of zeros for x 2 is supposed to fool you - it makes it look like x and y are independent, but they are not. One thing to look for is proportional rows. The row (.2, .1, .1, 0) is not proportional to the row (0, .1, .1, 2). If x and y were independent, we would have joint y 1 2 3 4 Px 1 .08 .08 .12 .12 .4 probabilities like 2 0 0 0 0 0 . (Note that the first and third rows are identical and x 3 .08 .08 .12 .12 .4 4 .04 .04 .06 .06 .2 .2 .2 .3 .3 1.0 the first and last rows are proportional) Since the rows are not proportional, x and y are not independent. b) Compute Covx, y and Corr x, y . y 1 2 x 3 4 P y yP y y P y 2 1 .2 0 0 0 .2 0 .1 0 .2 3 .1 4 0 0 0 .1 .2 .1 .1 .3 .3 Px xPx x 2 Px .4 0.4 0.4 0 0 0 .4 1.2 3.6 .2 1.0 0.8 2.4 3.2 7.2 0.2 0.4 0.9 1.2 2.7 0.2 0.8 2.7 4.8 8.5 xPx 2.4 , E x x E y yP y 2.7 and E y y P y 8.5 To summarize - y 2 .1 E xy Px 1 , x E x 2 .211 021 xyPxy 031 041 .3 0 .2 .2 0 0 0 0 7.4 0 0.6 0.9 2.4 0 1.2 1.6 0 2 2 .112 .113 014 02 2 02 3 02 4 .132 .133 .234 04 2 .14 3 .14 4 2 Px 7.2 , P y 1 , 251solnK1 3/28/06 (Open this document in 'Page Layout' view!) xy Covxy Exy x y 7.40 2.42.7 0.92 , x2 E x 2 x2 7.20 2.42 1.44 and y2 E y 2 y2 8.5 2.72 1.21 . So that xy c) Compute Ex y and Var x y . xy x y 0.92 .70 . 1.44 1.21 Ex y Ex E y x y 2.4 2.7 5.1 and Var x y x2 y2 2 xy Var x Var y 2Covx, y 1.44 1.31 20.92 4.49 Downing and Clark, pg. 219, Computational Problem 13: Using the joint probability table below, (a) check for independence, (b) Compute Covx, y , Corr x, y , (c) Compute Ex y and Var x y . y 1 x 1 2 3 4 5 6 1 36 1 36 1 36 1 36 1 36 1 36 2 1 36 1 36 1 36 1 36 1 36 1 36 3 4 5 6 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 Solution: a) Check for independence: Of course we have independence here. For example, we have 1 . Px 3 y 5 Px 3 P y 5 16 16 36 y 1 1 2 x 3 4 5 6 P y yP y 1 36 1 36 1 36 1 36 1 36 1 36 y 2 P y 1 6 1 6 1 6 2 1 36 1 36 1 36 1 36 1 36 1 36 1 6 2 6 4 6 3 4 5 1 36 1 36 1 36 1 36 1 36 1 36 1 6 3 6 9 6 1 36 1 36 1 36 1 36 1 36 1 36 1 6 4 6 16 6 1 36 1 36 1 36 1 36 1 36 1 36 1 6 5 6 25 6 Px xPx x 2 Px 6 1 36 1 36 1 36 1 36 1 36 1 36 1 6 6 6 36 6 1 6 1 6 1 6 1 6 1 6 1 6 1 1 6 2 6 3 6 4 6 5 6 6 6 21 6 1 6 4 6 9 6 16 6 25 6 36 6 91 6 21 6 91 6 Px 1 , Ex xPx 3.5 , E x x Px 15.167 , P y 1 , E y yP y 3.5 and E y y P y 15.167 . To summarize - y 2 21 6 x 21 6 2 2 2 121 6 91 6 251solnK1 3/28/06 (Open this document in 'Page Layout' view!) E xy 1 2 3 4 5 6 2 4 6 8 10 12 1 3 6 9 12 15 18 xyPxy 36 4 8 12 16 20 24 5 10 15 20 25 30 6 12 18 24 30 36 2 1 21 221 321 421 521 621 21 441 12 .25 36 36 36 xy Covxy Exy x y 12.25 3.53.5 0 , x2 E x 2 x2 15.167 3.52 2.917 and y2 E y 2 y2 15.167 3.52 2.917 . So that xy xy 0. 0 . We didn't have 7.917 7.917 to go to all this work to show this. It was explained in class that if x and y are independent xy 0 and x y xy 0 . c) Compute Ex y and Var x y . Ex y Ex E y x y 3.5 3.5 7.0 and Var x y x2 y2 2 xy Varx Var y 2Covx, y 2.917 2.917 20 5.833 251solnK1 3/28/06 (Open this document in 'Page Layout' view!) Downing and Clark (formerly pg. 348 now posted at end of 251hwkadd) Old Computational Problem 1: This is obviously sample data, so we compute only a sample covariance and correlation. b) Compute Covx, y and Corr x, y . c) Compute the mean of x y and Var x y . x 34 26 9 30 47 10 34 34 45 10 47 37 47 8 45 y 6 57 89 60 95 42 31 28 90 25 45 23 52 95 48 Solution: This is sample data, so we compute a sample covariance and correlation. b) Compute Covx, y and Corr x, y . Only the x and y columns are given. If we use computational formulas, we must start with the table below. xy y2 x2 y x obs 1 34 6 1156 36 204 2 3 4 26 9 30 57 89 60 676 81 900 3249 7921 3600 1482 801 1800 5 47 10 95 2209 100 9025 1764 4465 420 6 42 961 784 1054 952 90 1156 1156 2025 8100 4080 10 47 25 45 100 2209 625 2025 250 2115 12 37 23 1369 529 736 13 47 52 2209 2704 2444 14 15 8 45 95 48 64 2025 9025 2304 760 2160 Total 463 786 17435 52652 23808 9 34 34 45 10 11 7 8 31 28 x 463 , x x s x2 x 463 30.867 n x 15 2 nx 2 n 1 224 .5524 y s 2y 17435 1530 .867 2 14 y 786 52.400 n y 15 2 ny 2 n 1 818 .9714 52652 1552 .400 2 14 y 786 , y 52652 and xy 23808 xy nx y 23808 1530.867 52.400 The formula for the sample covariance is s 2 17435 , 2 xy 453 .2 32 .3714 14 . So rxy sxy sx s y n 1 32 .3714 224 .5514 818 .9714 14 0.07548 . c) Compute the mean of x y and Var x y . x y is x y x y 30.867 52.400 83.267 The sample variance of x y , s x2 y is calculated by the familiar formula, Var x y Var x Var y 2Covx, y , which, for a sample, becomes s x2 y s x2 s 2y 2s xy 224 .5524 818 .9714 2 32.3714 973 .7810 . The sample mean of 251solnK1 3/28/06 (Open this document in 'Page Layout' view!) Minitab Computation of the Above Problem. ————— 3/28/2006 9:03:25 PM ———————————————————— Welcome to Minitab, press F1 for help. Results for: 251K1s1.MTW MTB > WSave "C:\Documents and Settings\rbove\My Documents\Minitab\251K1s1.MTW"; SUBC> Replace. Saving file as: 'C:\Documents and Settings\rbove\My Documents\Minitab\251K1s1.MTW' MTB > exec '251samcov.txt' Executing from file: 251samcov.txt Executing from file: var973.txt Data Display svar 3143.73 #Sample variance before dividing by n-1 Descriptive Statistics: C1 Variable C1 N 15 N* 0 Mean 30.87 SE Mean 3.87 StDev 14.99 Minimum 8.00 Q1 10.00 Median 34.00 Q3 45.00 Maximum 47.00 Data Display Row 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 C1 34 26 9 30 47 10 34 34 45 10 47 37 47 8 45 C2 1156 676 81 900 2209 100 1156 1156 2025 100 2209 1369 2209 64 2025 # x and x squared. Data Display sum sumsq count smean svar sdev DF sterr 463.000 17435.0 15.0000 30.8667 224.552 14.9851 14.0000 3.86913 Executing from file: var973.txt Data Display svar 11465.6 # Sample variance of y before division by n-1. Descriptive Statistics: C1 Variable C1 N 15 N* 0 Mean 52.40 SE Mean 7.39 StDev 28.62 Minimum 6.00 Q1 28.00 Median 48.00 Q3 89.00 Maximum 95.00 251solnK1 3/28/06 (Open this document in 'Page Layout' view!) Data Display Row 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 C1 6 57 89 60 95 42 31 28 90 25 45 23 52 95 48 C2 36 3249 7921 3600 9025 1764 961 784 8100 625 2025 529 2704 9025 2304 # y and y squared. Data Display sum sumsq count smean svar sdev DF sterr 786.000 52652.0 15.0000 52.4000 818.971 28.6177 14.0000 7.38905 Data Display Row 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 x 34 26 9 30 47 10 34 34 45 10 47 37 47 8 45 xsq 1156 676 81 900 2209 100 1156 1156 2025 100 2209 1369 2209 64 2025 y 6 57 89 60 95 42 31 28 90 25 45 23 52 95 48 ysq 36 3249 7921 3600 9025 1764 961 784 8100 625 2025 529 2704 9025 2304 xy 204 1482 801 1800 4465 420 1054 952 4050 250 2115 851 2444 760 2160 # The worksheet. Data Display sumx sumx2 sumy sumy2 sumxy n xbar ybar svarx svary scovxy sx sy rxy rxy2 463.000 17435.0 786.000 52652.0 23808.0 15.0000 30.8667 52.4000 224.552 818.971 -32.3714 14.9851 28.6177 -0.0754864 0.00569820 # # # # # Sum Sum Sum Sum Sum of of of of of # # # # # # # # # Sample Sample Sample Sample Sample Sample Sample Sample Sample x x squared y y squared xy mean of x mean of y variance of x variance of y covariance of x and y standard deviation of x standard deviation of y correlation of x and y correlation of x and y squared.