What does it mean to not have enough codes?
In your statistical analysis adventures with STATISTICA, you may run into some error messages along the way. One such type of error tells you that a variable does not have enough codes. Let’s explore more of what this error is telling us and how to fix the data.
In statistical modeling tools like General Linear models and Data Mining tree algorithms like C&RT, CHAID, Boosted Trees and Random Forests, when a categorical predictor variable has less than 2 distinct levels, you get an error message that says: “Not enough codes selected for variable : The required minimum number of codes is 2.”
For Neural Networks and machine learning tools, you get a bit wordier message that is telling us the same thing. It says: “STATISTICA has detected an insufficient number of nominal levels in the categorical independent variable . All categorical variables must contain at least two nominal values. Please carefully check your data and case selection conditions and try again.
Here are some possible causes and solutions for this type of error message. I reserve the right to add to my list, if I think of something else.
- All records in the sample have the same response for this variable. Say the population you are studying is male subjects. You don’t need a gender variable in the model because all participants in your study are male. This gender variable should not be (and can’t be) used for analysis.
- Records are missing from our dataset. Say we want to compare several hospitals on various metrics. Each hospital has its own data set. These data files need merged before starting the analysis.
- Data was recorded as 1 if present and left blank otherwise. When this is the case, those blanks should be filled in with a value. When STATISTICA encounters a blank cell, it is taken to be unknown, missing. In this case, the value is not unknown; it is a unique group level. So to fix this, you might use the Process Missing Data tool to replace missing cells with a value. Or a spreadsheet function like “=iif(ismd(vcur)), 0, vcur)” will leave existing data unchanged and fill in missing cells with 0.
- Case selection conditions have excluded some cases, and now there is only 1 unique level to this variable. To solve this issue, either case selection conditions need changed or the predictor variable should not be included in the analysis.
- Missing data in another variable has excluded some cases, leaving only one unique level of a grouping factor. Missing data should be dealt with before starting an analysis. Model build tools can’t work with missing data and the records are thrown out. Here is a video that discusses dealing with missing data.
Now that you understand the cause of your error message, you are ready to get back to blazing your analytic trail.