Category independent variable
Message/Author
 ting hlin posted on Wednesday, June 08, 2011 - 7:42 pm
Hi:
i have a Category independent variable area (1=urban, 2 rural, 3 other), i run the models treating the variables as continuous varaibes, it converged, but i have trouble interpreting the results. then i tried 2 (1 v.s. 2 & 3) or 3 categories dummy coding for variables "area", it did not converge. i have specified number of iterations already.
how should i handling the probelm?
 Linda K. Muthen posted on Thursday, June 09, 2011 - 6:41 am
For a nominal variable with three categories, you should create two dummy variables.
 Oscar Beltran posted on Friday, October 23, 2015 - 8:46 am
Dear Dr. Muthén,

I am having difficulties with my dummy-codes on a TYPE = TWOLEVEL COMPLEX design.

My binary dependent variable is HAVEINS and my independent categorical variable is race_eth [Hispanic(1), white(2), Black(3), other(4)]. The frequencies for HAVEINS by race/ethnicity show that non-Hispanic white have the highest rate.

I dummy-coded 3 Race variables in SAS(Ref. white)using the example below and also verified they all matched the original variable:

If race_eth = 1 then hispanic = 1;
else if race_eth = 3 or race_eth = 4 or race_eth = 2 then race_eth = 0;
else race_eth = -999;

When I run my model:
HAVEINS ON hispanic black other;
OUTPUT: CINTERVAL;

The result indicate that Hispanic have higher rates of insurance, which is the opposite of what the frequencies show.

To address this issue I decided to use the DEFINE command in Mplus:

DEFINE:
IF (race_eth == 1) then hispanic = 1;
IF (race_eth /= 1) then hispanic = 0;
IF (race_eth == 3) then Black = 1;
IF (race_eth /= 3) then Black = 0;
IF (race_eth == 4) then other = 1;
IF (race_eth /= 4) then other = 0;

My questions are:

1)Am I using the DEFINE command correctly?

2)Are the dummy-variables created using DEFINE matching the ones I created in SAS?

Thank you.
 Linda K. Muthen posted on Friday, October 23, 2015 - 4:59 pm
Try

DEFINE:
hispanic = 0;
IF (race_eth == 1) then hispanic = 1;
black = 0;
IF (race_eth == 3) then Black = 1;
other = 0;
IF (race_eth == 4) then other = 1;

Your SAS code talks about 3 or 4 and 2 so I don't think the above Mplus code can be correct. You don't mention 3 or 4 and you don't mention 2.
 Oscar Beltran posted on Friday, October 23, 2015 - 6:07 pm
Hi Dr. Muthen,

Thank you very much for your quick feedback!

I did created a dummy code for each variable, but I omitted the rest of the syntax due space constraints:

If race_eth = 2 then white = 1;
else if race_eth = 3 or race_eth = 4 or race_eth = 1 then white = 0;
else white = -999;

If race_eth = 3 then black = 1;
else if race_eth = 2 or race_eth = 4 or race_eth = 1 then black = 0;
else black = -999;

If race_eth = 4 then other = 1;
else if race_eth = 3 or race_eth = 4 or race_eth = 1 then other = 0;
else other = -999;

I included all variables except white in my model:
HAVEINS ON hispanic black other;
OUTPUT: CINTERVAL;

1) If I recode my dummy variables following your syntax suggestion, would I be matching the SAS dummy codes?

2) Is this the best practice to dummy code in Mplus?

Thank you again,

-Oscar
 Bengt O. Muthen posted on Friday, October 23, 2015 - 6:25 pm