Coding categorical variables for regression

I'm not sure of the best way to code my categorical predictor variable for use in a hierarchical regression in order to test my specific hypothesis. This categorical variable has 3 levels representing 3 groups. I want to compare group 1 to group 2, group 1 to group 3 and group 2 to group 3. I know that for dummy coding I create k-1 variables, so 2 dummy variables in my case and code these variables with 0s and 1s while choosing one level of the categorical variable to be a reference category.

However, I'm not sure this is the best way of making the comparisons I wish to make as it appears I could only compare each group to the reference category, am I correct? So if group 3 was the reference category I could compare group 1 to group 3 and group 2 to group 3 but I could not compare group 1 to group 2. What alternative method of coding should I use to make these comparisons? My regression model will also contain continuous variables. I'm an undergrad psychology student and statistics are not my strong point simple answers would be best for me. I use SPSS. Thank you!

-
This sounds like you want Helmert Coding, see for example: ats.ucla.edu/stat/r/library/contrast_coding.htm#HELMERT I'm not an SPSS user I'm afraid though, so will let someone else give you a proper answer using SPSS. – Corone Feb 19 '14 at 16:31
Do bear in mind that you can estimate any contrasts, regardless of the coding scheme you use; it's just convenient to use a coding scheme where coefficients correspond to something of primary interest. – Scortchi Feb 19 '14 at 16:37
(1) I don't think it is quite helmert coding, but I always get confused between these different schemes. (2) I usually just change reference group and run model again. – charles Feb 19 '14 at 16:38
@Charles, sorry, yes would have been more helpful if I at least defined it! Helmert (as I understand it) is comparing 1 with 2&3 and comparing 2 with 3, which sort of seems to be the case here. If Claire compares 1&2 and 1&3 and 2&3 separately, you don't have regression, just a data description. – Corone Feb 19 '14 at 16:57
@Corone the webpage you linked mentions that reverse helmert coding would not make much sense with a nominal variable which is what my variable is. I am assuming it is the same for helmert coding? – Claire Feb 19 '14 at 17:16

Here is an example using the employee data.sav data, which comes with standard installation. Suppose salary is the dependent variable, job category, jobcat, is the categorical independent variable, and beginning salary, salbegin, is the continuous independent variable. Using GLM, you can perform pairwise comparisons between each pair of job categories. The steps are as follow:

1. With the data set open, go to Analyze > General Linear Model > Univariate.

2. Put the dependent variable and independent variable into the correct slots. Categorical independent variables go to "Fixed Factor(s)" and continuous ones go to "Covariate(s)." Do not worry about the Random Factors. When it's all set, click the "Model" button.

3. In the Model panel, highlight the two independent variables, then change the build term to "Main effects," and then click the arrow button (indicated by the red circle) to bring the two variables over. When all set, click "Continue."

4. Now, click the "Option" button.

5. In the Option panel, do the followings: 1) Highlight jobcat, 2) bring it over to the right by clicking the arrow button, 3) Check "Compare Main Effects", 4) Specify the adjustment you'd like to make for the multiple pairwise comparisons. I left it as LSD which does not adjust for multiple tests, 5) Check "Parameter Estimates" so that you'll also get the regression coefficients. When it's all done, click Continue and then OK to submit the test.

6. Here is the regression coefficient table:

7. Scroll down a bit and you'll find the pairwise comparisons table:

-
+1, however, you might clarify 5. 4) "LSD which does not adjust for multiple tests". Tukey's test does not adjust alpha to control for multiple tests (as, say, the Bonferroni approach does), but it is a perfectly valid strategy for dealing with multiple comparisons issues. – gung Feb 19 '14 at 19:51
@gung, as always, thanks for your comment. If you can clarify a bit more for me I'll be happy to make the revision. SPSS has LSD, Bonferroni, and Sidak corrections available to choose in this GLM module. If I am not mistaken Tukey's correction is HSD, which is not available. Thanks. PK. – Penguin_Knight Feb 19 '14 at 20:17
My mistake, I misread that. I thought it said HSD (Tukey's test), but it says "LSD" (Fisher's least significant difference), which you correctly note does not provide additional control for multiple comparisons beyond the initial F-test. If the wizard does not offer HSD as an option, the OP may need to click Paste instead of OK and then manually add /POSTHOC TUKEY (I think?--it's been a long time) to the syntax before running. – gung Feb 19 '14 at 20:33
@gung, I see, no problem. There are more than 15 different post hoc adjustments in GLM, but once we introduced a covariate, the Post Hoc button becomes inactive (as seen in the screenshot of step 4 above). I guess in SPSS those post hoc cna only work if we don't specify any continuous independent predictors. If we do, the three only choices are LSD, Bonferroni, and Sidak. I did try your method to replace LSD with TUKEY but SPSS showed an error and refused to proceed. – Penguin_Knight Feb 19 '14 at 21:02

Since you want to compare all groups with each other, the tests will not be orthogonal, even if they are a-priori. So you should use a test that addresses that. Tukey's honestly significant differences (HSD) test will do that, and is familiar to many people. You needn't worry about the type of coding used. First, as @Scortchi notes, you can perform this test with any regular coding method (reference level, effect, etc.). Second, SPSS will probably take care of the coding for you.

It's been a long time since I've used SPSS, but I gather you would use the GLM Univariate Analysis option, since you have both continuous and categorical variables. The SPSS documentation for post-hoc comparisons after running a GLM can be found here.

-

The Wikipedia article on post hoc analyses lists several tests/options for comparing groups after a factor has been found significant. I don't know SPSS well anymore, but I expect that it would implement one or more of the tests on that list. You can search for those terms in the SPSS documentation and that should tell you how to specify that you want those comparisons.

Googling for "SPSS post hoc" brings up several promising links as well.

-