203 Chapter 6. Covariance, Correlation Problem PP169 To illustrate graphically the meaning of correlation, generate 10 values of a random variable X uniformly distributed between 1 and 12 in cells A2:A11: = 1 + π π΄ππ·( ) ∗ 11. Generate 10 values of a random variable Y in cells B2:B11. The conditional pdf of Y given π = π₯ 1 is π(π¦|π₯) = 12−π₯ , 1 < π¦ < 13 − π₯. Example for cell B2: = 1 + (12 − π΄2) ∗ π π΄ππ·( ) and similarly for cells B3:B11. To prepare for a scatter plot of the values (π π), input the values 0 and 13 in cells D2:D3, the values 0 and 12 in cells D5:D6, compute the mean of the ten X values in both cells E2 and E3, the mean of the 10 Y values in both cells E5 and E6. 1. Use Insert\Scatter\Scatter with only markers to graph the X (on the horizontal axis) and Y values (on the vertical axis). Select the horizontal axis from 0 to 12, the vertical axis from 0 to 13. Add a vertical line at the mean of the X values (use cells D2:E3, connect the points by a linear trend line), a horizontal line at the mean of the Y values (use cells D5:E6). Consider both trend lines as new coordinate axes. Compute the correlation coefficient between the X and the Y values in cell E8: = πΆππ π πΈπΏ(π΄2: π΄11; π΅2: π΅11). Click on one of the data points in the graph and add a linear trend line. Check the sign of the correlation and the slope of the trend line. Repeat generating the values of X and Y (key F9), check the correlation coefficient and the position of the points with respect to the new axes. Also compute the sample covariance in cell D9: = πΆπππ΄π πΌπ΄ππΆπΈ. π(π΄2: π΄11; π΅2: π΅11); 2. On a new worksheet generate 10 values of X as in Step 1. Generate 10 values of Y in cells B2:B11 as follows (example for cell B2): = 16 − 2 ∗ π΄2 and likewise for cells B3:B11. Use a scatter plot to graph the 10 values of X and Y. Compute the correlation coefficient between the X and the Y values. Notice the perfect (negative) correlation for points on a straight line (with negative slope); 3. On a new worksheet we generate 50 points on the circumference of a circle with radius 1 as follows: 50 values of X, randomly distributed between -1 and +1, in the range A2:A51: = −1 + 2 ∗ π π΄ππ·( ), 50 values of Y in cells B2:B51. Example for cell B2: = πΌπΉ(π π΄ππ·( ) < .5; πππ π(1 − π΄2 ∗ π΄2); −πππ π(1 − π΄2 ∗ π΄2)) and similarly for cells B3:B51. Use a scatter plot to graph the 50 values of (π π). Compute the correlation coefficient between the X and the Y values. Notice the poor correlation although the points are ‘perfectly’ related since π 2 + π 2 = 1; 4. On a new worksheet generate the points as in Step 1. Add a point in row 12: the value 12 in cell A12, the value 13 in cell B12. Compute again the correlation between X and Y. The added point can be considered an outlier in the data. Notice the strong effect an outlier can have on the correlation. When repeatedly generating new data the correlation coefficient will be just mildly 204 negative or even positive. Assignment PA169 Repeat Step 1 but generate the values of Y as (for cell B2): = 1 + π΄2 ∗ π π΄ππ·( ). Repeat Step 2 but generate the values of Y as (for cell B2): = 6 + 2 ∗ π΄2. Repeat Step 3 but generate the values of Y (for cell B2): = ππππΈπ (π΄2; 4). 205 Problem PP170 Consider the random variables (X, Y) in Problem PP135. 1. Compute the expected values, the variances and standard deviations of X and Y. Answer: πΈ(π) = 0.8, π£ππ(π) = 0.76, πΈ(π) = 0.4, π£ππ(π) = 0.24; 2. Compute the expected value of X*Y and the covariance and correlation between X and Y. Answer: πΈ(π ∗ π) = 0.5, πππ£ππ(π, π) = 0.18, ππππππ(π, π) = 0.4215; 3. Derive the conditional pmf of Y given X for all possible values of X. Answer: ππ¦|π₯ (0|0) = 0.8, ππ¦|π₯ (1|0) = 0.2, ππ¦|π₯ (0|1) = 0.5, ππ¦|π₯ (1|1) = 0.5, ππ¦|π₯ (0|2) = 1⁄3, ππ¦|π₯ (1|2) = 2⁄3; 4. Generate 1000 values of X using the marginal pmf of X as follows: input random numbers in the range A2:A1001 and generate random values of X in cells B2:B1001. Example for cell B2: = πΌπΉ(π΄2 < .5,0; πΌπΉ(π΄2 < .7; 1; 2)) and similarly for cells B3:B1001. Use the conditional pmf of Y given X to generate 1000 values of Y in cells C2:C1001. Example for cell C2: = πΌπΉ (π΅2 = 0; πΌπΉ(π π΄ππ·( ) < .8; 0; 1); πΌπΉ(π΅2 = 1; πΌπΉ(π π΄ππ·( ) < .5; 0; 1); πΌπΉ(π π΄ππ·( ) < 1⁄3; 0; ,1))) and similarly for cells C3:C1001. In cell D11, compute the (sample) covariance of the first ten observations: = πΆπππ΄π πΌπ΄ππΆπΈ. π(π΅$2: π΅11; πΆ$2: πΆ11). Similarly for cells D12:D1001 for the first 11, 12, … observations. In cell E11 compute the correlation coefficient of the first 10 observations: = πΆππ π πΈπΏ(π΅$2: π΅11; πΆ$2: πΆ11) and similarly for cells E12:E1001 for the first 11, 12, … observations. Report the values 10, 11, 12, …, 1000 in cells F11:F1001. Use columns F and D to graph the evolution of the sample covariance as a function of the sample size (use the option Scatter with Straight Lines and Markers). Add a straight line for the value of πππ£ππ(π, π) as computed in Step 2. In a similar way use columns F and E to graph the evolution of the sample correlation. Assignment PA170 Consider the Assignment in Problem PP135. Compute the expected values, the variances and the standard deviations of X and Y. Compute the covariance and the correlation between X and Y. Generate 1000 values of X and Y. As in Step 4 compute the sample covariance and correlation of the first 10, 11, 12, …,1000 observations. Graph the evolution of the sample covariance and correlation as in Step 4. 206 Problem PP171 The sides of two coins are numbered 1 and 2. Both coins are tossed. Let X be the sum of the numbers on both coins and Y the maximum. 1. Derive the joint pmf of X and Y. Answer: Y: Maximum Marginal X 1 2 2 .25 .25 X: Sum 3 .5 .5 Marginal Y 4 .25 .25 .25 .75 2. Derive the marginal pmf of X and Y. Answer: see Table in Step 1; 3. Compute the expected values, the variances and the standard deviations of X and Y. Answer: πΈ(π) = 3, ππ2 = 0.5, ππ = √. 5 , πΈ(π) = 1.75, ππ2 = .1875, ππ = √. 1875; 4. Compute the covariance and the correlation between X and Y. Answer: πππ£ππ(π, π) = 1⁄4, ππππππ(π, π) = √2⁄3 = 0.8165; 5. Compute ππ΄π (π − π) from the results in Step 3 and 4. Answer: ππ΄π (π − π) = 3⁄16; 6. Generate 1000 values of the two coins in cells A2:B1001, the values of the sum X in cells C2:C1001, the values of the maximum Y in cells D2:D1001. Derive the sample estimates of the results in Step 1 to Step 5 and compare with the exact results. Assignment PA171 Two sides of a die are colored blue, two sides are colored green and two sides are colored red. When rolling the die, define the random variables B (π΅ = 1 when outcome is blue, 0 otherwise) and R (π = 1 when the outcome is red, 0 otherwise). Compute the covariance and the correlation between B and R. Compute the variance of the sum π΅ + π . Simulate the problem over 1000 lines and compute the sample covariance and sample correlation between B and R. Compute the sample variance of π΅ + π . Compare the sample values with the exact results. 207 Problem PP172 Consider Problem PP136. 1. Compute the covariance and the correlation between X and Y. Does the sign of the correlation make intuitive sense? Why? Answer: πππ£ππ(π, π) = 0.9452, ππππππ(π, π) = 0.4795; 2. Compute πΈ(1⁄π), π£ππ(1⁄π) πππ π π‘πππ£(1⁄π). Answer: πΈ(1⁄π) = 0.5514, π£ππ(1⁄π) = .0984, π π‘πππ£(1⁄π) = .3137; 3. Verify that πΈ(1⁄π) = .5514 ≠ 1⁄πΈ(π) = .3956; 4. Compute πΈ(π⁄π), π£ππ(π⁄π). Verify that πΈ(π⁄π) = 2.275 ≠ πΈ(π)⁄πΈ(π) = 1.7692 and that πΈ(π⁄π) = 2.275 ≠ πΈ(π) ∗ πΈ(1⁄π) = 2.4659; 5. Compute πππ£ππ(π, 1⁄π ) and ππππππ(π, 1⁄π ) using the results in Steps 2 and 4. Answer: πππ£ππ(π, 1⁄π) = −.1909, ππππππ(π, 1⁄π) = −.4335; 6. Compute πΈ(π⁄π) and π£ππ(π⁄π). Answer: πΈ(π⁄π) = .5833, π£ππ(π⁄π) = .0713; 7. Compute πππ£ππ(π⁄π , π⁄π) en ππππππ(π⁄π , π⁄π) using the results in Steps 4 and 6. Answer: πππ£ππ(π⁄π , π⁄π) = −.3271, ππππππ(π⁄π , π⁄π) = −.8766; 8. Generate values of X and Y as in Step 3 of Problem PP136. Compute the values of π⁄π, π⁄π πππ 1⁄π in columns E, F and G. Compute all sample analogues of the results in Steps 1 to 7. Compare the sample values with the exact theoretical results. Assignment PA172 Consider Assignment PA136. Compute πππ£ππ(π, π), ππππππ(π, π), πππ£ππ(π⁄π , π⁄π), ππππππ(π⁄π , π⁄π). Generate 1000 values of X and Y. Compute π⁄π and π⁄π in columns C and D. Compute estimates of the four parameters from the sample data. Repeat the simulation a number of times and compare the sample values with the exact theoretical values. 208 Problem PP173 Consider the random variables in Problem PP135 and Problem PP170. 1. Compute the variance of the sum π + π from the pmf as derived in Step 5 of Problem PP135. Answer: π£ππ(π + π) = 1.36; 2. Compute the variances of X and Y and the covariance between X and Y. Answer: π£ππ(π) = 0.76, π£ππ(π) = 0.24, πππ£ππ(π, π) = 0.18; 3. Compute the variance of the sum π + π from the results in Step 2; 4. Generate 1000 values of X and Y as in Step 4 of Problem PP170. Compute the sum of the values of X and Y in cells D2:D101. Compute the sample variances of X and Y and the sample covariance between the data in columns B and C: = ππ΄π . π(π΅2: π΅1001), = ππ΄π . π(πΆ2: πΆ1001), = πΆπππ΄π πΌπ΄ππΆπΈ. π(π΅2: π΅1001; πΆ2: πΆ1001). Compute the sample variance of the sum π + π in two ways: directly from the data in column D: = ππ΄π . π(π·2: π·1001) and indirectly from the sample variances and the sample covariance: = ππ΄π . π(π΅2: π΅1001) + ππ΄π . π(πΆ2: πΆ1001) + 2 ∗ πΆπππ΄π πΌπ΄ππΆπΈ. π(π΅2: π΅1001; πΆ2: πΆ1001). Compare both results. Compare the sample variance of the sum with the exact value computed in Step 3. Assignment PA173 Consider the random variables X and Y in Assignments PA135 and PA170. In PA170 you have computed π£ππ(π) = 0.5, π£ππ(π) = 1, πππ£ππ(π, π) = 0.5. Derive π£ππ(π − π) from these results. What is the meaning of the random variable π − π in this problem? Derive the variance of π − π from this new interpretation. Simulate 1000 values of X and Y, compute the differences π − π and the sample variance of the differences. Compute the sample variances of X and Y and the sample covariance between X and Y. Compute again the sample variance of the differences π − π from these results. Compare the results of both approaches. 209 Problem PP174 Consider Problem PP136 and Problem PP172. 1. Compute π£ππ(π − π) using the pmf of π − π derived in Step 8 of Problem PP136. Answer: 2.0525; 2. From the marginal pmf of X and Y derived in Step 2 of Problem PP136, compute π£ππ(π) and π£ππ(π). Answer: π£ππ(π) = π£ππ(π) = 1.9715; 3. Compute πππ£ππ(π, π) using the joint pmf of X and Y derived in Step 1 of Problem PP136. Answer: 0.9452; 4. Derive π£ππ(π − π) from the results in Step 2 and 3. Answer: see Step 1; 5. Start from the simulated values in Step 3 of Problem 136 or Step 2 in Problem PP172. Compute the sample variance of the values π − π generated in column E; 6. Compute the sample variances and the sample covariance of the values of X and Y generated in columns D and C; 7. Derive the sample variance of the values of π − π from the results in Step 6; 8. Compute π£ππ(π + π) using the pmf of π + π derived in Step 8 of Problem PP136. Answer: 5.8333; 9. From the results in Step 2 and 3 again compute the variance of π + π. Answer: see Step 8; 10. Call the result of rolling a die T. What is the value of 2 ∗ π£ππ(π)? Compare with the results in Step 8 and 9. Explain; 11. Start from the simulated values in Step 3 of Problem PP136 or Step 2 in Problem PP172. Compute the sample variance of the values π + π generated in column F; 12. Derive the sample variance of the values of π + π generated in column F from the results in Step 6; 13. Let π1 and π2 be the outcome on the first and the second die in columns A and B. Compute the sample variances and the sample covariance of the data generated in columns A and B. From these values derive the sample variance of the values π1 + π2 and compare with the values in Steps 11 and 12. Explain. 210 Assignment PA174 Consider the random variables X and Y defined in PA136 and PA172. Derive the pmf of π − π from the joint pmf of X and Y. Derive π£ππ(π − π) from the pmf of π − π. Compute the expected values and variances of X and Y. Compute the covariance between X and Y. Derive π£ππ(π − π) using π£ππ(π), π£ππ(π) and πππ£ππ(π, π). Compare both results. Generate 1000 values of X, Y and π − π. Compute the sample variance of π − π in two ways: firstly, from the 1000 differences and secondly from the sample variance of X, the sample variance of Y and the sample covariance between X and Y. 211 Problem PP175 Random variables X and Y have a variance equal to 1 and ππππππ(π, π) = π. For any constant c let π = π + ππ and π = π + ππ. 1. Derive πππ£ππ(π, π) and ππππππ(π, π). Answer: πππ£ππ(π, π) = π + ππ 2 + 2π, ππππππ(π, π) = π+ππ 2 +2π 1+π 2 +2ππ ; 2. Check the correlation when π = 1. Explain; 3. Assume X and Y are bivariate normal with πΈ(π) = 10, πΈ(π) = 20, π£ππ(π) = π£ππ(π) = 1, π(π, π) = π. Generate 1000 values of X in cells A2:A1001: = πππ π. πΌππ(π π΄ππ·( ); 10; 1), generate 1000 values of Y in cells B2:B1001 for π = 0.5 . Example for cell B2: = πππ π. πΌππ (π π΄ππ·( ); 20 ∗ .5 ∗ (π΄2 − 10); πππ π(1 − ππππΈπ (. 5; 2))). In columns C and D report values of Y for π = 0 and π = −0.5. Let π = 4. In columns E and F report values of V and W for π = 0.5, in columns G and H report values of V and W for π = 0, in columns I and J report values of V and W for π = −0.5. Based on the results in Step 1 compute the covariance and the correlation between V and W for the three different correlations between X and Y. Compute the sample covariances and sample correlations and compare with the exact theoretical values. Assignment PA175 Two analysts measure a same variable Y. The measurements involve errors. Let ππ be the value measured by analyst π, π = 1, 2 and assume ππ = π + ππ , π = 1,2. Assume that π1 and π2 are independent and that both are also independent of Y. Let πΈ(π1 ) = πΈ(π2 ) = 0 (both analysts expect to measure Y correctly), π£ππ(π1 ) = π£ππ(π2 ) = π 2 and π£ππ(π) = π 2 . Compute the covariance and the correlation between both measurements as a function of π 2 and π 2 . When is the correlation minimal, when maximal? Generate 1000 values of Y in cells A2:A1001 (assume Y to be normally distributed with expected value 100 and standard deviation 2), generate 1000 values of π1 (π2 ) in cells B2:B1001 (C2:C1001) (assume both to be standard normally distributed). Compute the values of π1 (π2) in column D (E). Compute the sample covariance and the sample correlation between π1 and π2 and compare with the exact values computed in Step 1. 212 Problem PP176 Random variable Z is standard normally distributed. Let π = 2 ∗ π and π = π 2 . 1. Compute the correlation between Z and X. Answer: π(π, π) = 1. Explain; 2. Compute the correlation between Z and Y. Are Z and Y independent? Explain. Answer: π(π, π) = 0. Z and Y are not independent; 3. Generate 1000 values of Z in A2:A1001: = πππ π. π. πΌππ(π π΄ππ·( )). Generate the corresponding values of X and Y in columns B and C. Compute the sample correlation between Z and X and between Z and Y. Compare the sample correlations with the exact correlations. Assignment PA176 Random variable Z is uniformly distributed on the interval (-1 1). Let π = 2 ∗ π and π = π 2 . Compute the covariance and the correlation between Z and X. Compute the covariance and the correlation between Z and Y. Generate 1000 values of Z, X and Y. Compute the sample covariances and correlations between Z and X and between Z and Y. Compare the sample estimates with the exact theoretical values. 213 Problem PP177 For random variables X and Y it holds that πΈ(π) = πΈ(π) = π, π£ππ(π) = ππ2 , π£ππ(π) = ππ2 and πππ£ππ(π, π) = πππ . Assume that the expected value π is not known but that the variances and the covariance are known. We estimate the expected value by π = ππ + (1 − π)π where a is a constant to be determined. 1. Show that πΈ(π) = π for any value of a (the expected value of the estimate is “correct”); 2. Determine the value of a for which π£ππ(π) is minimal. Answer: π = (ππ2 − πππ )⁄(ππ2 + ππ2 − 2 ∗ πππ ); 3. Assume the joint density of (π, π) is bivariate normal with parameters π = 10, ππ2 = 4, ππ2 = 1, πππ = −1. It follows that the correlation π(π, π) = −0.5. Report the value of the correlation in cell A1, the value of the covariance in cell B1. Generate 1000 values of X in cells A2:A1001: = πππ π. πΌππ(π π΄ππ·( ); 10; 2). Generate 1000 values of Y in cells B2:B1001. Example for cell B2: = πππ π. πΌππ (π π΄ππ·( ); 10 + $π΄$1 ∗ (π΄2−10) 2 ; πππ π(1 − $π΄$1 ∗ $π΄$1)). Input different values of a in cells C1:K1: -2, -1.5, -1, -.5, 0, .5, 1, 1.5, 2. In cell L1 input the value of a derived in Step 2: = (1 − $π΅$1)⁄(4 + 1 − 2 ∗ $π΅$1). Compute the values of W for the different values of a in columns D to M. Example for cell D2: = π·$1 ∗ $π΄2 + (1 − π·$1) ∗ $π΅2 and likewise for cells D3:D1001 and columns E to M. Repeat the values of a in cells O1:X1. Compute the averages of the values of W in cells O2:X2 for the different values of a. Compare the averages with the result in Step 1. Compute the sample variances of the values of W in cells O3:X3 for the different values of a. For which value of a is the sample variance minimal? Compare this result to the conclusion drawn in Step 2; 4. Change the value of the correlation (and the covariance) in cell A1 (B1) to different values and always check the results in O2:X2 and O3:X3. Assignment PA177 Random variables S and V are derived from random variables X and Y: π = π + π, π = π − π. Show that πππ£ππ(π, π) = π£ππ(π) − π£ππ(π). Generate 1000 values of X, Y, S and V. Assume that (π, π) are bivariate normal with parameters πΈ(π) = 10, π£ππ(π) = 1, πΈ(π) = 20, π£ππ(π) = 4, π(π, π) = 0.5 and compute the sample covariance between S and V. Compare with πππ£ππ(π, π). 214 Problem PP178 Random variable X is uniformly distributed over the interval (0 1). 1. Compute πππ£ππ(π, π π ) for any constant π > 0. Answer: πππ£ππ(π, π π ) = π⁄(2 ∗ (π + 1) ∗ (π + 2)); 2. Derive the value of k for which the covariance is maximal. Answer: π = √2; 3. Graph the covariance as a function of k for k in the interval (0 12); 4. Compute ππππππ(π, π π ) for any π > 0. Answer: ππππππ(π, π π ) = √3 ∗ (2π + 1)⁄(π + 2); 5. Derive the value of k for which the correlation is maximal. Answer: π = 1; 6. Graph the correlation as a function of k for k in the interval (0 12); 7. Generate values of X in the range A2:A1001. Compute the values of π π for π = 0.5, 2, 3, 4, 5 in columns B, C, D, E, F. Compute the sample covariances and correlations between X and π π and compare with the exact values derived in Steps 1 and 4. Assignment PA178 A random variable X is uniformly distributed over the interval (1 2). A square has a side of length X. Compute the covariance and the correlation between the circumference and the area of the square. Generate 1000 values of X. Compute the circumference and the area of the 1000 squares. Compute the sample covariance and the sample correlation and compare to the exact values. 215 Problem PP179 For any constant a, −1 < π < 1, and π1 and π2 independent standard normal random variables, 1+π consider random variables X and Y: π = √ 2 1−π ∗ π1 + √ 2 1+π ∗ π2 , π = √ 2 1−π ∗ π1 − √ 2 ∗ π2 . 1. Compute the covariance and the correlation between X and Y. Answer: πππ£ππ(π, π) = π, ππππππ(π, π) = π; 2. Derive the joint pdf of X and Y. Answer: bivariate normal with πΈ(π) = πΈ(π) = 0, π£ππ(π) = π£ππ(π) = 1, π(π, π) = π; 3. Report a value of a in cell A1, e.g. π = 0.8. Generate 1000 values of π1 and π2 in cells A3:A1002 and B3:B1002. Example for cell A3: = πππ π. π. πΌππ(π π΄ππ·( )) and likewise for cells A4:A1002 and column B. Compute the values of X and Y in columns C and D for the value of a in cell A1. Example for cell C3: = πππ π((1 + $π΄$1)⁄2) ∗ π΄3 + πππ π((1 − $π΄$1)⁄2) ∗ π΅3 and likewise for cells C4:C1002 and column D. Compute the sample covariance between X and Y and compare with the value in cell A1. Change the value in cell A1 to .2, to 0, to -.5. Assignment PA179 Let π1 and π2 be independent standard normal random variables. For constants π1 , π2 , π1 , π2 πππ 0 < π < 1, let π = π1 + π1 ∗ π1 and π = π2 + π2 ∗ (π ∗ π1 + √1 − π2 ∗ π2 ). Compute the covariance and the correlation between X and Y. Derive the joint pdf of X and Y. Generate 1000 values of π1 , π2 , X and Y for π1 = 2, π2 = 4, π1 = −3, π2 = 2, π = 0.5. Compute the sample covariance and the sample correlation between X and Y. Compare to the exact theoretical values. 216 Problem PP180 Consider the random variables X and Y in Problem PP167. 1. Compute the covariance between X and Y. Answer: πππ£ππ(π, π) = 1⁄π2; 2. Compute the correlation between X and Y. Answer: ππππππ(π, π) = √2⁄2; 3. Compute πΈ(ππ − π) and π£ππ(ππ − π). Answer: πΈ(ππ − π) = (π − 2)⁄π, π£ππ(ππ − π) = 1 + 2⁄π2 − 2⁄π ; 4. To simulate the above results, report a value of λ in cell A1, say π = 2. Generate 1000 values of X (Y) in cells A3:A1002 (B3:B1002). Example for cell A3: = πΊπ΄πππ΄. πΌππ(π π΄ππ·( ); 1; 1⁄$π΄$1). Example for cell B3:= π΄3 − (1⁄$π΄$1) ∗ ππ(π π΄ππ·( )). Compute the values of ππ − π in cells C3:C1002. Compute the sample covariance and sample correlation between X and Y. Compare with the values in Step 1 and 2. Compute the sample mean and the sample variance of ππ − π in column C and compare with the values derived in Step 3. Assignment PA180 Consider the random variables in Problem PA167. Compute the covariance and the correlation between X and Y. Generate 1000 values of Y and X, compute the sample covariance and sample correlation and compare with the exact theoretical values. 217 Problem PP181 A machine produces parts which can be one of four different kinds: the part satisfies all requirements (probability is 0.8), it can be reworked and then satisfies the requirements (probability is 0.05), it has insufficient length and is total loss (probability is 0.1) or it has insufficient width and is total loss (probability is 0.05). The selling price of the part is €18, the unit production cost is €10, the cost of reworking a part is €5. A lot of 1000 parts will be produced today. Let S be the number of parts that satisfy all requirements, R the number of parts to be reworked, L the number of parts of insufficient length and W the number of parts of insufficient width. 1. Compute the expected value and the variance of S and R. Answer: πΈ(π) = 800, πΈ(π ) = 50, π£ππ(π) = 160, π£ππ(π ) = 47.5; 2. Compute the covariance and correlation between S and R. Answer: πππ£ππ(π, π ) = −40, ππππππ(π, π ) = −.4588; 3. Express the total profit of the lot P as a function of S and R. Answer: π = 18 ∗ π + 13 ∗ π − 10000; 4. Compute the expected value of P. Answer: πΈ(π) = 5050; 5. Compute the standard deviation of P. Answer: ππ = 202.8485; 6. To simulate the problem, generate 1000 random numbers in the range A2:A1001. Generate the quality of 1000 parts in cells B2:B1001. Example for cell B2: = πΌπΉ (π΄2 < .8; "π";πΌπΉ(π΄2 < .85; "π ";πΌπΉ(π΄2 < .95; "πΏ";"π"))) and similarly for cells B3:B1001. Compute the profit made on the parts in cells C2:C1001. Example for cell C2: = πΌπΉ(π΅2 = "π";8; πΌπΉ(π΅2 = "π ";3; −10)) and similarly for cells C3:C1001. Compute the total number of S-parts in cell E2, the total number of R-parts in cell F2, the total number of L-parts in cell G2, the total number of W-parts in cell H2 and the total profit of the 1000 parts in cell I2. Use the TABLE-option of Excel to generate these values 1000 times. Compute the sample averages and sample variances of S and R and compare with the values computed in Step 1. Compute the sample covariance and correlation between S and R and compare with the values in Step 2. Compute the sample mean of profits and compare with the expected value computed in Step 4. Compute the sample standard deviation of profit and compare with the standard deviation computed in Step 5. 218 Assignment PA181 A die is rolled 60 times. Let X be the number of times an even number is rolled and Y the number of times the outcome 1 is obtained. Compute the expected values and variances of X and Y, compute the covariance and the correlation between X and Y. Compute the expected value and the variance of π + π using the previous results. Compute again the expected value and the variance of π + π using results from a binomial process. Generate 60 rolls of a die. Compute the value of X, Y and π + π and use the TABLE-option to repeat this process 1000 times. Compute sample estimates of the expected values, variances, covariance and correlation computed above and compare the sample estimates to the exact values. 219 Problem PP182 Two risky assets have random returns π 1 and π 2 over the next period. Let π1 = πΈ(π 1 ), π2 = πΈ(π 2 ) be the expected returns, π1 = π π‘πππ£(π 1 ), π2 = π π‘πππ£(π 2 ) be the standard deviations of the returns and π12 = ππππππ(π 1 , π 2 ), the correlation between both returns. A portfolio P is built by investing a capital of 1 for a proportion π1 in asset 1 and a proportion π2 = 1 − π1 in asset 2 (no short selling, so 0 ≤ π1 ≤ 1). 1. Derive the expected return and the variance of the portfolio. Answer: π(π) = π1 ∗ π1 + (1 − π1 ) ∗ π2 , π 2 (π) = π12 ∗ π12 + (1 − π1 )2 ∗ π22 + 2 ∗ π1 ∗ (1 − π1 ) ∗ π12 ∗ π1 ∗ π2 ; 2. Derive the proportions π1π and π2π to be invested in both assets when minimizing the risk (risk being measured by the variance of the portfolio). π2 −π ∗π1 ∗π2 12 Answer: π1π = π2 +π2 2 −2∗π 1 2 12 ∗π1 ∗π2 , possibly corrected to 0 when the ratio is negative and to 1 when the ratio is larger than 1 (this correction is not required when short selling is allowed), π2π = 1 − π1π ; 3. Assume π1 = 0.14, π2 = 0.08, π1 = 0.2, π2 = 0.15, π12 = 0. Report these values in cells A3:E3. For all values of π1 between 0 and 1 in steps of 0.05 (cells A5:A25), compute the expected return of the portfolio in cells B5:B25, the standard deviation of the portfolio in cells C5:C25 using the results in Step 1 (use the values in cells A3:E3). Use a scatter plot to graph the expected value (on the vertical axis) versus the standard deviation (on the horizontal axis); 4. For the parameter values in Step 3, compute the portfolio ππ with minimal variance (also minimal standard deviation) using the result in Step 2. Answer: π1π = 0.36, π2π = 0.64, πΈ(ππ ) = 0.1016, π 2 (ππ ) = 0.0144, π(ππ ) = 0.12. 5. Assume a risk averse investor (preferring less risk for the same expected return and more expected return for the same risk), indicate in the graph in Step 3 the portfolios that are not dominated by other possible portfolios (the so called efficient frontier); 6. Use the Solver to compute the minimal variance portfolio as already derived in Step 4; 7. Compute the portfolio with minimal risk when requiring an expected profit of at least 0.11. Answer: π1 = .5, π2 = .5, πΈ(π) = 0.11, π 2 (π) = 0.125, π(π) = 0.3535; 8. Compute the portfolio with minimal risk when requiring an expected profit of at least 0.10. Answer: π1 = .36, π2 = .64, πΈ(π) = 0.1016, π 2 (π) = 0.0144, π(π) = 0.12; 220 9. Use the Solver to derive the portfolios computed in Steps 7 and 8; 10. Change the value of the correlation in cell E3 to .25, .5, 1, -.25, -.5, -1 and check how the graph derived in Step 3 changes; 11. For values of the correlation between -1 and +1, steps of 0.1 (cells A32:A52), use Excel to compute the value of π1 and the standard deviation of the minimal variance portfolio. Graph the standard deviation as a function of the correlation. Justify intuitively the shape of this graph; 12. Assume both returns are normally distributed. Compute the portfolio of maximal expected return but for which the probability of a loss of at least 0.08 is limited to 0.1. Use both hand computation and the Solver. Answer (rounded): π1 = .796, πΈ(π) = .1278, π π‘πππ£(π) = 0.1621. Assignment PA182 Perform Steps 1, 2, 3, 5, 7 and 8 for the case of one risky asset (π1 = .15, π1 = .25) and one riskfree asset (π2 = .06, π2 = 0). In Step 12 assume a loss of at least .15 limited to a probability of 0.01. 221 Problem PP183 Three assets have random returns π 1 , π 2 and π 3 over the next period. Expected returns are 0.1, 0.2 and -0.02. Variances are 0.015, 0.02 and 0.005. Correlations are: π12 = 0.5, π13 = −0.4 and π23 = −0.2. Report the expected values in cells B2:D2, the variances in cells B3:D3, the correlation matrix in the range B7:D9. 1. Compute the covariance matrix in the range G7:I9. Answer: .015 .00866 -.00346 .02 -.002 .005 2. Consider all possible portfolios of the three assets (steps of .05) in cells A13:C242 (no short selling). For example start with 0, 0, 1 in cells A13:C13 (all funds invested in asset 3), 0, 0.05, 0.95 in cells A14:C14 (5% invested in asset 2, 95% in asset 3), etc. Compute the expected returns of all portfolios in column D. Example for cell D13: = π΄13 ∗ $π΅$2 + π΅13 ∗ $πΆ$2 + πΆ13 ∗ $π·$2. Compute the standard deviation of all portfolios in column E. Example for cell E13: = πππ π(π΄13 ∗ π΄13 ∗ $π΅$3 + π΅13 ∗ π΅13 ∗ $πΆ$3 + πΆ13 ∗ πΆ13 ∗ $π·$3 + 2 ∗ π΄13 ∗ π΅13 ∗ $πΊ$8 + 2 ∗ π΄13 ∗ πΆ13 ∗ $πΊ$9 + 2 ∗ π΅13 ∗ πΆ13 ∗ $π»$9); 3. Graph a Scatter Plot (Scatter with only markers) of the standard deviation (horizontal axis) versus the expected value (vertical axis). The efficient portfolios can be clearly seen on the graph; 4. Underneath the graph put three fractions adding up to 1 in cells H38:J38, e.g. .7, .1, .2. Compute the expected value and the standard deviation of the portfolio in cells K38:L38 by copying any of the cells in column D in cell K38 and any of the cells in column E in cell L38. Compute the sum of the fractions in cell M38: = πππ(π»38: π½38). Construct a horizontal line segment from the point (0 =K38) to the point (=L38 =K38) as follows: 0 in cell H40, =K38 in cell I40, =L38 in cell H41, =K38 in cell I41. Add the two series in cells H40:I41 to the graph (as Scatter with straight lines). Construct a vertical line segment from the point (=L38 0) to the point (=L38 K38) similar to the construction of the horizontal segment. Notice that the line segments join in the point that represents the standard deviation and expected value of the portfolio with fractions in H38:J38. Change the fractions and check how the graph changes; 5. Use the Solver to compute the portfolio with minimal standard deviation (minimal risk) in cell L38. Allow cells H38:J38 to change. Check the graph. Answer: π(π) = 0.0477 (cell L38); π(π) = 0.0264 (cell K38); fractions to be invested (cells H38:J38): 0.2688, 0.0641, 0.6671; 222 6. Use the Solver to minimize the standard deviation of the portfolio (cell L38) under the restriction that the expected return (cell K38) be at least 0.12. Check the graph. Answer: : π(π) = 0.086; π(π) = 0.12, fractions to be invested (cells H38:J38): 0.173, 0.542, 0.285; 7. Change the expected return required in Step 6 to different values. Notice that when an expected return smaller than 0.02636 (expected return corresponding to the portfolio with minimal risk) is required, then the solution is the minimal risk portfolio. Assignment PA183 Keep the data above with the following changes: the variance of asset 1 is 0 (asset with no risk), the correlations between the return of asset 1 with both other returns are 0. Repeat Steps 1 to 7 above. What does the efficient set of non-dominated portfolios look like? 223 Problem PP184 N assets have random returns π 1 , π 2 , … , π π over the next period. Expected returns are ππ = [π1 π2 … ππ ]. Standard deviations are π1 , π2 , … , ππ . Denote the covariance matrix by π. A capital of 1 is available to invest in the assets. Let the proportions invested in the assets be denoted as ππ = [π1 π2 … ππ ] with ∑π 1 ππ = 1. 1. Compute the expected return and the variance of the portfolio (use matrix notation). Answer: πΈ(π) = ππ π, π 2 (π) = ππ ππ; 2. Use the data and the set-up of the Excel sheet in Problem PP183, first 9 lines. Assume fractions ππ = [. 1 .6 .3] in cells H12:J12. Compute the expected value of the portfolio in cell G14 using the array instruction: = ππππΏπ(π»12: π½12; ππ π΄ππππππΈ(π΅2: π·2)). Compute the variance in cell G15 using the array instruction: = ππππΏπ(ππππΏπ(π»12: π½12; πΊ7: πΌ9); ππ π΄ππππππΈ(π»12: π½12)). Compare expected value and variance with the values computed in Step 2 of Problem PP183 (note: the standard deviation was computed there, not the variance); 3. Derive the weights a for the portfolio with minimal variance (short selling allowed). Compute its expected value and variance. Answer: π = π−1 π⁄1π π−1 π (1 is a N dimensional vector of ones), πΈ(π) = ππ π−1 π⁄ππ π−1 π, π 2 (π) = 1⁄ππ π−1 π ; 4. To compute the minimal variance portfolio, its expected value and variance, use the results of Step 3 as follows: first compute the inverse covariance matrix in the range L7:N9. To do so, select cells L7:N9 and use the array instruction: = ππΌπππΈπ ππΈ(πΊ7: πΌ9). Report the values 1, 1 and 1 in cells H17:J17. Select cells G18:G20 and compute the weights of the minimal variance portfolio using the array instruction: = ππππΏπ(πΏ7: π9; ππ π΄ππππππΈ(π»17: π½17))⁄ππππΏπ(ππππΏπ(π»17: π½17; πΏ7: π9); ππ π΄ππππππΈ(π»17: π½17)) Compute the expected value of the minimal variance portfolio in cell G22 (array instruction): = ππππΏπ(ππππΏπ(π»17: π½17; πΏ7: π9); ππ π΄ππππππΈ(π΅2: π·2))⁄ππππΏπ(ππππΏπ(π»17: π½17; πΏ7: π9); ππ π΄ππππππΈ(π»17: π½17)) Use a similar instruction to compute the variance in cell G23: = 1⁄ππππΏπ(ππππΏπ(π»17: π½17; πΏ7: π9); ππ π΄ππππππΈ(π»17: π½17)); 5. Use the Solver to compute the minimal variance portfolio. Work as follows: any weights in H25:J25. Cell K25: = πππ(π»25: π½25). Cell G27: = ππππΏπ(ππππΏπ(π»25: π½25; πΊ7: πΌ9); ππ π΄ππππππΈ(π»25: π½25)), the variance of the portfolio. Use the Solver to minimize cell G27, restriction that cell K25 equals 1. Compute the expected return of the minimal variance portfolio in cell G28. Compare expected value and variance with the same values computed in Step 4; 6. Derive the weights a for the portfolio with minimal variance among all portfolio’s with an expected return of at least ππππ (short selling allowed). Answer: Let πΆ = π−1 π, π· = π−1 π, π1 = ππ πΆ, π2 = ππ π·, π3 = ππ π·. 224 Then, 1 π = π π −π 2 [π1 π· − π3 πΆ + ππππ (π2 πΆ − π3 π·)]; 1 2 3 7. On the Excel sheet compute the vector values of πΆ and π· in cells G31:G33 and H31:H33, the values of the constants π1 , π2 πππ π3 in cells G36:I36. In cells G40:G58 input values of ππππ : -.02, -.01, 0, .0125, .025, .0375, …, 0.2. Select cells H40:J40 and compute the value of the vector ππ for ππππ = −.02 (array instruction): = (1⁄($πΊ$36 ∗ $π»$36 − $πΌ$36 ∗ $πΌ$36)) ∗ ($πΊ$36 ∗ ππ π΄ππππππΈ($π»$31: $π»$33) − $πΌ$36 ∗ ππ π΄ππππππΈ($πΊ$31: $πΊ$33) + πΊ40 ∗ ($π»$36 ∗ ππ π΄ππππππΈ($πΊ$31: $πΊ$33) − $πΌ$36 ∗ value of ππ compute the expected value of the portfolio in cell K40 (should be -.02), its variance in cell L40 (.003531) and its standard deviation in cell M40. Drag cells H40:M40 to line 58. For minimal expected values as given in cells G40:G58 we have available the efficient portfolios (with minimal standard deviation). Make a scatter plot (with full lines) of the expected value (vertical axis) versus the standard deviation (horizontal axis); ππ π΄ππππππΈ($π»$31: $π»$33))). Using this 8. Use the Solver to compute the efficient portfolio for a minimal expected return of 0.125. Report fractions adding up to 1 in cells G61:G63. In cell G64: = πππ(πΊ61: πΊ64). Compute the expected return in cell I61: = ππππΏπ(π΅2: π·2; πΊ61: πΊ63), the variance in cell I62: = ππππΏπ(ππππΏπ(ππ π΄ππππππΈ(πΊ61: πΊ63; πΊ7: πΌ9); πΊ61: πΊ63)). Minimize cell I62, requiring cell G64 to be 1 and cell I61 at least 0.125. Change the value of the minimal expected return to 0.02 and solve the problem again (notice some short selling). Using the Solver you can forbid short selling by requiring all fractions to be nonnegative. Assignment PA184 Consider 4 assets with expected returns π = [. 1 .3 .4 .2] and standard deviations π = [0 .05 .1 .07] (asset 1 is a non-risk asset). Correlations are: π23 = .5, π24 = −.4, π34 = −.2. Compute the covariance matrix of the returns of assets 2, 3 and 4. Compute the expected return, the variance and the standard deviation of a portfolio with fractions .2, .3, .4 and .1. Use the Solver to compute the optimal portfolio (minimal variance) for expected values of at least .1, .125, .15, …, .4 (short selling allowed). Compute the expected value, the variance and the standard deviation for each portfolio. Next compute optimal portfolio’s using only the risky assets 2, 3 and 4 for the same expected returns .1, .125, …, .4. For these portfolios assume it is required that the restriction on the expected value is exactly equal to (rather than at least equal to). Construct in the same graph (Scatter plot with full lines) the expected values (vertical axis) as a function of the standard deviations (horizontal axis) for both types of portfolios (with and without the no-risk asset). Notice how the efficient set of the four asset model is a straight line tangent to the efficient set of the three asset model). Denote the vector of expected returns of the risky assets by ππ and the return of the non-risky asset by πππ . Then it can be shown that the weights of the tangency portfolio are given by π−1 (ππ − πππ π)⁄1π π−1 (ππ − πππ π). Compute these weights and derive the expected return, the variance and the standard deviation of the tangent portfolio.