getWithin: Within-class Covariance Matrix

Description Usage Arguments Details Author(s) See Also Examples

View source: R/getWithin.R

Description

Calculates the estimated within-class covariance matrix

Usage

1
  getWithin(variables, group)

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)

Details

The obtained matrix is the estimated within-class covariance matrix (i.e. within-class covariance matrix divided by its degrees of freedom n-k, where n is the number of observations and k is the number of groups)

Author(s)

Gaston Sanchez

See Also

withinCov

Examples

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

  # estimated within-class covariance matrix (dividing by n-k)
  getWithin(iris[,1:4], iris[,5])

  # compared to the within-class covariance matrix (dividing by n-1)
  withinCov(iris[,1:4], iris[,5])
  
## End(Not run)

Example output

             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length   0.26500816  0.09272109   0.16751429  0.03840136
Sepal.Width    0.09272109  0.11538776   0.05524354  0.03271020
Petal.Length   0.16751429  0.05524354   0.18518776  0.04266531
Petal.Width    0.03840136  0.03271020   0.04266531  0.04188163
             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

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