I have a question I am not even sure quite how to ask.

When r fits models with  un-ordered categorical variables as predictors
(RHS of model) it automatically converts them into 1 less dichotomous
variables than there are levels.

For example  if I had levels(trait) = ("A","B","C") it would automatically
recode to
          NewVar1 NewVar2
A         0               0
B         1               0
C          0               1

What I would like to know is, is there a way that I can "center" these
categorical variables, and if so how

for continuous variables it is simple
x <- x-mean(x)

for a single dichotomous variable it is not so hard
gender <- gender - sum(gender)/length(gender)
where the gender are (0,1) or (-.5,.5) for  example
 which would give  gender coefficients in a model  that would still reflect
the difference between the two genders but the intercept and the other
coefficients would be for some one of "average gender"

and it is that last part that I am unclear on for a multi (3 or more) level
factor.  How do you set up variables so that the *other* coefficients
reflect the average across the factor levels. Do I need two or three
centered variables? and is there a quick way to get at all those variables
if my factor has many levels, e.g. 14?


Robert

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to