EVOLUTION-MANAGER
Edit File: cov.wt.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Weighted Covariance Matrices</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for cov.wt {stats}"><tr><td>cov.wt {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Weighted Covariance Matrices</h2> <h3>Description</h3> <p>Returns a list containing estimates of the weighted covariance matrix and the mean of the data, and optionally of the (weighted) correlation matrix.</p> <h3>Usage</h3> <pre> cov.wt(x, wt = rep(1/nrow(x), nrow(x)), cor = FALSE, center = TRUE, method = c("unbiased", "ML")) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a matrix or data frame. As usual, rows are observations and columns are variables.</p> </td></tr> <tr valign="top"><td><code>wt</code></td> <td> <p>a non-negative and non-zero vector of weights for each observation. Its length must equal the number of rows of <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>cor</code></td> <td> <p>a logical indicating whether the estimated correlation weighted matrix will be returned as well.</p> </td></tr> <tr valign="top"><td><code>center</code></td> <td> <p>either a logical or a numeric vector specifying the centers to be used when computing covariances. If <code>TRUE</code>, the (weighted) mean of each variable is used, if <code>FALSE</code>, zero is used. If <code>center</code> is numeric, its length must equal the number of columns of <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>method</code></td> <td> <p>string specifying how the result is scaled, see ‘Details’ below. Can be abbreviated.</p> </td></tr> </table> <h3>Details</h3> <p>By default, <code>method = "unbiased"</code>, The covariance matrix is divided by one minus the sum of squares of the weights, so if the weights are the default (<i>1/n</i>) the conventional unbiased estimate of the covariance matrix with divisor <i>(n - 1)</i> is obtained. This differs from the behaviour in S-PLUS which corresponds to <code>method = "ML"</code> and does not divide. </p> <h3>Value</h3> <p>A list containing the following named components: </p> <table summary="R valueblock"> <tr valign="top"><td><code>cov</code></td> <td> <p>the estimated (weighted) covariance matrix</p> </td></tr> <tr valign="top"><td><code>center</code></td> <td> <p>an estimate for the center (mean) of the data.</p> </td></tr> <tr valign="top"><td><code>n.obs</code></td> <td> <p>the number of observations (rows) in <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>wt</code></td> <td> <p>the weights used in the estimation. Only returned if given as an argument.</p> </td></tr> <tr valign="top"><td><code>cor</code></td> <td> <p>the estimated correlation matrix. Only returned if <code>cor</code> is <code>TRUE</code>.</p> </td></tr> </table> <h3>See Also</h3> <p><code><a href="cor.html">cov</a></code> and <code><a href="cor.html">var</a></code>. </p> <h3>Examples</h3> <pre> (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) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>