cov.group: Group covariance matrices

Description Usage Arguments Value See Also Examples

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 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)

vcvComp documentation built on Dec. 17, 2020, 9:07 a.m.