
Last chance! 50% off unlimited learning
Sale ends in
cov.wt(x, wt = rep(1/nrow(x), nrow(x)), cor = FALSE, center = TRUE, method = c("unbiased", "ML"))
x
.TRUE
, the
(weighted) mean of each variable is used, if FALSE
, zero is
used. If center
is numeric, its length must equal the number
of columns of x
.x
.cor
is TRUE
.method = "unbiased"
,
The covariance matrix is divided by one minus the sum of squares of
the weights, so if the weights are the default ($1/n$) the conventional
unbiased estimate of the covariance matrix with divisor $(n - 1)$
is obtained. This differs from the behaviour in S-PLUS which
corresponds to method = "ML"
and does not divide.
cov
and var
.
(xy <- cbind(x = 1:10, y = c(1:3, 8:5, 8:10)))
w1 <- c(0,0,0,1,1,1,1,1,0,0)
cov.wt(xy, wt = w1) # i.e. method = "unbiased"
cov.wt(xy, wt = w1, method = "ML", cor = TRUE)
Run the code above in your browser using DataLab