Learn R Programming

grt (version 0.1.0)

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

Description

Calculate sample means and covariance(s) of multivariate data

Usage

## S3 method for class 'default':
mcovs(x, grouping, pooled=TRUE, \dots)

## S3 method for class 'formula': mcovs(formula, data, pooled=TRUE, \dots)

Arguments

formula
A formula in the form of grouping ~ x1 + x2 + ..., where the right hand side specifies the sample varibles.
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:
  • Ntotal number of samples.
  • countsnumber of samples per groups.
  • levlevels of the grouping factor
  • meansa named list of vectors specifying the means for each groups. Named according to lev.
  • covsa named list of variance-covarinace matrix(es). Named as pooled if pooled=TRUE, otherwise according to lev.