var.wt: Calculate a weighted covariance matrix between two sets of...

Description Usage Arguments Value Examples

Description

Calculate a weighted covariance matrix in the same way as cov.wt, but allow two sets of columns as in var.

Usage

1
2
var.wt(x, y = NULL, w, method = c("unbiased", "ML"), xcenter = NULL,
  ycenter = NULL)

Arguments

x

Data frame or a matrix

y

Data frame or a matrix with the same number of rows as x. If left NULL, the covariance matrix of x is calculated.

w

A vector of weights. w will be divided by sum(w) to ensure weights sum to 1.

method

The type of estimate returned, "unbiased" (default) or "ML", meaning maximum likelihood.

xcenter, ycenter

Optional center values for x and y.

Value

A weighted covariance matrix.

Examples

1
2
3
wts <- (tmp <- runif(nrow(mtcars))) / sum(tmp)
var.wt(mtcars[, 1:5], mtcars[, 1:2], w = wts)
cov.wt(mtcars[, 1:5], wt = wts)$cov

markajoc/MBCbigP documentation built on May 30, 2019, 8:39 a.m.