ClassificationDiscriminant - How to exclude a predictor for only one group level?
조회 수: 4 (최근 30일)
이전 댓글 표시
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
채택된 답변
Ilya
2013년 3월 25일
Delete the corresponding column in the matrix of predictors you pass to ClassificationDiscriminant.fit:
X(:,1) = [];
댓글 수: 4
Ilya
2013년 3월 28일
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'.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Discriminant Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!