What is exactly the calculation used when calling cov.wt((faithful,c(1,2,3,4))$cov)?

(Say the data faithful has 4 rows and 2 columns, coordinates x,y)

I.e.: What is the formula it uses to compute the weighted covariance matrix $\Sigma$?

The doumentation doesn't say, the internet shows more than one formula and the code is short but I don't understand it and want just a mathematical clear formula.

center <- colSums(wt * x)
x <- sqrt(wt) * sweep(x, 2, center, check.margin = FALSE)
cov <- crossprod(x)/(1-sum(wt^2))
  • $\begingroup$ I believe the solution can be found here. $\endgroup$
    – Keith Lau
    Mar 22 '19 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.