R: Total and Between-Group Deviation Matrices in Linear...

ldaHmat {subselect} | R Documentation

## Total and Between-Group Deviation Matrices in Linear Discriminant Analysis

### Description

Computes total and between-group matrices of Sums of Squares and Cross-Product (SSCP) deviations in linear discriminant analysis. These matrices may be used as input to the variable selection search routines `anneal`, `genetic` `improve` or `eleaps`.

### Usage

    ## Default S3 method:
    ldaHmat(x,grouping,...)

    ## S3 method for class 'data.frame'
    ldaHmat(x,grouping,...)

    ## S3 method for class 'formula'
    ldaHmat(formula,data=NULL,...)

### Arguments

`x` | A matrix or data frame containing the discriminators for which the SSCP matrix is to be computed.
`grouping` | A factor specifying the class for each observation.
`formula` | A formula of the form `'groups ~ x1 + x2 + ...'` That is, the response is the grouping factor and the right hand side specifies the (non-factor) discriminators.
`data` | Data frame from which variables specified in 'formula' are preferentially to be taken.
`...` | further arguments for the method.

### Value

A list with four items:

`mat` | The total SSCP matrix
`H` | The between-groups SSCP matrix
`r` | The expected rank of the H matrix which equals the minimum between the number of discriminators and the number of groups minus one. The true rank of H can be different from r if the discriminators are linearly dependent.
`call` | The function call which generated the output.

### See Also

`anneal`, `genetic`, `improve`, `eleaps`, `lda`.

### Examples

    ##--------------------------------------------------------------------

    ## An example with a very small data set. We consider the Iris data
    ## and three groups, defined by species (setosa, versicolor and
    ## virginica).

    data(iris)
    irisHmat <- ldaHmat(iris[1:4],iris$Species)
    irisHmat

    ##$mat
    ##             Sepal.Length Sepal.Width Petal.Length Petal.Width
    ##Sepal.Length   102.168333   -6.322667     189.8730    76.92433
    ##Sepal.Width     -6.322667   28.306933     -49.1188   -18.12427
    ##Petal.Length   189.873000  -49.118800     464.3254   193.04580
    ##Petal.Width     76.924333  -18.124267     193.0458    86.56993

    ##$H
    ##             Sepal.Length Sepal.Width Petal.Length Petal.Width
    ##Sepal.Length     63.21213   -19.95267     165.2484    71.27933
    ##Sepal.Width     -19.95267    11.34493     -57.2396   -22.93267
    ##Petal.Length    165.24840   -57.23960     437.1028   186.77400
    ##Petal.Width      71.27933   -22.93267     186.7740    80.41333

    ##$r
    ##[1] 2

    ##$call
    ##ldaHmat.data.frame(x = iris[1:4], grouping = iris$Species)

[Package subselect version 0.14 Index]