# problem in categorical data: impossible cells in contingency table

I have a dataset of categorical variables. Consider the following predictors:

Age (18-23,23-28, 28-35, 35+)

Education(high-school,two-year degree, bachelor,master,phd)

Experience(0-3,3-5,5-7,7+)

I want to predict salary (0-1.5,1.5-3,3-4.5,4.5+)

Before using chi-squre test or log-linear model or logistic regression, I created a contingency table to make sure my cells have at least 5 (or 10) values. Here a problem comes in: there are empty cells that cannot be filled logically.

For example, phds cannot fall into 18-23 or 23-28 ranges. As another example, 18-23 year olds are very unlikely to have 4.5+ years of experience. The Common practice is combining categories so that each cell in the contingency table has more than 5 (or 10) values. If I do that, I lose the details in my data. What should I do?

• I think it is important to clarify the levels of your education. What is the difference between "college" and "bachelor?" Does one indicate that you attained a degree while the other indicates you studied at college but did not earn a degree? Should "college" and "bachelor" be combined into one category? Make sure this is clear in whatever analysis with which you move forward! – Matt Brems Aug 2 '16 at 18:33
• @MattBrems By college, I meant a two-year degree. – Hamideh Aug 2 '16 at 18:35
• Depending on where you publish/display your analysis, I might recommend that you relabel "college" to "Associate's degree" or "two-year degree." For example, in the United States, a two-year degree is often referred to as an Associate's degree and the term "college" might be confusing. However, if your analysis is published in a region where "college" is understood to be different from "bachelor," then this is unnecessary. – Matt Brems Aug 2 '16 at 18:43

Structural zeros or voids are special cases in the analysis of contingency tables. These are vacancies in cell structure that, as noted by the OP, represent theoretically impossible combinations. If one treats the impossible cells as observed zero values, they distort any test of independence. Tables with these values have an incomplete factorial design requiring different treatment. This usually involves excluding or ignoring these cells when rolling up the chi-square values in a test of quasi-independence. Note that this is the same model as in the complete table -- just with certain cells excluded.

Good discussions of these issues abound in the contingency table modeling literature. My favorite citation for it is chapter 10 of Wickens Multiway Contingency Table Analysis for the Social Sciences.

If you want to execute a chi-square test, you must meet the assumptions which will include independence of observations and an expected count of at least 5 in each cell. Note that the observed count can be less than 5 as long as the expected count is at least 5. If the expected count in one or more cells are less than 5, then you will want to collapse cells - for example, collapse the age categories 18-23 and 23-28 into one 18-28 category or collapse the experience categories 5-7 and 7+ into one 5+ category. If you do not meet these assumptions and you still use a chi-square test, then you are not losing details from your data but you are using a test where all of the assumptions have not been met and your result (whether you reject or fail to reject) will be unreliable!

If you do not want to lose the details there, it is possible to execute Fisher's exact test. Fisher's exact test will calculate an exact $p$-value from your data rather than calculating an approximate $p$-value that relies on the assumptions of the chi-square test being met. This exact $p$-value will allow you to evaluate whether or not salary has an association with age or education or experience.

It is important to note that Fisher's exact test, like a chi-squared test, will only check for associations between two variables and cannot check for associations among more than two variables.

With respect to log-linear models, the Wikipedia page for log-linear models has the following suggestions: "If both (a) the expected frequencies are greater than or equal to 5 for 80% or more of the categories and (b) all expected frequencies are greater than 1 [then using a log-linear model is appropriate.]... Suggested solutions [if either or both of these assumptions are violated] are: delete a variable, combine levels of one variable (e.g., put males and females together), or collect more data."

Logistic regression would be inappropriate here, because the term "logistic regression" as it is most frequently used only applies to dependent variables that are binary, whereas salary (as you specified it) is a categorical outcome.

I would either recommend using "ordinal logistic regression" to indicate that there are multiple ordered categories of salary you seek to predict or using linear regression and predicting salary directly (instead of multiple categories). If you have the raw salary data, then I strongly recommend using that as your dependent variable.