# withinCov: Within-class Covariance Matrix In DiscriMiner: Tools of the Trade for Discriminant Analysis

## Description

Calculates the within-class covariance matrix

## Usage

 `1` ``` withinCov(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

`withinSS`, `betweenCov`, `totalCov`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```## Not run: # load iris dataset data(iris) # within-class covariance matrix (dividing by n-1) withinCov(iris[,1:4], iris[,5]) # within-class covariance matrix (dividing by n) withinCov(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.26145101  0.09147651   0.16526577  0.03788591
Sepal.Width    0.09147651  0.11383893   0.05450201  0.03227114
Petal.Length   0.16526577  0.05450201   0.18270201  0.04209262
Petal.Width    0.03788591  0.03227114   0.04209262  0.04131946
Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length   0.25970800  0.09086667   0.16416400  0.03763333
Sepal.Width    0.09086667  0.11308000   0.05413867  0.03205600
Petal.Length   0.16416400  0.05413867   0.18148400  0.04181200
Petal.Width    0.03763333  0.03205600   0.04181200  0.04104400
```

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