ClassificationDiscriminant - How to exclude a predictor for only one group level?
4 views (last 30 days)
Show older comments
I am using ClassificationDiscriminant.fit to classify data. I seek to predict classes of Y, a nominal categorical variable, by X, a n-by-5 matrix of continous valued measurements.
Because some groups of Y (e.g. class level "l.b") have zero variance, I get the error:
“Error using ClassificationDiscriminant (line 624) Predictor x1 has zero variance for class l.b. Either exclude this predictor or set 'discrimType' to 'pseudoQuadratic' or 'diagQuadratic'.”
However, I cannot find user-guide, help notes or documentation that indicate how to exclude a predictor during this process. I do not want to use 'pseudoQuadratic' or the other, but would like to exclude the predictor causing the problem. Can someone please explain a simple efficient way to accomplish this?
The solution proposed to exclude an entire column of the matrix of predictors is not acceptable. This not a viable solution because this is a case where the predictor variance is zero for only one class level of the grouping variable. Removing the entire predictor variable will eliminate an important factor. What I figure is needed is: 1 ) to reassign that category of the grouping variable to another category; or 2 ) remove observations belonging to that category. Does anyone agree? What I am seeking is to use ClassificationDiscriminant.fit to proceed by excluding these zero-var cases without throwing an error, i.e. automatically exclude them. Assuming that is not possible, how do I access the variance information by category (group level) during ClassificationDiscriminant.fit, so that I can use its calculations to handle these cases prior to it throwing an error? Must I calculate the intra group level variances myself prior to submitting the data to ClassificationDiscriminant.fit?
Thank you.
0 Comments
Accepted Answer
Ilya
on 25 Mar 2013
Delete the corresponding column in the matrix of predictors you pass to ClassificationDiscriminant.fit:
X(:,1) = [];
4 Comments
Ilya
on 28 Mar 2013
If the predictor no longer has zero variance after you merge two groups or if you remove observations for the offending group, you will be able to carry out quadratic discriminant analysis. I have no opinion on whether merging two groups or removing observations from a certain group is a sound approach for your specific analysis.
Instead of using try/catch, you can always use the 'pseudoQuadratic' option. If a covariance matrix is not singular, its inverse is equal to its pseudo inverse. In this case, however, you won't know if one of the covariance matrices is singular because the analysis type in the returned object will be always set to 'pseudoQuadratic'.
More Answers (0)
See Also
Categories
Find more on Discriminant Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!