These code fragments are examples that we are using to try and understand these techniques using Mplus. We ask that you treat them as works in progress that explore these techniques, rather than definitive answers as to how to analyze any particular kind of data.
This picks up after Examples 1 and 2 and Examples 3 and 4, but considers predicting class membership.
We now have the input file //mplus/code/hsb6.inp and the data file it reads called https://stats.idre.ucla.edu/wp-content/uploads/2016/02/hsb6.dat .
Example : A latent class analysis with 2 classes, continuous indicators, and one predictor of class membership.
Here is the input file
Data:
File is I:mplushttps://stats.idre.ucla.edu/wp-content/uploads/2016/02/hsb6.dat ;
Variable:
Names are
id gender race ses sch prog locus concept mot career read write math
sci ss hilocus hiconcep himot hiread hiwrite himath hisci hiss academic;
Usevariables are
read write math sci ss mot;
classes = c(2);
Analysis:
Type=mixture;
MODEL:
%overall%
c#1 on mot;
%C#1%
[read math sci ss write *30 ];
%C#2%
[read math sci ss write *60];
OUTPUT:
TECH8;
SAVEDATA:
file is lca_ex5.txt ;
save is cprob;
format is free;
Much of the output is similar to what you have seen in Example #1, so here is the new output that is related to the prediction of being in class 1 based on your score on motivation (mot).
------------------------------------------------------------------------------
LATENT CLASS REGRESSION MODEL PART
C#1 ON
MOT -1.408 0.270 -5.206
Intercepts
C#1 0.755 0.237 3.183
#1. So C1 is the membership in the poorly performing class. And this is like a logistic regression predicting membership in that class. The intercept is .755, suggesting that the odds of being in Class 1 when motivation is 0 is exp(.755) = 2.1276115. The slope is -1.408, but we would normally convert that to an odds ratio, e.g. .24463206. We can invert this for ease of interpretation, yielding 4.08. So, for every unit increase in motivation, your odds of being in Class 1 goes down by about a factor of 4. Note that the minimum for mot is 0 and the max is 1, so this represents a change in going from the lowest to highest level of mot.
------------------------------------------------------------------------------
We now read the saved data file into Stata for comparison to the Mplus output.
infile read write math sci ss mot cprob1 cprob2 class using lca_ex5.txt
A "poor person’s" latent class analysis might be to sum up the read, write, math, sci and ss scores and then divide the students into high and low, and then predict that from mot. We don’t recommend this, but do it to help make this concept more concrete. You can relate the results of the logit analysis below to the latent class regression above.
. gen tot = read + write + math + sci + ss
. summ tot
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
tot | 600 259.9447 40.44849 164.7 350
. gen lotot = tot < 260
. logit lotot mot
Iteration 0: log likelihood = -415.61827
Iteration 1: log likelihood = -403.01575
Iteration 2: log likelihood = -403.0075
Logit estimates Number of obs = 600
LR chi2(1) = 25.22
Prob > chi2 = 0.0000
Log likelihood = -403.0075 Pseudo R2 = 0.0303
------------------------------------------------------------------------------
lotot | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
mot | -1.222341 .2486219 -4.92 0.000 -1.709631 -.7350508
_cons | .748621 .1851841 4.04 0.000 .3856668 1.111575
------------------------------------------------------------------------------
Example 6: A latent class analysis with 3 classes, and continuous indicators, and a predictor of class membership.
Here is the input file
Data:
File is I:mplushsb6.dat ;
Variable:
Names are
id gender race ses sch prog locus concept mot career read write math
sci ss hilocus hiconcep himot hiread hiwrite himath hisci hiss academic;
Usevariables are
read write math sci ss mot;
classes = c(3);
Analysis:
Type=mixture;
MODEL:
%overall%
c#1 on mot;
c#2 on mot;
%C#1%
[read math sci ss write *30 ];
%C#2%
[read math sci ss write *45];
%C#3%
[read math sci ss write *60];
OUTPUT:
TECH8;
SAVEDATA:
file is lca_ex6.txt ;
save is cprob;
format is free;
Here is the output
Much of the output is similar to what you have seen in Example #2, so here is the new output that is related to the prediction of being in class 1 and class 2 based on your score on motivation (mot).
------------------------------------------------------------------------------
LATENT CLASS REGRESSION MODEL PART
C#1 ON
MOT -2.047 0.382 -5.362
C#2 ON
MOT -0.955 0.395 -2.417
Intercepts
C#1 1.600 0.338 4.727
C#2 1.186 0.319 3.723
#1. So C#1 is the membership in the poorly performing class (as compared to the well performing class), and C#2 is the class that is doing middleish, as compared to the well performing class. Class 3 is the well performing class. Since there are 3 Classes, this is now like a multinomial logistic regression. See the stata results below for more on this.
------------------------------------------------------------------------------
We now read the saved data file into Stata for comparison to the Mplus output.
infile read write math sci ss mot cprob1 cprob2 cprob3 class using lca_ex6.txt
For the sake of trying to relate the output from above to things we know, let’s look at the results we would get if we predicted class membership from mot using multinomial logistic regression using the mlogit command. Note that we have made category 3 the base category, while the results are somewhat different, they are in the same ballpark. We do not recommend doing this, but are just showing how you can relate what you know about multinomial logistic regression to the results above.
. mlogit class mot, basecat(3)
Iteration 0: log likelihood = -648.53111
Iteration 1: log likelihood = -628.20907
Iteration 2: log likelihood = -627.84529
Iteration 3: log likelihood = -627.84496
Multinomial logistic regression Number of obs = 600
LR chi2(2) = 41.37
Prob > chi2 = 0.0000
Log likelihood = -627.84496 Pseudo R2 = 0.0319
------------------------------------------------------------------------------
class | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
1 |
mot | -2.121486 .3521118 -6.03 0.000 -2.811612 -1.431359
_cons | 1.675262 .2721728 6.16 0.000 1.141813 2.208711
-------------+----------------------------------------------------------------
2 |
mot | -1.104075 .3411532 -3.24 0.001 -1.772723 -.4354272
_cons | 1.272108 .275151 4.62 0.000 .7328222 1.811394
------------------------------------------------------------------------------
(Outcome class==3 is the comparison group)
