I'm currently studying for an Experimental Design exam. I feel like I'm missing something quite fundamental...

I've attached a minimal example to illustrate my confusion at https://gist.github.com/2942913

We were asked to compare the treatment and sum dummy coding systems. It was pointed out that with the treatment system the values in the "contrast matrix" [1] do not correspond with the observations in the data matrix (or the design matrix). My cbind() command in the example illustrates this. [2]

Using the sum coding system, the contrasts are negative for one value of the factor and positive for the other (and they also don't change when leaving out the interactions). This is supposed to result in "interpretable parameters" (as opposed to the treatment coding system?). My question is how I should interpret this last statement, i.e. why does having a correspondence between the contrast and data matrix with the sum coding result in interpretable parameters? Or: is there something I urgently need to revise?

[1] $( X' X)^{-1} X' )$

[2] Edit (replacing original footnote): There was a 'bug' in the code I provided caused by the following. I used cbind() with a factor (essentially only for presentation purposes; to show the vectors side by side). This resulted in an implicit conversion of the numerical codes in the factor to numbers.

  • 1
    $\begingroup$ (+1) If only for your username. Hilarious. $\endgroup$ – cardinal Jun 17 '12 at 14:04
  • $\begingroup$ That's the first time any of the usernames I ever made up elicits such a reaction! :-) $\endgroup$ – contr.error Jun 17 '12 at 15:49

The short answer to your question is that treatment or 'dummy' variables sum to 1 for each observation row. In the sum coding system the variable, representing the same thing, sum to 0 for each observation row.

The second part of your question, how is sum coding related to interpretable parameters; I would rephrase the question to how does sum coding give useful information about the response or independent variables.

That being said, I think both forms of dummy coding give us interpretable parameters. I think the class is asking, in what circumstances is it preferable to use sum coding instead of treatment coding.

An example from my research experience when sum coding was used instead of treatment coding: We wanted to know if the amount of campaign funds donated to a House member changed when that House member belonged to a political party with majority status. If the House member belonged to a political party that lost majority status they were coded -1 for that column. If the house member gained majority status they were coded +1 for the same column. Over the two terms studied, the house member in each row had dummy variables summing to 0.

If we had used treatment coding it would have the dummy variables per row would have summed to 1.

When you get into the math of a multiple regression the sign associated with a dummy variable affects the coefficient since that dummy is multiplied by all other independent variables in addition to the dependent variable.

Does that help answer your question?

Sources: http://www.palgrave.com/PDFs/9780230577176.pdf http://www.ats.ucla.edu/stat/r/modules/dummy_vars.htm


UCLA has a great page on Coding systems for categorical variables. There should be enough here to also get a good feel for when each type of coding system would be appropriate. One note is that they use slightly different terminology than what you used above, but the coding systems are nonetheless similar.

  • $\begingroup$ Thanks. I worked through the first three examples there, but I don't really have a problem with understanding the contrasts and their interpretation when doing a lm(). I'm more confused about the relation between the coding matrix and resulting contrast matrix (see footnote [1] in my question). Perhaps it's more the linear algebra that's eluding me? $\endgroup$ – contr.error Jun 17 '12 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.