I'm working on a health care outcome regression model using the deviation contrast scheme described on the UCLA SAS help page here for a collection of dichotomous predictor variables measuring medical diagnoses. Everyone in my analysis dataset has one primary diagnosis. Deviation contrast coding would compare each diagnosis category with the other categories. However, as illustrated in the example with the hsb2.sas7bdat dataset using the race variable, one category (White) is still left out of the regression model.

My question: Is there a way to code deviation contrasts comparing each level to the grand mean with no reference category while avoiding one variable level being a linear combination of the others?


1 Answer 1


Why do you want that? Whatever coding you are using, you can always, after estimation, compute the estimate of any (estimable) parametric function of interest. For an example (in R, I do not know about sas) see Categorical variable coding to compare all levels to all levels. For a factor with $k$ levels, there is (usually) only $k-1$ degrees of freedom, so in effect for the contrast matrix you can choose any $k-1$ (linearly independent) estimable functions. Others of interest you can calculate after estimation.

If there is only one factor in the model, you can omit the intercept, and represent $k$ contrasts in the contrasts matrix. For deviation coding (as defined here at UCLA, where the group parameter is the deviation of the group mean from the mean of all means, in this case you can represent all those deviations, but leaving out the intercept. The contrast matrix in that case will be $H=I-k^{-1}1 1^T$, with $I$ the identity matrix and $1$ a vector of only 1's. See also Removing intercept from GLM for multiple factorial predictors only works for first factor in model.


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.