Learn R Programming

grt (version 0.2.1)

mcovs: Calculate sample means and covariance(s) of multivariate data

Description

Calculate sample means and covariance(s) of multivariate data

Usage

# S3 method for default
mcovs(x, grouping, pooled=TRUE, …)

# S3 method for formula mcovs(formula, data, pooled=TRUE, …)

Arguments

formula

A formula in the form of grouping ~ x1 + x2 + …, where the right hand side specifies the sample variables.

data

Data frame from which variables specified in formula are taken.

x

data frame or Matrix containing sample values.

grouping

a factor specifying the population to which the samples in x belong.

pooled

logical. If TRUE, pooled variance-covariance matrix is calculated. If FALSE, a list of variance-covariance matrices for each groups are calculated. Default to TRUE.

further arguments

Value

A list containing:

N

total number of samples.

counts

number of samples per groups.

lev

levels of the grouping factor

means

a named list of vectors specifying the means for each group. Named according to lev.

covs

a named list of variance-covarinace matrix(es). Named as pooled if pooled=TRUE, otherwise according to lev.