In: Statistics and Probability
Numerical proof of Var(X + Y ) = σ 2 X + σ 2 Y + 2Cov(X, Y ):
***Please use R commands, that is where my confusion lies***
2.1 State how you create a dependent pair of variables (X, Y), give Var(X), Var(Y ), Cov(X, Y ), and Var(X + Y ).
2.2 Choose a sample size n and generate (xi , yi), i = 1, . . . , n according to the (X,Y) distribution. Give the sample variances of the x-sample and y-sample, the sample covariance of the (x,y)-sample, and the sample variance of the x+y sample.
2.3 Turn in all R commands and the output showing the results.
x = rnorm(100)
> x
[1] -1.39508770 1.23749355 -0.89043356 -0.44246252 -0.48219278
0.51737739
[7] 0.43736545 -1.44127576 0.69844128 1.30431716 1.73347160
0.64656737
[13] 0.31893521 0.54369421 0.35821053 0.11477235 2.72183527
-0.07533421
[19] 1.07264450 0.04917985 -0.45877550 0.09283623 -0.81798545
1.25331236
[25] 0.01787277 1.52285714 0.12152447 -0.70239760 -1.40953925
0.89200808
[31] 0.25002911 0.71849054 0.01372816 1.27846813 0.65457045
-1.56526313
[37] -1.13734122 1.16262413 -1.30518708 -2.26470247 0.04927437
0.59248387
[43] -0.70503592 0.38757838 -0.77413858 2.20414858 0.46341609
1.66987966
[49] -1.45606203 -0.07781120 0.77092326 0.27247932 -0.54983058
0.58806113
[55] -1.23299784 1.06557792 0.41021195 1.03193412 0.04105798
0.77148834
[61] 0.35893096 0.86845357 0.28864828 1.33212269 1.93581299
-3.05256071
[67] -1.85968212 0.64204972 1.58389119 1.49517631 -2.35280813
-0.45472439
[73] -0.15203100 -0.67996286 -0.68216879 0.46028269 -0.30063752
1.53658885
[79] -0.81516441 0.00523194 0.91152680 0.17970262 -0.04568688
2.28317716
[85] 0.44593197 1.41122473 0.31333078 -0.28015770 0.25237328
1.50680575
[91] 1.72683184 -0.17421345 0.29580024 1.27976560 -0.74355545
0.57552741
[97] 1.52676155 0.10048627 -0.86818691 0.02072099
> y = rnorm(100)
y
[1] -1.0983263638 -0.5184673180 -0.8567424857 0.1415674881
-0.7077443353
[6] -1.8395133039 -0.7562074951 -1.1142233359 -0.0029848664
-0.8398088289
[11] 1.8925675511 0.6399905309 0.4216333094 -1.5416938450
1.0657257641
[16] -1.6542988080 -0.3504024999 -0.2348931502 -0.4304215765
1.6285713221
[21] 0.5891964381 0.6647065134 -1.7105458715 0.4642969442
0.6156243822
[26] -0.7470505942 -1.1481651434 -0.9800610791 0.0816198654
0.8237707178
[31] 0.1908711658 0.5911551050 2.1933378603 -0.2241243165
-0.1781293926
[36] 0.5187739505 -0.3977168914 0.2219984662 -1.9817542533
0.3777002819
[41] -1.0513677019 0.1834750571 -0.8994811598 0.4036057591
1.6018921021
[46] -1.9966998266 -0.9058871645 -0.0203444836 0.8574151464
-0.2618342709
[51] -0.7319454620 0.0207771138 0.6119090595 0.0166679038
0.0758013497
[56] 0.1781624191 -0.1149452973 0.1017285242 0.6483773150
0.3612698785
[61] 2.1609625209 0.0568131529 -0.1576076703 -0.9983894732
0.0583938540
[66] 0.8859588438 -2.5721344528 0.1797832308 0.2850947954
1.3015514234
[71] -1.2559886548 -0.9803519912 0.7141806280 1.2517711976
-1.3425651735
[76] 0.1470303023 -0.3007137245 -3.3284845691 -0.2297190225
-1.2902136980
[81] -0.0006329613 -1.2105434460 1.5905124270 -0.9110091856
0.8379255734
[86] 1.2344964897 -0.0438162020 0.5891972151 0.1479086952
-0.2537882266
[91] 0.3899007218 0.3257472155 -1.0723836688 -0.1401912752
0.8876566067
[96] 4.0964935535 0.4725501144 0.2153416118 -1.6991137697
1.7160245616
cov(x,y)
[1] 0.06926987
> var(x)
[1] 1.123162
> var(y)
[1] 1.192585
> var(x+y)
[1] 2.454286
> var(x) + var(y) + 2 * cov(x,y)
[1] 2.454286
Thank you for asking. Please rate my answer...!!