`centroids`

computes group centroids, the pooled mean
and pooled variance, and optionally the group specific variances.

1 2 |

`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. |

`lambda.var` |
Shrinkage intensity for the variances. If not specified it is
estimated from the data, see details below. |

`lambda.freqs` |
Shrinkage intensity for the frequencies. If not specified it is
estimated from the data. |

`var.groups` |
Estimate group-specific variances. |

`centered.data` |
Return column-centered data matrix. |

`verbose` |
Provide some messages while computing. |

As estimator of the variance we employ
`var.shrink`

as described in Opgen-Rhein and Strimmer (2007).
For the estimates of frequencies we rely on
`freqs.shrink`

as described in Hausser and Strimmer (2009).
Note that the pooled mean is computed using the estimated frequencies.

`centroids`

returns a list
with the following components:

`samples` |
a vector containing the samples sizes in each group, |

`freqs` |
a vector containing the estimated frequency in each group, |

`means` |
the group means and the pooled mean, |

`variances` |
the group-specific and the pooled variances, and |

`centered.data` |
a matrix containing the centered data. |

Korbinian Strimmer (http://strimmerlab.org).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
# 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, lambda.var=0)
## also compute group-specific variances
centroids(X, Y, var.groups=TRUE, lambda.var=0)
## use shrinkage estimator for the variances
centroids(X, Y, var.groups=TRUE)
## return centered data
xc = centroids(X, Y, centered.data=TRUE)$centered.data
apply(xc, 2, mean)
## useful, e.g., to compute the inverse pooled correlation matrix
powcor.shrink(xc, alpha=-1)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.