Learn R Programming

sda (version 1.0.2)

centroids: Group Centroids, (Pooled) Variances, and Powers of the Pooled Correlation Matrix

Description

centroids computes group centroids and optionally the pooled mean and pooled variance, the group specific variances, and powers of the pooled correlation matrix.

Usage

centroids(x, L, mean.pooled=FALSE, var.pooled=TRUE, var.groups=FALSE, 
  powcor.pooled=FALSE, alpha=1, shrink=FALSE, verbose=TRUE)

Arguments

x
A matrix containing the data set. Note that the rows are sample observations and the columns are variables.
L
A factor with the group labels.
mean.pooled
Estimate the pooled mean.
var.pooled
Estimate the pooled variances.
var.groups
Estimate all group-specific variances.
powcor.pooled
Estimate pooled correlation matrix (taken to the power of alpha).
alpha
exponent for the pooled correlation matrix (default: alpha=1).
shrink
Use empirical or shrinkage estimator.
verbose
Provide some messages while computing.

Value

  • centroids returns a list with the following components:
  • samplesa vector containing the samples sizes in each group,
  • meansthe empirical group means,
  • mean.pooledthe pooled empirical mean,
  • var.pooleda vector containing the pooled variances,
  • var.groupsa matrix containing the group-specific variances, and
  • powcor.pooleda matrix containing the pooled correlation matrix to the power of alpha (if all correlations are zero a vector only 1s is returned to save space).
  • alphaexponent for the pooled correlation matrix.

Details

If option shrink=TRUE then the shrinkage estimators var.shrink from Opgen-Rhein and Strimmer (2007) and cor.shrink from Sch"afer and Strimmer (2005) are used.

See Also

var.shrink, powcor.shrink.

Examples

Run this code
# load sda library
library("sda")

## prepare data set
data(iris) # good old iris data
X = as.matrix(iris[,1:4])
Y = iris[,5]

## estimate centroids and empirical pooled variances
centroids(X, Y)

## show pooled mean
centroids(X, Y, mean.pooled=TRUE)

## compute group-specific variances
centroids(X, Y, var.groups=TRUE)

## and inverse pooled correlation
centroids(X, Y, var.groups=TRUE, powcor.pooled=TRUE, alpha=-1)

## use shrinkage estimator for variances and correlations
centroids(X, Y, var.groups=TRUE, powcor.pooled=TRUE, alpha=-1, shrink=TRUE)

Run the code above in your browser using DataLab