2

I know the covariance for discrete distributions can be calculated using the cov and cov.wt functions in R. For example the covariance for the below distribution can be solved like this,

enter image description here

weight <- c(.2,.05,.1,.15,.2,.3)

x <- c(100,250,100,250,100,250)

y <- c(0,0,100,100,200,200)

xy <- cbind (x,y)

cov.wt(xy, wt=weight,method='ML')

Result: 1875

Can the covariance for continuous distributions be calculated in a similar way? For instance this question,

enter image description here

The answer is 1.5625 if you do it manually, but how can this be done using R (base R would be preferred). Thanks!

0 Answers0