Description Usage Arguments Details Value Author(s) Examples

Classify items using linear discriminant analysis.

1 | ```
ldclassify (data, means, covariance, template = NULL, posterior = 'no')
``` |

`data` |
A matrix in which each row represents an item to be classified, and each column represents an observation from a variable describing the item. |

`means` |
A matrix of means where each row is a mean vector specifying a candidate category. The number of columns must equal the number of columns in data. |

`covariance` |
The pooled within-groups covariance matrix to be used for classification. |

`template` |
A 'Template' object may be passed instead of a mean and covariance. |

`posterior` |
If 'winner', the posterior probability of the winning category is returned. If 'all', the posterior of every category is returned. |

This function classifies the items described in the data matrix by comparing them to the reference patterns for the different candidate categories represented in the means matrix. The category with the minimum Mahalanobis distance to the observed pattern (i.e., a given row of the data matrix) is selected as the winner. Mahalanobis distances are found with using the covariance matrix provided to the function.

Mean and covariance matrices can be made easily for data using the createtemplate() function included in this package.

A vector of winning categories is returned. If winning posteriors are desired, these are returned in a second column. All posteriors are returned in separate columns for each category.

Santiago Barreda <[email protected]>

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
## load Peterson & Barney vowel data
data (pb52)
## normalize vowel formant frequencies
normdvowels = normalize (pb52[,7:9], pb52$speaker, pb52$vowel)
formants = normdvowels[,1:3]
vowels = pb52$vowel
## make a vowel template based on these frequencies
template = createtemplate (formants, vowels)
## classify vowels
answers = ldclassify (formants, template$means, template$covariance)
## compare to known categories
table (answers, vowels)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.