Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use RStudio for the following problem. Numerical proof of Var(X+Y) = (^2)

ID: 3330239 • Letter: P

Question

Please use RStudio for the following problem.

Numerical proof of Var(X+Y) = (^2)X + (^2)Y + 2Cov(X,Y). State how you create a dependent pair of variables (X, Y), giveVar(X), Var(Y), Cov(X,Y), and Var(X+Y). 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. Turn in all R commands and the output showing the results.

Explanation / Answer

First install the "mvtnorm" library and just run the R-code below:

library(mvtnorm)
n=10000
rho=0.6
data <- rmvnorm(n,rep(0,2),sigma = matrix(c(1,rho,rho,1),2,2))
x <- data[,1]
y <- data[,2]

#Var(X+Y)
var(x+y)

# var(X)+var(Y)+2cov(X,Y)
var(x)+var(y)+2*cov(x,y)