Variance of combination of variables

m1 <- 10
v1 <- 2
m2 <- 100
v2 <- 5

# var(x + y) = var(x) + cov(x, y) + var(y)
# if the x and y variables are independent:
# var(x + y) = var(x) + var(y)

(v1 + v2)

# If I use resampling
c1 <- rnorm(100000, mean=m1, sd=sqrt(v1))
c2 <- rnorm(100000, mean=m2, sd=sqrt(v2))

var(c1+c2)

# The resampling method can be used in most of the cases

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04