From: maxwell10 on
Hi,
I tried to use classify function with Mahalanobis method.
I got the follow error:

??? Error using ==> classify at 298
The covariance matrix of each group in
TRAINING must be positive definite.

what that it means? What should I do about?

This is the code
[P, T, Eig] = princomp(spec');
T1=T(:,1:6);
[r,c]=size(T1);
R=rand(r,1);
Itrain=find(R>=0.2);
Iclass=find(R<0.2);
training=T1(Itrain,:);
sample=T1(Iclass,:);
group=type(Itrain);
class = classify(sample,training,group,'mahalanobis');

Where 'spec' is 73x109 (73 wave number and 109 samples)
and 'type' is 1x109 and this is the actual classification of the spectra.
From: maxwell10 on
Hi,

I found out this problam occured also when I use this function directly on the spec matrix which means that the problam is not the scores matrix ('P').
From: Peter Perkins on
maxwell10 wrote:

> ??? Error using ==> classify at 298
> The covariance matrix of each group in
> TRAINING must be positive definite.
>
> what that it means? What should I do about?

> Where 'spec' is 73x109 (73 wave number and 109 samples)
> and 'type' is 1x109 and this is the actual classification of the spectra.

Discriminat analysis, as implemented by CLASSIFY requires estimation of one (linear DA) or more (quadratic DA or 'Mahalanobis' DA), and to do DA, that cov matrix must be non-singular. With 73 variables (if I interpret what you've said correctly) and only 109 observations, that can't be done, because a large percentage of your variables will necessarily be linearly dependent with so few observations. You need either a lot more data, or reduce your set of variables, or consider some method other than DA.

Hope this helps.