wt.scale: Weighted Expectations and Variances

Description Usage Arguments Value Author(s) See Also Examples

View source: R/wt.scale.R

Description

wt.var estimate the unbiased variance taking into account data weights.

wt.moments produces the weighted mean and weighted variance for each column of a matrix.

wt.scale centers and standardized a matrix using the weighted means and variances.

Usage

1
2
3
  wt.var(xvec, w) 
  wt.moments(x, w)
  wt.scale(x, w, center=TRUE, scale=TRUE)

Arguments

xvec

a vector

x

a matrix

w

data weights

center

logical value

scale

logical value

Value

A rescaled matrix (wt.scale), a list containing the column means and variances (wt.moments), or single number (wt.var)

Author(s)

Korbinian Strimmer (https://strimmerlab.github.io).

See Also

weighted.mean, cov.wt.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# load corpcor library
library("corpcor")

# generate some data
p = 5
n = 5
X = matrix(rnorm(n*p), nrow = n, ncol = p)
w = c(1,1,1,3,3)/9


# standardize matrix
scale(X)
wt.scale(X)
wt.scale(X, w) # take into account data weights

corpcor documentation built on Sept. 16, 2021, 5:12 p.m.

Related to wt.scale in corpcor...