In short
A categorical predictor with k groups enters a regression as k − 1 dummy variables (0/1), and the group that gets 0 on all of them is the reference category. Each dummy’s B is the difference between its group and the reference, adjusted for the other predictors in the model. Changing the reference changes which differences you read, not the model: R², the fitted values and the overall test of the factor stay identical. Test the factor as a whole with the F of the block of dummies (ΔR²), then report each B with its 95% confidence interval and say which group is the reference. In the example below, therapy group adds ΔR² = .077, F(2, 176) = 11.64, p < .001, and CBT patients end 5.04 points lower than the waitlist at the same baseline anxiety.
Sooner or later every regression model you build has a predictor that is not a number: treatment arm, diagnosis, educational level, country. Software will accept it as a number if you let it, and the output will look normal. This guide covers the coding, the reading of each coefficient, the test that answers “does group matter?” and the APA 7 table. The general reporting format for regression is in how to report a regression in APA 7; here the focus is the categorical predictor.
Why a categorical predictor cannot go in as a number
Take a randomised trial with 180 adults with anxiety, 60 per arm: waitlist, cognitive behavioural therapy (CBT) and a mindfulness programme. The outcome is post-treatment anxiety and you adjust for baseline anxiety. The data are simulated for this article so that every figure can be checked.
Suppose you type the arms as 1 = waitlist, 2 = CBT, 3 = mindfulness and enter that column as a predictor. The model now assumes that the three arms lie on a line, equally spaced, in that order: whatever separates waitlist from CBT must also separate CBT from mindfulness. With this coding the slope is −1.20 and R² = .360. Swap the labels so that 2 = mindfulness and 3 = CBT, which changes nothing about the data, and the slope becomes −2.52 with R² = .420. Two arbitrary labelling decisions, two different answers. The numbers 1, 2 and 3 are names, not quantities, and a regression cannot tell the difference unless you code them so that it can (Cohen et al., 2003; Hardy, 1993).
Dummy coding: k − 1 variables and the reference category
Dummy coding (also called indicator or treatment coding) creates one 0/1 variable for each group except one (Suits, 1957). With three arms you need two dummies:
| Group | DCBT | DMindfulness |
|---|---|---|
| Waitlist (reference) | 0 | 0 |
| CBT | 1 | 0 |
| Mindfulness | 0 | 1 |
The group coded 0 on every dummy is the reference category. Its mean is carried by the intercept, so it needs no dummy of its own. If you add a third dummy for the waitlist as well, the three dummies always sum to 1 and are a perfect linear copy of the intercept: the model cannot be estimated as specified, and the software drops one of them for you (SPSS lists it under Excluded Variables; R returns NA for it). This is the “dummy variable trap”, an extreme case of the problem described in how to report multicollinearity and VIF.
The model for the example is:
Anxietypost = b0 + b1·Baselinec + b2·DCBT + b3·DMindfulness + e
Baseline anxiety is centred at its sample mean (22.78), so that the intercept refers to a patient with average baseline anxiety rather than to an impossible score of 0. In R, lm() builds the dummies for you from a factor and uses the first level as the reference; in SPSS you either create them with Transform → Create Dummy Variables or declare the factor in GLM Univariate, which by default uses the last category as the reference. Check which one your software picked before you interpret anything.
How to choose the reference (and why it changes the reading, not the model)
Choose the group that makes the coefficients answer your research question. In a trial, that is usually the control arm. In other designs, it is the largest or most typical group, or the one the literature compares against. Avoid a tiny or residual category (“other”) as the reference: every comparison then has a wide confidence interval because it leans on a handful of cases.
Here is the part that is often misunderstood. Changing the reference does not change the model. With waitlist as the reference or with CBT as the reference, the fitted values are the same, R² is .420 in both cases and the test of the group factor is the same F(2, 176) = 11.64. What changes is which pairwise differences appear as coefficients:
- Waitlist as reference: CBT vs waitlist, B = −5.04; mindfulness vs waitlist, B = −2.39.
- CBT as reference: waitlist vs CBT, B = 5.04; mindfulness vs CBT, B = 2.65, 95% CI [0.59, 4.71], p = .012.
The third comparison, mindfulness vs CBT, was in the first model all along: it is −2.39 − (−5.04) = 2.65. Refitting with another reference is simply the easiest way to get its standard error. If you look at all three pairs, you are running three tests, and the usual multiple-comparison logic applies: with a Holm adjustment (Holm, 1979) the three p values become < .001, .024 and .024. If only the comparisons against control were planned, say so in the Method and test only those.
Interpreting each B as an adjusted mean difference
With waitlist as the reference, the coefficients read as follows:
- Intercept, b0 = 20.60: predicted post-treatment anxiety for a waitlist patient with average baseline anxiety. It is the adjusted mean of the reference group.
- DCBT, B = −5.04, 95% CI [−7.10, −2.98]: at the same baseline anxiety, CBT patients score 5.04 points lower than waitlist patients.
- DMindfulness, B = −2.39, 95% CI [−4.45, −0.33]: at the same baseline anxiety, mindfulness patients score 2.39 points lower than the waitlist.
Add the coefficients to the intercept and you get the three adjusted means: 20.60 (waitlist), 20.60 − 5.04 = 15.57 (CBT) and 20.60 − 2.39 = 18.21 (mindfulness). The observed means were 20.43, 16.05 and 17.90. The CBT difference grows from −4.38 raw to −5.04 adjusted because the CBT group started slightly higher at baseline (23.45 against 22.55), and each baseline point predicts 0.73 points at follow-up: 0.73 × 0.90 ≈ 0.65, which accounts for the gap between the two figures (the rest is rounding).
Two things a dummy coefficient is not. It is not a slope: there is no “one-unit increase in group”, only the switch from the reference to that group. And its p value tests that one difference against zero, not whether the factor matters. A factor can have a non-significant dummy and still be a strong predictor overall, or the reverse. That is what the next test is for.
The overall test of the factor: the F of the block
The question “does therapy group predict post-treatment anxiety?” has two degrees of freedom here, because it is carried by two dummies. You answer it by entering the dummies together as a block and testing the change in R², exactly as in a hierarchical regression:
| Step | Predictors | R² | ΔR² | ΔF | df | p |
|---|---|---|---|---|---|---|
| 1 | Baseline anxiety | .343 | .343 | 92.97 | 1, 178 | < .001 |
| 2 | + Group (2 dummies) | .420 | .077 | 11.64 | 2, 176 | < .001 |
The group factor explains an additional 7.7% of the variance in post-treatment anxiety over baseline. This ΔF is the same F you would get for the group effect in an ANCOVA with baseline as the covariate, and it does not depend on which group is the reference. Never let the significance of individual dummies stand in for it: “one of the two dummies was significant” is not a test of the factor. If you are working through your first model of this kind, multiple regression step by step shows how to fit the blocks in SPSS and R.
Other codings (effect, contrast) in two lines
Effect coding (−1/0/1) compares each group with the unweighted mean of all group means instead of with one group: here the intercept becomes 18.13, the average of the three adjusted means, and the coefficients are deviations from it (CBT −2.56, mindfulness 0.09). Contrast coding builds orthogonal or planned comparisons, such as “control vs any therapy” followed by “CBT vs mindfulness”, and is the best option when your hypotheses are exactly those contrasts (Davis, 2010; Schad et al., 2020; Wendorf, 2004). All of them give the same R² and the same block F; only the meaning of each coefficient changes, which is why the Method has to say which coding you used.
How to put it in the APA 7 regression table
APA 7 does not need a special table for categorical predictors, but it does need the reader to be able to tell what each row compares. Three habits make that possible: name the factor as a heading row, put the reference category in that row, and indent its dummies below it. Explain the coding and the reference again in the note (American Psychological Association, 2020).
Table 1
Regression of Post-Treatment Anxiety on Baseline Anxiety and Treatment Group
| Predictor | B | SE | 95% CI | β | t | p |
|---|---|---|---|---|---|---|
| Intercept | 20.60 | 0.74 | [19.15, 22.06] | 27.94 | < .001 | |
| Baseline anxiety | 0.73 | 0.07 | [0.59, 0.86] | .60 | 10.47 | < .001 |
| Group (ref. = waitlist) | ||||||
| CBT | −5.04 | 1.04 | [−7.10, −2.98] | −4.82 | < .001 | |
| Mindfulness | −2.39 | 1.04 | [−4.45, −0.33] | −2.29 | .023 |
Note. N = 180 (60 per group). R² = .42, adjusted R² = .41, F(3, 176) = 42.45, p < .001. Group was dummy coded with the waitlist as the reference category; ΔR² for the group block = .077, F(2, 176) = 11.64, p < .001. Baseline anxiety was centred at the sample mean (22.78), so the intercept is the adjusted mean of the waitlist group. Standardised coefficients are not reported for the dummy variables because they depend on the proportion of cases in each group. CI = confidence interval.
That last point is worth a sentence of its own. A standardised β multiplies B by the standard deviation of the predictor (and divides it by that of the outcome), and the standard deviation of a 0/1 variable depends only on how many cases are coded 1. The same difference between two groups gets a different β in a 50/50 sample and in a 90/10 sample, so β says little about a dummy. The unstandardised B, in the units of the outcome, is the readable effect. If you want the table built from your own output, the APA 7 regression table generator produces it in this format.
And a model paragraph for the Results:
“Treatment group was entered as two dummy variables, with the waitlist as the reference category. Over and above baseline anxiety, group explained an additional 7.7% of the variance in post-treatment anxiety, ΔR² = .077, F(2, 176) = 11.64, p < .001. At equal baseline anxiety, participants in CBT scored 5.04 points lower than those on the waitlist, B = −5.04, 95% CI [−7.10, −2.98], p < .001, and participants in the mindfulness programme scored 2.39 points lower, B = −2.39, 95% CI [−4.45, −0.33], p = .023.”
Does your table say what each dummy is compared with?
A coefficient without its reference category cannot be interpreted, and reviewers notice. So do they when a factor is judged by its individual dummies instead of by the block test.
Run your paper through Previum →Frequently asked questions
How many dummy variables do I need?
One fewer than the number of categories: k − 1. A factor with three groups needs two dummies; one with five needs four. The category without a dummy is the reference, and its mean is carried by the intercept. Adding a dummy for every category makes the model impossible to estimate (the dummy variable trap).
How do I interpret the coefficient of a dummy variable?
As the difference in the outcome between that group and the reference group, holding the other predictors constant. In the example, B = −5.04 for CBT means CBT patients score 5.04 points lower than waitlist patients with the same baseline anxiety.
Does the choice of reference category change the results?
It changes which comparisons appear as coefficients, not the model. R², the predicted values and the overall F test of the factor are identical whichever group you choose as the reference. Pick the reference that makes the coefficients answer your question, usually the control group.
How do I test whether a categorical predictor is significant overall?
Enter all its dummies together as one block and test the change in R² with an F test whose numerator degrees of freedom equal the number of dummies. The individual dummy p values only test differences from the reference group.
Should I report standardised coefficients for dummy variables?
Usually not. A standardised coefficient for a 0/1 variable depends on the proportion of cases in each group, so the same group difference gives different values in different samples. Report B with its confidence interval, which is in the units of the outcome.
Coding a factor takes a minute; deciding which comparisons the paper actually needs, and defending them to a reviewer, takes longer. If you want that worked through on your own data, from the model to the Results section you then revise with your coauthors, that is part of my statistical consulting.
References
American Psychological Association. (2020). Publication manual of the American Psychological Association (7th ed.). https://doi.org/10.1037/0000165-000
Cohen, J., Cohen, P., West, S. G., & Aiken, L. S. (2003). Applied multiple regression/correlation analysis for the behavioral sciences (3rd ed.). Lawrence Erlbaum Associates.
Davis, M. J. (2010). Contrast coding in multiple regression analysis: Strengths, weaknesses, and utility of popular coding structures. Journal of Data Science, 8(1), 61–73. https://doi.org/10.6339/JDS.2010.08(1).563
Hardy, M. A. (1993). Regression with dummy variables. SAGE Publications. https://doi.org/10.4135/9781412985628
Holm, S. (1979). A simple sequentially rejective multiple test procedure. Scandinavian Journal of Statistics, 6(2), 65–70.
Schad, D. J., Vasishth, S., Hohenstein, S., & Kliegl, R. (2020). How to capitalize on a priori contrasts in linear (mixed) models: A tutorial. Journal of Memory and Language, 110, Article 104038. https://doi.org/10.1016/j.jml.2019.104038
Suits, D. B. (1957). Use of dummy variables in regression equations. Journal of the American Statistical Association, 52(280), 548–551. https://doi.org/10.1080/01621459.1957.10501412
Wendorf, C. A. (2004). Primer on multiple regression coding: Common forms and the additional case of repeated contrasts. Understanding Statistics, 3(1), 47–57. https://doi.org/10.1207/s15328031us0301_3