# Regularized discriminant analysis in Matlab

I am trying to do the 2-class classification using regularized discriminant analysis in Matlab using fitdiscr() function. The coefficients are stored in the object created by created by fitdiscr(). But the coefficients are stored in a 2x2 cell, shouldn't there be just one coefficients vector for any given discriminant analysis problem?

load('AA.mat')
obj = fitcdiscr(AA',actual_group','SaveMemory','on','FillCoeffs','on')


The coefficients are stored in obj.Coeffs.

Here is the data that I am using, first 10 columns belong to class-0 and last 10 column belong to class-1.

• each element of obj.Coeffs is a 2000X1 vector its not possible to show it here Commented Dec 1, 2015 at 17:37

You are correct that only one set of coefficients is necessary here. But the function can also handle more than just binary classification, so the storage arrangement is general enough to handle that.

You should find that the (1,1) coefficients are empty, and the (1,2) coefficients match the (2,1) coefficients but with opposite sign. Of course for a three-class problem there would also be (1,3) and (2,3) coefficients that are not redundant with the (1,2) coefficients.

If I try this:

C = c.Coeffs(1,2).Const;
L = c.Coeffs(1,2).Linear;
score = C + x*L


I see that high scores favor class 1 over class 2. The inverse logit transformation converts the scores to probabilities.

x = [4 3 2 1];
x =
4     3     2     1
[~,score] = predict(c,x)
score =
0.5884    0.4116    0.0000
1./(1+exp(-C-x*L))
ans =
0.5884

• So given a new test data ,with which coefficient vector should I do the dot product with ((1,2) or (2,1)?) to obtain posterior predictive score ? Commented Dec 1, 2015 at 19:08
• I edited the answer to include this information. Commented Dec 2, 2015 at 19:53