betweenCov: Between-class Covariance Matrix

Description Usage Arguments Details Author(s) See Also Examples

View source: R/betweenCov.R

Description

Calculates between-class covariance matrix

Usage

1
  betweenCov(variables, group, div_by_n = FALSE)

Arguments

variables

matrix or data frame with explanatory variables (No missing values are allowed)

group

vector or factor with group memberships (No missing values are allowed)

div_by_n

logical indicating division by number of observations

Details

When div_by_n=TRUE the covariance matrices are divided by n (number of observations), otherwise they are divided by n-1

Author(s)

Gaston Sanchez

See Also

getWithin, betweenSS, withinCov, totalCov

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
# load iris dataset
data(iris)

# between-class covariance matrix (dividing by n-1)
betweenCov(iris[,1:4], iris[,5])

# between-class covariance matrix (dividing by n)
betweenCov(iris[,1:4], iris[,5], div_by_n=TRUE)

## End(Not run)

Example output

             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length    0.4242425 -0.13391051    1.1090497   0.4783848
Sepal.Width    -0.1339105  0.07614049   -0.3841584  -0.1539105
Petal.Length    1.1090497 -0.38415839    2.9335758   1.2535168
Petal.Width     0.4783848 -0.15391051    1.2535168   0.5396868
             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length    0.4214142 -0.13301778    1.1016560   0.4751956
Sepal.Width    -0.1330178  0.07563289   -0.3815973  -0.1528844
Petal.Length    1.1016560 -0.38159733    2.9140187   1.2451600
Petal.Width     0.4751956 -0.15288444    1.2451600   0.5360889

DiscriMiner documentation built on May 1, 2019, 10:32 p.m.