Category independent variable PreviousNext
Mplus Discussion > Categorical Data Modeling >
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
Your Define statement seems fine.

I seem to recall that SAS codes its binary DV in the opposite way, but I may be wrong.
 Samuel Stull posted on Wednesday, August 19, 2020 - 7:32 am
Hi,

I have questions regarding coding a dummy predictor variable for a logistic regression in the "define" statement and then using this variable in the "model" statement.

The categorical predictor is race ("nethrace") and has 5 levels. I created a dummy variable in the "define" statement as follows (where white =1 and will be the reference group):

Define:

black = 0;
IF (NETHRACE == 2) then black = 1;
NatAm = 0;
IF (NETHRACE == 3) then NatAm = 1;
AsPac = 0;
IF (NETHRACE == 4) then AsPac = 1;
Hispan = 0;
IF (NETHRACE == 5) then Hispan = 1;


Then I used this variable in the "model" statement as follows:

MODEL:
%OVERALL%
ANHEDONI ON black(int1);
ANHEDONI ON NatAm (int2);
ANHEDONI ON AsPac (int3);
ANHEDONI ON Hispan (int4);

My interpretation of these results are, for example, anhedonia (vs. no anhedonia) for black relative to white participants.

Does all of this seem to be correct?

Thanks so much for your time.

-Sam
 Bengt O. Muthen posted on Wednesday, August 19, 2020 - 3:54 pm
Seems right. Make sure you handle any missing data on Nethrace.
 Samuel Stull posted on Wednesday, August 19, 2020 - 4:08 pm
Ah, yes. Thank you very much!
Back to top
Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: