# How to examine the relationship between categorical variables with several levels?

I would like examine if the job satisfaction of part-time workers is higher or lower compared to full-time workers.

My dataset consists of 4125 cross-sectional observations.

independent variable: employment status (1 = full-time, 2 = part-time)

dependent variable: job satisfaction (0 = Very dissatisfied, 25 = Dissatisfied, 50 = Neutral, 75 = Satisfied 100 = Very satisfied)

What kind of statistical test do I need for my analysis?

How could I incorporate (categorical) control variables (e.g. age, gender, tenure, etc.)?

Viewing satisfactions scores as levels of a categorical variable. There are various possible approaches. One of the simplest is to put the counts into a $$2 \times 5$$ table and do a chi-squared test for independence. Your satisfaction scores are essentially a Likert scale with percentages proportional to numbers 1 through 5, used in the fake example below:

Satis    1    2    3    4    5   TOTAL
Full   191  319  329  456  675    1970
Part   562  603  419  267  275    2126


Analysis in R:

f = c(191, 319, 329, 456, 675)
p = c(562, 603, 419, 267, 275)
TBL = rbind(f, p)
chisq.test(TBL)

Pearson's Chi-squared test

data:  TBL
X-squared = 493.7, df = 4, p-value < 2.2e-16


With P-value so near zero, there is strong evidence of association between Full/Part time and Satisfaction.

Expected counts $$E_{ij}$$ for the ten cells of the table are computed from row and column totals of the table of counts---assuming that the null hypothesis of no association between the two categorical variables to be true. You can see the expected counts as follows:

cq.out = chisq.test(TBL)
cq.out$exp [,1] [,2] [,3] [,4] [,5] f 362.1606 443.4424 359.7559 347.7319 456.9092 p 390.8394 478.5576 388.2441 375.2681 493.0908  Observed counts #X_{ij}$ are the corresponding (integer) counts in TBL. Comparing observed and expected counts, you can see that part time workers tend to have more than the expected number of counts in the lower-numbered satisfaction categories.

The Pearson residuals are the 'signed' square roots of the ten quantities $$\frac{(X_{ij} - E_{IJ})^2}{E_{ij}}$$ can be displayed as follows:

cq.out$res [,1] [,2] [,3] [,4] [,5] f -8.994008 -5.909486 -1.621526 5.806014 10.202872 p 8.657745 5.688545 1.560901 -5.588942 -9.821412  Usually, Pearson residuals with absolute values greater than $$3$$ are taken to show cells with especially poor agreement between observed and expected counts. For my fake data, the residuals of greatest interest are for lowest and highest-numbered categorical levels of satisfaction scores. Viewing satisfaction scores as actual numerical values. The chi-squared test essentially ignores any numerical properties associated with satisfaction scores (even order), treating numbers only as labels for nominal categorical levels. Other kinds of tests, including a 2-sample t test might be used if you want to treat satisfaction scores as actual numbers. In the data above, we could let $$X$$ (for full-time employees) have 'numerical' values as follows: $$191$$ 1's, $$319$$ 2's, and so on. And similarly for $$Y$$ (for part-time employees). Whether to ascribe actual numerical meaning to Likert scores is controversial, but widely accepted as useful in the social sciences. According to this scheme we have $$X$$ and $$Y$$ as follows: x = rep(1:5, f); y = rep(1:5, p) par(mfrow=c(2,1)) hist(x, br=(0:5)+.5, ylim=c(0,900), lab=T, col="skyblue2", main="Full-Time") hist(y, br=(0:5)+.5, ylim=c(0,900), lab=T, col="skyblue2", main="Part-Time") par(mfrow=c(1,1)) Then a Welch 2-sample t test on the 'numerical' values in $$X$$ and $$Y$$ shows a highly significant difference in population means.  Welch Two Sample t-test data: x and y t = 23.437, df = 4063.8, p-value < 2.2e-16 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 0.906221 1.071674 sample estimates: mean of x mean of y 3.560914 2.571966  • Thank you! How can I see if the job satisfaction of part-time workers is higher or lower than the job satisfaction of full-time workers? – Michael12 May 3 at 20:57 • In terms of the sample means$\bar X = 3.56$and$\bar Y = 2.57$shown in the output for the t test. (Subtract 1 and multiply by 25 to use the numerical scale 0, 25, 50 75, 100 of your Question.) // In the two-way table, you might note that the median score for Full-Time is 4, while the median score for Part-Time is 2. – BruceET May 3 at 21:29 • This is very helpful. Thank you. How can I find out if the difference in job satisfaction between part-time and full-time could be explained by gender (1 = male, 2 = female)? – Michael12 May 4 at 8:52 • Maybe use a two-factor ANOVA with factors Gender (levels M/F) and Job Type (F/P), with Likert observations hoped to be nearly normal. // Another possibility is to add a dimension to the table$2 \times 2 \times 5.\$ – BruceET May 4 at 8:58