cov.group {vcvComp}R Documentation

Group covariance matrices

Description

Computes the covariance matrix of each group. The effect of sexual dimorphism can be removed by using, for each group, the average of the covariance matrix of males and the covariance matrix of females.

Usage

cov.group(X, groups, sex = NULL, use = "everything")

Arguments

X

a data matrix with variables in columns and group names as row names

groups

a character / factor vector containing grouping variable

sex

NULL (default). A character / factor vector containing sex variable, to remove sexual dimorphism by averaging males and females in each group

use

an optional character string giving a method for computing covariances in the presence of missing values. This must be (an abbreviation of) one of the strings "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs".

Value

A (p x p x m) array of covariance matrices, where p is the number of variables and m the number of groups.

See Also

cov and scale

Examples


# Data matrix of 2D landmark coordinates
data("Tropheus.IK.coord")
coords <- which(names(Tropheus.IK.coord) == "X1"):which(names(Tropheus.IK.coord) == "Y19")
proc.coord <- as.matrix(Tropheus.IK.coord[coords])

# Covariance matrix of each population
S.phen.pop <- cov.group(proc.coord, groups = Tropheus.IK.coord$POP.ID)

# Covariance matrix of each population, pooled by sex
S.phen.pooled <- cov.group(proc.coord,
groups = Tropheus.IK.coord$POP.ID, sex = Tropheus.IK.coord$Sex)


[Package vcvComp version 1.0.2 Index]