Dear all,
A small question of categorical variables.....
I have several categorical variables as potential predictors of outcome
in a modelling situation. Each of these potential predictors is nominal
(as opposed to ordinal). For example, say our 2 hypothetical predictors
are 'colour' with categories blue, red and green and 'material' with
categories leather, cotton, nylon, silk. My problem is to produce a
model which only includes categories which are good predictors of
outcome....(for arguments sake, say our outcome is 'attrractiveness').
I can think of doing this in two ways:
1) Code each k level categorical variable as k-1 dummy variables and
enter the dummy variables as 'a set' for each categorical variable to
give a model.
For example, choosing 'leather' and 'blue' to be the reference
categories, we may get:
Predictor Coef P
Material:
cotton -0.0984709 0.796
nylon 0.0801628 0.858
silk -0.356450 0.150
Colour:
red 0.898338 0.149
green 0.962118 0.000
Tests for terms with more than 1 degree of freedom
Term Chi-Square DF P
material 3.8453 3 0.279
colour 15.0917 2 0.001
Each of the p values for the categories 'red' and 'green' above tell us
the significance of the category relative to 'blue'; each of the p
values of cotton, nylon and silk tell us the significance of the
category relative to 'leather'. The tests at the bottom of the output
provide an 'omnibus' test of the null hypothesis that, for example (for
the 'colour' variable), the coefficients for red and green are both
equal to zero.
So, for 'colour' we may say that red is not significantly different from
blue (p=0.149). We can also see (from the omnibus test) that the
'material' variable is non significant (p=0.279). We can thus omit the
material variable and amalgamate the 'red' and 'blue' categories
together and regenerate the model using a new variable for colour (x1)
with categories:
X1
Red or blue 0
Green 1
2)Code each of the k category variables as *k* dummy variables e.g. for
'material':
X1 x2 x3 x4
Leather 1 0 0 0
Cotton 0 1 0 0
Nylon 0 0 1 0
Silk 0 0 0 1
Similarly we could have dummy binary variables Z1, Z2 and Z3 for
categories blue, red and green respectively.
All of the 7 dummy binary variables will then be entered into a stepwise
variable selection so that at each step dummy variables are selected one
at a time. This may work provided that the procedure does not try to
select all k dummy variables for a k level categorical variable. The
routine is then essentially 'choosing the reference category for you'.
For example, after variable selection we may end up with the only
predictor in the model being Z3 which will tell us the effect of the
colour 'green' relative to the red and blue.
Do both of these suggestions sound reasonable?
Many thanks,
Kim
Dr Kim Pearce,
Industrial Statistics Research Unit (ISRU),
Stephenson Centre,
Stephenson Building,
Newcastle University,
Newcastle upon Tyne,
United Kingdom,
NE1 7RU.
Tel: +44 (0)191 222 6244 (note: new number),
Fax: +44 (0)191 222 7365
|