From: Ryan on
Hi Dale and others,

Thanks so much for the feedback yesterday. I was hoping Dale and/or
others would consider taking a look at the code I constructed based on
Dale's example. I'm certain there are errors in my code as I did not
grasp fully the explanations of the code. Hopefully, I'm not
completely off the mark.

Note that my dataset consists of 19 response variables, some of which
are dichotomous (0/1) and while others are continuous/ordinal. There
are 6 hypothesized latent classes and a random intercept.

Code starts now...

/
*--------------------------------------------------------------------------------------------
*/
/*-----LCA with 6 classes, 19 response variables, & Person REs---*/
/
*--------------------------------------------------------------------------------------------
*/
proc nlmixed data=mydata tech=quanew lis=2 method=gauss
maxiter=1000 gconv=.00000000001 fconv=.00000000001;
parms

/* Parameter which expresses probability of */
/* latent class contrasts */
alpha1 = 0.17 alpha2 = 0.17 alpha3 = 0.17
alpha4 = 0.17 alpha5 = 0.17

/* If there are more latent classes, then need */
/* alpha1, alpha2, etc. Number of alpha parms */
/* is one less than number of latent classes. */
log_Valpha1 -4 log_Valpha2 -4 log_Valpha3 -4
log_Valpha4 -4 log_Valpha5 -4

/* Parameters which express probability of Xi=1 | latent class 1 */
bpi11 = 1 bpi21 = 1 bpi31 = 1 bpi41 = 1 bpi51 = 1 bpi61 = 1
bpi71 = 1 bpi81 = 1 bpi91 = 1 bpi101 = 1 bpi111 = 1
bpi121 = 1 bpi131 = 1 bpi141 = 1 bpi151 = 1 bpi161 = 1
bpi171 = 1 bpi181 = 1 bpi191 = 0

/* Parameters which express probability of Xi=1 | latent class 2 */
bpi12 = .5 bpi22 = .5 bpi32 = .5 bpi42 = .5 bpi51 = .5 bpi62 = .5
bpi72 = .5 bpi82 = .5 bpi92 = .5 bpi102 = .5 bpi112 = .5
bpi122 = .5 bpi132 = .5 bpi142 = .5 bpi152 = .5 bpi162 = -.5
bpi172 = .5 bpi182 = .5 bpi192 = .5

/* Parameters which express probability of Xi=1 | latent class 3 */
bpi13 = 1 bpi23 = 1 bpi33 = 1 bpi43 = 1 bpi53 = 1 bpi63 = 1
bpi73 = 1 bpi83 = 1 bpi93 = 1 bpi103 = 1 bpi113 = 1
bpi123 = 1 bpi133 = 1 bpi143 = 1 bpi153 = 1 bpi163 = 1
bpi173 = 1 bpi183 = 1 bpi193 = 0

/* Parameters which express probability of Xi=1 | latent class 4 */
bpi14 = .5 bpi24 = .5 bpi34 = .5 bpi44 = .5 bpi54 = .5 bpi64 = .5
bpi74 = .5 bpi84 = .5 bpi94 = .5 bpi104 = .5 bpi114 = .5
bpi124 = .5 bpi134 = .5 bpi144 = .5 bpi154 = .5 bpi164 = -.5
bpi174 = .5 bpi184 = .5 bpi194 = .5

/* Parameters which express probability of Xi=1 | latent class 5 */
bpi15 = 1 bpi25 = 1 bpi35 = 1 bpi45 = 1 bpi55 = 1 bpi65 = 1
bpi75 = 1 bpi85 = 1 bpi95 = 1 bpi105 = 1 bpi115 = 1
bpi125 = 1 bpi135 = 1 bpi145 = 1 bpi155 = 1 bpi165 = 1
bpi175 = 1 bpi185 = 1 bpi195 = 0

/* Parameters which express probability of Xi=1 | latent class 6 */
bpi16 = .5 bpi26 = .5 bpi36 = .5 bpi46 = .5 bpi51 = .5 bpi66 = .5
bpi76 = .5 bpi86 = .5 bpi96 = .5 bpi106 = .5 bpi116 = .5
bpi126 = .5 bpi136 = .5 bpi146 = .5 bpi156 = .5 bpi166 = -.5
bpi176 = .5 bpi186 = .5 bpi196 = .5
;

bounds -6 <= bpi11 - bpi191 <= 6;

**** latent class part;

pi11 = 1/(1+exp(-bpi11)); pi12 = 1/(1+exp(-bpi12));
pi21 = 1/(1+exp(-bpi21)); pi22 = 1/(1+exp(-bpi22));
pi31 = 1/(1+exp(-bpi31)); pi32 = 1/(1+exp(-bpi32));
pi41 = 1/(1+exp(-bpi41)); pi42 = 1/(1+exp(-bpi42));
pi51 = 1/(1+exp(-bpi51)); pi52 = 1/(1+exp(-bpi52));
pi61 = 1/(1+exp(-bpi61)); pi62 = 1/(1+exp(-bpi62));
pi71 = 1/(1+exp(-bpi71)); pi72 = 1/(1+exp(-bpi72));
pi81 = 1/(1+exp(-bpi81)); pi82 = 1/(1+exp(-bpi82));
pi91 = 1/(1+exp(-bpi91)); pi92 = 1/(1+exp(-bpi92));
pi101 = 1/(1+exp(-bpi101)); pi102 = 1/(1+exp(-bpi102));
pi111 = 1/(1+exp(-bpi111)); pi112 = 1/(1+exp(-bpi112));
pi121 = 1/(1+exp(-bpi121)); pi122 = 1/(1+exp(-bpi122));
pi131 = 1/(1+exp(-bpi131)); pi132 = 1/(1+exp(-bpi132));
pi141 = 1/(1+exp(-bpi141)); pi142 = 1/(1+exp(-bpi142));
pi151 = 1/(1+exp(-bpi151)); pi152 = 1/(1+exp(-bpi152));
pi161 = 1/(1+exp(-bpi161)); pi162 = 1/(1+exp(-bpi162));
pi171 = 1/(1+exp(-bpi171)); pi172 = 1/(1+exp(-bpi172));
pi181 = 1/(1+exp(-bpi181)); pi182 = 1/(1+exp(-bpi182));
pi191 = 1/(1+exp(-bpi191)); pi192 = 1/(1+exp(-bpi192));

pi13 = 1/(1+exp(-bpi13)); pi14 = 1/(1+exp(-bpi12));
pi23 = 1/(1+exp(-bpi23)); pi24 = 1/(1+exp(-bpi22));
pi33 = 1/(1+exp(-bpi33)); pi34 = 1/(1+exp(-bpi34));
pi43 = 1/(1+exp(-bpi43)); pi44 = 1/(1+exp(-bpi44));
pi53 = 1/(1+exp(-bpi53)); pi54 = 1/(1+exp(-bpi54));
pi63 = 1/(1+exp(-bpi63)); pi64 = 1/(1+exp(-bpi64));
pi73 = 1/(1+exp(-bpi73)); pi74 = 1/(1+exp(-bpi74));
pi83 = 1/(1+exp(-bpi83)); pi84 = 1/(1+exp(-bpi84));
pi93 = 1/(1+exp(-bpi93)); pi94 = 1/(1+exp(-bpi94));
pi103 = 1/(1+exp(-bpi103)); pi104 = 1/(1+exp(-bpi104));
pi113 = 1/(1+exp(-bpi113)); pi114 = 1/(1+exp(-bpi114));
pi123 = 1/(1+exp(-bpi123)); pi124 = 1/(1+exp(-bpi124));
pi133 = 1/(1+exp(-bpi133)); pi134 = 1/(1+exp(-bpi134));
pi143 = 1/(1+exp(-bpi143)); pi144 = 1/(1+exp(-bpi144));
pi153 = 1/(1+exp(-bpi153)); pi154 = 1/(1+exp(-bpi154));
pi163 = 1/(1+exp(-bpi163)); pi164 = 1/(1+exp(-bpi164));
pi173 = 1/(1+exp(-bpi173)); pi174 = 1/(1+exp(-bpi174));
pi183 = 1/(1+exp(-bpi183)); pi184 = 1/(1+exp(-bpi184));
pi193 = 1/(1+exp(-bpi193)); pi194 = 1/(1+exp(-bpi194));

pi15 = 1/(1+exp(-bpi15)); pi16 = 1/(1+exp(-bpi16));
pi25 = 1/(1+exp(-bpi25)); pi26 = 1/(1+exp(-bpi26));
pi35 = 1/(1+exp(-bpi35)); pi36 = 1/(1+exp(-bpi36));
pi45 = 1/(1+exp(-bpi45)); pi46 = 1/(1+exp(-bpi46));
pi55 = 1/(1+exp(-bpi55)); pi56 = 1/(1+exp(-bpi56));
pi65 = 1/(1+exp(-bpi65)); pi66 = 1/(1+exp(-bpi66));
pi75 = 1/(1+exp(-bpi75)); pi76 = 1/(1+exp(-bpi76));
pi85 = 1/(1+exp(-bpi85)); pi86 = 1/(1+exp(-bpi86));
pi95 = 1/(1+exp(-bpi95)); pi96 = 1/(1+exp(-bpi96));
pi105 = 1/(1+exp(-bpi105)); pi106 = 1/(1+exp(-bpi106));
pi115 = 1/(1+exp(-bpi115)); pi116 = 1/(1+exp(-bpi116));
pi125 = 1/(1+exp(-bpi125)); pi126 = 1/(1+exp(-bpi126));
pi135 = 1/(1+exp(-bpi135)); pi136 = 1/(1+exp(-bpi136));
pi145 = 1/(1+exp(-bpi145)); pi146 = 1/(1+exp(-bpi146));
pi155 = 1/(1+exp(-bpi155)); pi156 = 1/(1+exp(-bpi156));
pi165 = 1/(1+exp(-bpi165)); pi166 = 1/(1+exp(-bpi166));
pi175 = 1/(1+exp(-bpi175)); pi176 = 1/(1+exp(-bpi176));
pi185 = 1/(1+exp(-bpi185)); pi186 = 1/(1+exp(-bpi186));
pi195 = 1/(1+exp(-bpi195)); pi196 = 1/(1+exp(-bpi196));

prod11 = (pi11**x1)*(1-pi11)**(1-x1);
prod12 = (pi12**x1)*(1-pi12)**(1-x1);
prod13 = (pi13**x1)*(1-pi13)**(1-x1);
prod14 = (pi14**x1)*(1-pi14)**(1-x1);
prod15 = (pi15**x1)*(1-pi15)**(1-x1);
prod16 = (pi16**x1)*(1-pi16)**(1-x1);
prod21 = (pi21**x2)*(1-pi21)**(1-x2);
prod22 = (pi22**x2)*(1-pi22)**(1-x2);
prod23 = (pi23**x2)*(1-pi23)**(1-x2);
prod24 = (pi24**x2)*(1-pi24)**(1-x2);
prod25 = (pi25**x2)*(1-pi25)**(1-x2);
prod26 = (pi26**x2)*(1-pi26)**(1-x2);
prod31 = (pi31**x3)*(1-pi31)**(1-x3);
prod32 = (pi32**x3)*(1-pi32)**(1-x3);
prod33 = (pi33**x3)*(1-pi33)**(1-x3);
prod34 = (pi34**x3)*(1-pi34)**(1-x3);
prod35 = (pi35**x3)*(1-pi35)**(1-x3);
prod36 = (pi36**x3)*(1-pi36)**(1-x3);
prod41 = (pi41**x1)*(1-pi41)**(1-x4);
prod42 = (pi42**x4)*(1-pi42)**(1-x4);
prod43 = (pi43**x4)*(1-pi43)**(1-x4);
prod44 = (pi44**x4)*(1-pi44)**(1-x4);
prod45 = (pi45**x4)*(1-pi45)**(1-x4);
prod46 = (pi46**x4)*(1-pi46)**(1-x4);
prod51 = (pi51**x5)*(1-pi51)**(1-x5);
prod52 = (pi52**x5)*(1-pi52)**(1-x5);
prod53 = (pi53**x5)*(1-pi53)**(1-x5);
prod54 = (pi54**x5)*(1-pi54)**(1-x5);
prod55 = (pi55**x5)*(1-pi55)**(1-x5);
prod56 = (pi56**x5)*(1-pi56)**(1-x5);
prod61 = (pi61**x6)*(1-pi61)**(1-x6);
prod62 = (pi62**x6)*(1-pi62)**(1-x6);
prod63 = (pi63**x6)*(1-pi63)**(1-x6);
prod64 = (pi64**x6)*(1-pi64)**(1-x6);
prod65 = (pi65**x6)*(1-pi65)**(1-x6);
prod66 = (pi66**x6)*(1-pi66)**(1-x6);
prod71 = (pi71**x7)*(1-pi71)**(1-x7);
prod72 = (pi72**x7)*(1-pi72)**(1-x7);
prod73 = (pi73**x7)*(1-pi73)**(1-x7);
prod74 = (pi74**x7)*(1-pi74)**(1-x7);
prod75 = (pi75**x7)*(1-pi75)**(1-x7);
prod76 = (pi76**x7)*(1-pi76)**(1-x7);
prod81 = (pi81**x8)*(1-pi81)**(1-x8);
prod82 = (pi82**x8)*(1-pi82)**(1-x8);
prod83 = (pi83**x8)*(1-pi83)**(1-x8);
prod84 = (pi84**x8)*(1-pi84)**(1-x8);
prod85 = (pi85**x8)*(1-pi85)**(1-x8);
prod86 = (pi86**x8)*(1-pi86)**(1-x8);
prod91 = (pi91**x9)*(1-pi91)**(1-x9);
prod92 = (pi92**x9)*(1-pi92)**(1-x9);
prod93 = (pi93**x9)*(1-pi93)**(1-x9);
prod94 = (pi94**x9)*(1-pi94)**(1-x9);
prod95 = (pi95**x9)*(1-pi95)**(1-x9);
prod96 = (pi96**x9)*(1-pi96)**(1-x9);
prod101 = (pi101**x10)*(1-pi101)**(1-x10);
prod102 = (pi102**x10)*(1-pi102)**(1-x10);
prod103 = (pi103**x10)*(1-pi103)**(1-x10);
prod104 = (pi104**x10)*(1-pi104)**(1-x10);
prod105 = (pi105**x10)*(1-pi105)**(1-x10);
prod106 = (pi106**x10)*(1-pi106)**(1-x10);
prod111 = (pi111**x11)*(1-pi111)**(1-x11);
prod112 = (pi112**x11)*(1-pi112)**(1-x11);
prod113 = (pi113**x11)*(1-pi113)**(1-x11);
prod114 = (pi114**x11)*(1-pi114)**(1-x11);
prod115 = (pi115**x11)*(1-pi115)**(1-x11);
prod116 = (pi116**x11)*(1-pi116)**(1-x11);
prod121 = (pi121**x12)*(1-pi121)**(1-x12);
prod122 = (pi122**x12)*(1-pi122)**(1-x12);
prod123 = (pi123**x12)*(1-pi123)**(1-x12);
prod124 = (pi124**x12)*(1-pi124)**(1-x12);
prod125 = (pi125**x12)*(1-pi125)**(1-x12);
prod126 = (pi126**x12)*(1-pi126)**(1-x12);
prod131 = (pi131**x13)*(1-pi131)**(1-x13);
prod132 = (pi132**x13)*(1-pi132)**(1-x13);
prod133 = (pi133**x13)*(1-pi133)**(1-x13);
prod134 = (pi134**x13)*(1-pi134)**(1-x13);
prod135 = (pi135**x13)*(1-pi135)**(1-x13);
prod136 = (pi136**x13)*(1-pi136)**(1-x13);
prod141 = (pi141**x14)*(1-pi141)**(1-x14);
prod142 = (pi142**x14)*(1-pi142)**(1-x14);
prod143 = (pi143**x14)*(1-pi143)**(1-x14);
prod144 = (pi144**x14)*(1-pi144)**(1-x14);
prod145 = (pi145**x14)*(1-pi145)**(1-x14);
prod146 = (pi146**x14)*(1-pi146)**(1-x14);
prod151 = (pi151**x15)*(1-pi151)**(1-x15);
prod152 = (pi152**x15)*(1-pi152)**(1-x15);
prod153 = (pi153**x15)*(1-pi153)**(1-x15);
prod154 = (pi154**x15)*(1-pi154)**(1-x15);
prod155 = (pi155**x15)*(1-pi155)**(1-x15);
prod156 = (pi156**x15)*(1-pi156)**(1-x15);
prod161 = (pi161**x16)*(1-pi161)**(1-x16);
prod162 = (pi162**x16)*(1-pi162)**(1-x16);
prod163 = (pi163**x16)*(1-pi163)**(1-x16);
prod164 = (pi164**x16)*(1-pi164)**(1-x16);
prod165 = (pi165**x16)*(1-pi165)**(1-x16);
prod166 = (pi166**x16)*(1-pi166)**(1-x16);
prod171 = (pi171**x17)*(1-pi171)**(1-x17);
prod172 = (pi172**x17)*(1-pi172)**(1-x17);
prod173 = (pi173**x17)*(1-pi173)**(1-x17);
prod174 = (pi174**x17)*(1-pi174)**(1-x17);
prod175 = (pi175**x17)*(1-pi175)**(1-x17);
prod176 = (pi176**x17)*(1-pi176)**(1-x17);
prod181 = (pi181**x18)*(1-pi181)**(1-x18);
prod182 = (pi182**x18)*(1-pi182)**(1-x18);
prod183 = (pi183**x18)*(1-pi183)**(1-x18);
prod184 = (pi184**x18)*(1-pi184)**(1-x18);
prod185 = (pi185**x18)*(1-pi185)**(1-x18);
prod186 = (pi186**x18)*(1-pi186)**(1-x18);
prod191 = (pi191**x19)*(1-pi191)**(1-x19);
prod192 = (pi192**x19)*(1-pi192)**(1-x19);
prod193 = (pi193**x19)*(1-pi193)**(1-x19);
prod194 = (pi194**x19)*(1-pi194)**(1-x19);
prod195 = (pi195**x19)*(1-pi195)**(1-x19);
prod196 = (pi196**x19)*(1-pi196)**(1-x19);

/* model probability of each latent class. */
/* Note that we add random effect u1 to alpha1. U1 is */
/* person random effect on probability of latent class */
/* 1. If there are more latent classes, then would */
/* need terms u2, u3, etc. */

*************Not Clear On How to Contstruct Code Below***************

eta1=exp(alpha1 + u1)/(1+exp(alpha1 + u1));
eta2=1/(1+exp(alpha2 + u2));
eta3=exp(alpha3+ u3)/(1+exp(alpha3 + u3));
eta4=1/(1+exp(alpha4 + u4));
eta5=exp(alpha5 + u5)/(1+exp(alpha5 + u5));
eta6=1/(1+exp(alpha5 + u5));

/* Construct likelihood and log likelihood */
l_latclass=eta1*prod11*prod21*prod31*prod41*
prod51*prod61*prod71*prod81*
prod91*prod101*prod111*prod121*
prod131*prod141*prod151*prod161*
prod171*prod181*prod191
+
eta2*prod12*prod22*prod32*prod42*
prod52*prod62*prod72*prod82*
prod92*prod102*prod112*prod122*
prod132*prod142*prod152*prod162*
prod172*prod182*prod192
+
eta3*prod13*prod23*prod33*prod43*
prod53*prod63*prod73*prod83*
prod93*prod103*prod113*prod123*
prod133*prod143*prod153*prod163*
prod173*prod183*prod193
+
eta4*prod14*prod24*prod34*prod44*
prod54*prod64*prod74*prod84*
prod94*prod104*prod114*prod124*
prod134*prod144*prod154*prod164*
prod174*prod184*prod194
+
eta5*prod15*prod25*prod35*prod45*
prod55*prod65*prod75*prod85*
prod95*prod105*prod115*prod125*
prod135*prod145*prod155*prod165*
prod175*prod185*prod195
+
eta6*prod16*prod26*prod36*prod46*
prod56*prod66*prod76*prod86*
prod96*prod106*prod116*prod126*
prod136*prod146*prod156*prod166*
prod176*prod186*prod196;

ll_latclass = log(l_latclass);

/* Maximize the latent class log likelihood */
model ll_latclass ˜ general(ll_latclass);

/* Model the variance of the latent class probability */
random u1 u2 u3 u4 u5 ~ normal([0], [exp(2*log_Valpha1)],
[0], [exp(2*log_Valpha2)],
[0], [exp(2*log_Valpha3)],
[0], [exp(2*log_Valpha4)],
[0], [exp(2*log_Valpha5)] )
subject=person;
run;

/------------------------------END SAS
CODE--------------------------------------/

Thanks!

Ryan
From: Ryan on
On Dec 3, 10:03 am, Ryan <ryan.andrew.bl...(a)gmail.com> wrote:
> Hi Dale and others,
>
> Thanks so much for the feedback yesterday. I was hoping Dale and/or
> others would consider taking a look at the code I constructed based on
> Dale's example. I'm certain there are errors in my code as I did not
> grasp fully the explanations of the code. Hopefully, I'm not
> completely off the mark.
>
> Note that my dataset consists of 19 response variables, some of which
> are dichotomous (0/1) and while others are continuous/ordinal. There
> are 6 hypothesized latent classes and a random intercept.
>
> Code starts now...
>
> /
> *--------------------------------------------------------------------------­------------------
> */
> /*-----LCA with 6 classes, 19 response variables, & Person REs---*/
> /
> *--------------------------------------------------------------------------­------------------
> */
> proc nlmixed data=mydata tech=quanew lis=2 method=gauss
>             maxiter=1000 gconv=.00000000001 fconv=.00000000001;
>  parms
>
>    /* Parameter which expresses probability of */
>    /* latent class contrasts                   */
>    alpha1 = 0.17 alpha2 = 0.17 alpha3 = 0.17
>    alpha4 = 0.17 alpha5 = 0.17
>
>    /* If there are more latent classes, then need */
>    /* alpha1, alpha2, etc.  Number of alpha parms */
>    /* is one less than number of latent classes.  */
>    log_Valpha1 -4 log_Valpha2 -4 log_Valpha3 -4
>    log_Valpha4 -4 log_Valpha5 -4
>
>    /* Parameters which express probability of Xi=1 | latent class 1 */
>    bpi11 = 1 bpi21 = 1 bpi31 = 1 bpi41 = 1 bpi51 = 1 bpi61 = 1
>    bpi71 = 1 bpi81 = 1 bpi91 = 1 bpi101 = 1 bpi111 = 1
>    bpi121 = 1 bpi131 = 1 bpi141 = 1 bpi151 = 1 bpi161 = 1
>    bpi171 = 1 bpi181 = 1 bpi191 = 0
>
>    /* Parameters which express probability of Xi=1 | latent class 2 */
>    bpi12 = .5 bpi22 = .5 bpi32 = .5 bpi42 = .5 bpi51 = .5 bpi62 = .5
>    bpi72 = .5 bpi82 = .5 bpi92 = .5 bpi102 = .5 bpi112 = .5
>    bpi122 = .5 bpi132 = .5 bpi142 = .5 bpi152 = .5 bpi162 = -.5
>    bpi172 = .5 bpi182 = .5 bpi192 = .5
>
>    /* Parameters which express probability of Xi=1 | latent class 3 */
>    bpi13 = 1 bpi23 = 1 bpi33 = 1 bpi43 = 1 bpi53 = 1 bpi63 = 1
>    bpi73 = 1 bpi83 = 1 bpi93 = 1 bpi103 = 1 bpi113 = 1
>    bpi123 = 1 bpi133 = 1 bpi143 = 1 bpi153 = 1 bpi163 = 1
>    bpi173 = 1 bpi183 = 1 bpi193 = 0
>
>    /* Parameters which express probability of Xi=1 | latent class 4 */
>    bpi14 = .5 bpi24 = .5 bpi34 = .5 bpi44 = .5 bpi54 = .5 bpi64 = .5
>    bpi74 = .5 bpi84 = .5 bpi94 = .5 bpi104 = .5 bpi114 = .5
>    bpi124 = .5 bpi134 = .5 bpi144 = .5 bpi154 = .5 bpi164 = -.5
>    bpi174 = .5 bpi184 = .5 bpi194 = .5
>
>    /* Parameters which express probability of Xi=1 | latent class 5 */
>    bpi15 = 1 bpi25 = 1 bpi35 = 1 bpi45 = 1 bpi55 = 1 bpi65 = 1
>    bpi75 = 1 bpi85 = 1 bpi95 = 1 bpi105 = 1 bpi115 = 1
>    bpi125 = 1 bpi135 = 1 bpi145 = 1 bpi155 = 1 bpi165 = 1
>    bpi175 = 1 bpi185 = 1 bpi195 = 0
>
>    /* Parameters which express probability of Xi=1 | latent class 6 */
>    bpi16 = .5 bpi26 = .5 bpi36 = .5 bpi46 = .5 bpi51 = .5 bpi66 = .5
>    bpi76 = .5 bpi86 = .5 bpi96 = .5 bpi106 = .5 bpi116 = .5
>    bpi126 = .5 bpi136 = .5 bpi146 = .5 bpi156 = .5 bpi166 = -.5
>    bpi176 = .5 bpi186 = .5 bpi196 = .5
>  ;
>
>  bounds -6 <= bpi11 - bpi191 <= 6;
>
>  **** latent class part;
>
>  pi11 = 1/(1+exp(-bpi11)); pi12 = 1/(1+exp(-bpi12));
>  pi21 = 1/(1+exp(-bpi21)); pi22 = 1/(1+exp(-bpi22));
>  pi31 = 1/(1+exp(-bpi31)); pi32 = 1/(1+exp(-bpi32));
>  pi41 = 1/(1+exp(-bpi41)); pi42 = 1/(1+exp(-bpi42));
>  pi51 = 1/(1+exp(-bpi51)); pi52 = 1/(1+exp(-bpi52));
>  pi61 = 1/(1+exp(-bpi61)); pi62 = 1/(1+exp(-bpi62));
>  pi71 = 1/(1+exp(-bpi71)); pi72 = 1/(1+exp(-bpi72));
>  pi81 = 1/(1+exp(-bpi81)); pi82 = 1/(1+exp(-bpi82));
>  pi91 = 1/(1+exp(-bpi91)); pi92 = 1/(1+exp(-bpi92));
>  pi101 = 1/(1+exp(-bpi101)); pi102 = 1/(1+exp(-bpi102));
>  pi111 = 1/(1+exp(-bpi111)); pi112 = 1/(1+exp(-bpi112));
>  pi121 = 1/(1+exp(-bpi121)); pi122 = 1/(1+exp(-bpi122));
>  pi131 = 1/(1+exp(-bpi131)); pi132 = 1/(1+exp(-bpi132));
>  pi141 = 1/(1+exp(-bpi141)); pi142 = 1/(1+exp(-bpi142));
>  pi151 = 1/(1+exp(-bpi151)); pi152 = 1/(1+exp(-bpi152));
>  pi161 = 1/(1+exp(-bpi161)); pi162 = 1/(1+exp(-bpi162));
>  pi171 = 1/(1+exp(-bpi171)); pi172 = 1/(1+exp(-bpi172));
>  pi181 = 1/(1+exp(-bpi181)); pi182 = 1/(1+exp(-bpi182));
>  pi191 = 1/(1+exp(-bpi191)); pi192 = 1/(1+exp(-bpi192));
>
>  pi13 = 1/(1+exp(-bpi13)); pi14 = 1/(1+exp(-bpi12));
>  pi23 = 1/(1+exp(-bpi23)); pi24 = 1/(1+exp(-bpi22));
>  pi33 = 1/(1+exp(-bpi33)); pi34 = 1/(1+exp(-bpi34));
>  pi43 = 1/(1+exp(-bpi43)); pi44 = 1/(1+exp(-bpi44));
>  pi53 = 1/(1+exp(-bpi53)); pi54 = 1/(1+exp(-bpi54));
>  pi63 = 1/(1+exp(-bpi63)); pi64 = 1/(1+exp(-bpi64));
>  pi73 = 1/(1+exp(-bpi73)); pi74 = 1/(1+exp(-bpi74));
>  pi83 = 1/(1+exp(-bpi83)); pi84 = 1/(1+exp(-bpi84));
>  pi93 = 1/(1+exp(-bpi93)); pi94 = 1/(1+exp(-bpi94));
>  pi103 = 1/(1+exp(-bpi103)); pi104 = 1/(1+exp(-bpi104));
>  pi113 = 1/(1+exp(-bpi113)); pi114 = 1/(1+exp(-bpi114));
>  pi123 = 1/(1+exp(-bpi123)); pi124 = 1/(1+exp(-bpi124));
>  pi133 = 1/(1+exp(-bpi133)); pi134 = 1/(1+exp(-bpi134));
>  pi143 = 1/(1+exp(-bpi143)); pi144 = 1/(1+exp(-bpi144));
>  pi153 = 1/(1+exp(-bpi153)); pi154 = 1/(1+exp(-bpi154));
>  pi163 = 1/(1+exp(-bpi163)); pi164 = 1/(1+exp(-bpi164));
>  pi173 = 1/(1+exp(-bpi173)); pi174 = 1/(1+exp(-bpi174));
>  pi183 = 1/(1+exp(-bpi183)); pi184 = 1/(1+exp(-bpi184));
>  pi193 = 1/(1+exp(-bpi193)); pi194 = 1/(1+exp(-bpi194));
>
>  pi15 = 1/(1+exp(-bpi15)); pi16 = 1/(1+exp(-bpi16));
>  pi25 = 1/(1+exp(-bpi25)); pi26 = 1/(1+exp(-bpi26));
>  pi35 = 1/(1+exp(-bpi35)); pi36 = 1/(1+exp(-bpi36));
>  pi45 = 1/(1+exp(-bpi45)); pi46 = 1/(1+exp(-bpi46));
>  pi55 = 1/(1+exp(-bpi55)); pi56 = 1/(1+exp(-bpi56));
>  pi65 = 1/(1+exp(-bpi65)); pi66 = 1/(1+exp(-bpi66));
>  pi75 = 1/(1+exp(-bpi75)); pi76 = 1/(1+exp(-bpi76));
>  pi85 = 1/(1+exp(-bpi85)); pi86 = 1/(1+exp(-bpi86));
>  pi95 = 1/(1+exp(-bpi95)); pi96 = 1/(1+exp(-bpi96));
>  pi105 = 1/(1+exp(-bpi105)); pi106 = 1/(1+exp(-bpi106));
>  pi115 = 1/(1+exp(-bpi115)); pi116 = 1/(1+exp(-bpi116));
>  pi125 = 1/(1+exp(-bpi125)); pi126 = 1/(1+exp(-bpi126));
>  pi135 = 1/(1+exp(-bpi135)); pi136 = 1/(1+exp(-bpi136));
>  pi145 = 1/(1+exp(-bpi145)); pi146 = 1/(1+exp(-bpi146));
>  pi155 = 1/(1+exp(-bpi155)); pi156 = 1/(1+exp(-bpi156));
>  pi165 = 1/(1+exp(-bpi165)); pi166 = 1/(1+exp(-bpi166));
>  pi175 = 1/(1+exp(-bpi175)); pi176 = 1/(1+exp(-bpi176));
>  pi185 = 1/(1+exp(-bpi185)); pi186 = 1/(1+exp(-bpi186));
>  pi195 = 1/(1+exp(-bpi195)); pi196 = 1/(1+exp(-bpi196));
>
>  prod11 = (pi11**x1)*(1-pi11)**(1-x1);
>    prod12 = (pi12**x1)*(1-pi12)**(1-x1);
>      prod13 = (pi13**x1)*(1-pi13)**(1-x1);
>        prod14 = (pi14**x1)*(1-pi14)**(1-x1);
>          prod15 = (pi15**x1)*(1-pi15)**(1-x1);
>             prod16 = (pi16**x1)*(1-pi16)**(1-x1);
>  prod21 = (pi21**x2)*(1-pi21)**(1-x2);
>    prod22 = (pi22**x2)*(1-pi22)**(1-x2);
>      prod23 = (pi23**x2)*(1-pi23)**(1-x2);
>        prod24 = (pi24**x2)*(1-pi24)**(1-x2);
>          prod25 = (pi25**x2)*(1-pi25)**(1-x2);
>             prod26 = (pi26**x2)*(1-pi26)**(1-x2);
>   prod31 = (pi31**x3)*(1-pi31)**(1-x3);
>     prod32 = (pi32**x3)*(1-pi32)**(1-x3);
>       prod33 = (pi33**x3)*(1-pi33)**(1-x3);
>         prod34 = (pi34**x3)*(1-pi34)**(1-x3);
>           prod35 = (pi35**x3)*(1-pi35)**(1-x3);
>             prod36 = (pi36**x3)*(1-pi36)**(1-x3);
>   prod41 = (pi41**x1)*(1-pi41)**(1-x4);
>     prod42 = (pi42**x4)*(1-pi42)**(1-x4);
>       prod43 = (pi43**x4)*(1-pi43)**(1-x4);
>         prod44 = (pi44**x4)*(1-pi44)**(1-x4);
>           prod45 = (pi45**x4)*(1-pi45)**(1-x4);
>             prod46 = (pi46**x4)*(1-pi46)**(1-x4);
>   prod51 = (pi51**x5)*(1-pi51)**(1-x5);
>     prod52 = (pi52**x5)*(1-pi52)**(1-x5);
>       prod53 = (pi53**x5)*(1-pi53)**(1-x5);
>         prod54 = (pi54**x5)*(1-pi54)**(1-x5);
>           prod55 = (pi55**x5)*(1-pi55)**(1-x5);
>             prod56 = (pi56**x5)*(1-pi56)**(1-x5);
>   prod61 = (pi61**x6)*(1-pi61)**(1-x6);
>     prod62 = (pi62**x6)*(1-pi62)**(1-x6);
>       prod63 = (pi63**x6)*(1-pi63)**(1-x6);
>         prod64 = (pi64**x6)*(1-pi64)**(1-x6);
>            prod65 = (pi65**x6)*(1-pi65)**(1-x6);
>              prod66 = (pi66**x6)*(1-pi66)**(1-x6);
>   prod71 = (pi71**x7)*(1-pi71)**(1-x7);
>     prod72 = (pi72**x7)*(1-pi72)**(1-x7);
>       prod73 = (pi73**x7)*(1-pi73)**(1-x7);
>         prod74 = (pi74**x7)*(1-pi74)**(1-x7);
>           prod75 = (pi75**x7)*(1-pi75)**(1-x7);
>              prod76 = (pi76**x7)*(1-pi76)**(1-x7);
>   prod81 = (pi81**x8)*(1-pi81)**(1-x8);
>     prod82 = (pi82**x8)*(1-pi82)**(1-x8);
>       prod83 = (pi83**x8)*(1-pi83)**(1-x8);
>         prod84 = (pi84**x8)*(1-pi84)**(1-x8);
>           prod85 = (pi85**x8)*(1-pi85)**(1-x8);
>               prod86 = (pi86**x8)*(1-pi86)**(1-x8);
>   prod91 = (pi91**x9)*(1-pi91)**(1-x9);
>     prod92 = (pi92**x9)*(1-pi92)**(1-x9);
>       prod93 = (pi93**x9)*(1-pi93)**(1-x9);
>         prod94 = (pi94**x9)*(1-pi94)**(1-x9);
>           prod95 = (pi95**x9)*(1-pi95)**(1-x9);
>               prod96 = (pi96**x9)*(1-pi96)**(1-x9);
>   prod101 = (pi101**x10)*(1-pi101)**(1-x10);
>     prod102 = (pi102**x10)*(1-pi102)**(1-x10);
>       prod103 = (pi103**x10)*(1-pi103)**(1-x10);
>         prod104 = (pi104**x10)*(1-pi104)**(1-x10);
>           prod105 = (pi105**x10)*(1-pi105)**(1-x10);
>             prod106 = (pi106**x10)*(1-pi106)**(1-x10);
>   prod111 = (pi111**x11)*(1-pi111)**(1-x11);
>     prod112 = (pi112**x11)*(1-pi112)**(1-x11);
>       prod113 = (pi113**x11)*(1-pi113)**(1-x11);
>         prod114 = (pi114**x11)*(1-pi114)**(1-x11);
>           prod115 = (pi115**x11)*(1-pi115)**(1-x11);
>             prod116 = (pi116**x11)*(1-pi116)**(1-x11);
>   prod121 = (pi121**x12)*(1-pi121)**(1-x12);
>     prod122 = (pi122**x12)*(1-pi122)**(1-x12);
>       prod123 = (pi123**x12)*(1-pi123)**(1-x12);
>         prod124 = (pi124**x12)*(1-pi124)**(1-x12);
>           prod125 = (pi125**x12)*(1-pi125)**(1-x12);
>             prod126 = (pi126**x12)*(1-pi126)**(1-x12);
>   prod131 = (pi131**x13)*(1-pi131)**(1-x13);
>     prod132 = (pi132**x13)*(1-pi132)**(1-x13);
>       prod133 = (pi133**x13)*(1-pi133)**(1-x13);
>         prod134 = (pi134**x13)*(1-pi134)**(1-x13);
>           prod135 = (pi135**x13)*(1-pi135)**(1-x13);
>             prod136 = (pi136**x13)*(1-pi136)**(1-x13);
>   prod141 = (pi141**x14)*(1-pi141)**(1-x14);
>     prod142 = (pi142**x14)*(1-pi142)**(1-x14);
>       prod143 = (pi143**x14)*(1-pi143)**(1-x14);
>         prod144 = (pi144**x14)*(1-pi144)**(1-x14);
>           prod145 = (pi145**x14)*(1-pi145)**(1-x14);
>             prod146 = (pi146**x14)*(1-pi146)**(1-x14);
>   prod151 = (pi151**x15)*(1-pi151)**(1-x15);
>     prod152 = (pi152**x15)*(1-pi152)**(1-x15);
>       prod153 = (pi153**x15)*(1-pi153)**(1-x15);
>         prod154 = (pi154**x15)*(1-pi154)**(1-x15);
>           prod155 = (pi155**x15)*(1-pi155)**(1-x15);
>             prod156 = (pi156**x15)*(1-pi156)**(1-x15);
>   prod161 = (pi161**x16)*(1-pi161)**(1-x16);
>     prod162 = (pi162**x16)*(1-pi162)**(1-x16);
>       prod163 = (pi163**x16)*(1-pi163)**(1-x16);
>         prod164 = (pi164**x16)*(1-pi164)**(1-x16);
>           prod165 = (pi165**x16)*(1-pi165)**(1-x16);
>             prod166 = (pi166**x16)*(1-pi166)**(1-x16);
>   prod171 = (pi171**x17)*(1-pi171)**(1-x17);
>     prod172 = (pi172**x17)*(1-pi172)**(1-x17);
>       prod173 = (pi173**x17)*(1-pi173)**(1-x17);
>         prod174 = (pi174**x17)*(1-pi174)**(1-x17);
>           prod175 = (pi175**x17)*(1-pi175)**(1-x17);
>             prod176 = (pi176**x17)*(1-pi176)**(1-x17);
>   prod181 = (pi181**x18)*(1-pi181)**(1-x18);
>     prod182 = (pi182**x18)*(1-pi182)**(1-x18);
>       prod183 = (pi183**x18)*(1-pi183)**(1-x18);
>         prod184 = (pi184**x18)*(1-pi184)**(1-x18);
>           prod185 = (pi185**x18)*(1-pi185)**(1-x18);
>             prod186 = (pi186**x18)*(1-pi186)**(1-x18);
>   prod191 = (pi191**x19)*(1-pi191)**(1-x19);
>     prod192 = (pi192**x19)*(1-pi192)**(1-x19);
>       prod193 = (pi193**x19)*(1-pi193)**(1-x19);
>         prod194 = (pi194**x19)*(1-pi194)**(1-x19);
>           prod195 = (pi195**x19)*(1-pi195)**(1-x19);
>             prod196 = (pi196**x19)*(1-pi196)**(1-x19);
>
>  /* model probability of each latent class.  */
>  /* Note that we add random effect u1 to alpha1.  U1 is */
>  /* person random effect on probability of latent class */
>  /* 1.  If there are more latent classes, then would    */
>  /* need terms u2, u3, etc.                             */
>
> *************Not Clear On How to Contstruct Code Below***************
>
>  eta1=exp(alpha1 + u1)/(1+exp(alpha1 + u1));
>  eta2=1/(1+exp(alpha2 + u2));
>  eta3=exp(alpha3+ u3)/(1+exp(alpha3 + u3));
>  eta4=1/(1+exp(alpha4 + u4));
>  eta5=exp(alpha5 + u5)/(1+exp(alpha5 + u5));
>  eta6=1/(1+exp(alpha5 + u5));
>
>  /* Construct likelihood and log likelihood    */
>  l_latclass=eta1*prod11*prod21*prod31*prod41*
>                  prod51*prod61*prod71*prod81*
>                  prod91*prod101*prod111*prod121*
>                  prod131*prod141*prod151*prod161*
>                  prod171*prod181*prod191
>             +
>             eta2*prod12*prod22*prod32*prod42*
>                  prod52*prod62*prod72*prod82*
>                  prod92*prod102*prod112*prod122*
>                  prod132*prod142*prod152*prod162*
>                  prod172*prod182*prod192
>             +
>             eta3*prod13*prod23*prod33*prod43*
>                  prod53*prod63*prod73*prod83*
>                  prod93*prod103*prod113*prod123*
>                  prod133*prod143*prod153*prod163*
>                  prod173*prod183*prod193
>             +
>             eta4*prod14*prod24*prod34*prod44*
>                  prod54*prod64*prod74*prod84*
>                  prod94*prod104*prod114*prod124*
>                  prod134*prod144*prod154*prod164*
>                  prod174*prod184*prod194
>             +
>             eta5*prod15*prod25*prod35*prod45*
>                  prod55*prod65*prod75*prod85*
>                  prod95*prod105*prod115*prod125*
>                  prod135*prod145*prod155*prod165*
>                  prod175*prod185*prod195
>             +
>             eta6*prod16*prod26*prod36*prod46*
>                  prod56*prod66*prod76*prod86*
>                  prod96*prod106*prod116*prod126*
>                  prod136*prod146*prod156*prod166*
>                  prod176*prod186*prod196;
>
>  ll_latclass = log(l_latclass);
>
>  /* Maximize the latent class log likelihood */
>  model ll_latclass ˜ general(ll_latclass);
>
>  /* Model the variance of the latent class probability */
>  random u1 u2 u3 u4 u5 ~ normal([0], [exp(2*log_Valpha1)],
>                                 [0], [exp(2*log_Valpha2)],
>                                 [0], [exp(2*log_Valpha3)],
>                                 [0], [exp(2*log_Valpha4)],
>                                 [0], [exp(2*log_Valpha5)] )
> subject=person;
> run;
>
> /------------------------------END SAS
> CODE--------------------------------------/
>
> Thanks!
>
> Ryan

Small correction. All response variables are dichotomous. Sorry for
the confusion. Again, any feedback would be great. I will post back if
I work out the areas of confusion for me.
From: Dale McLerran on
Ryan,

The likelihood model for the ordinal and continuous variables
must be constructed differently from the likelihood model for
binary manifest variables. How many ordinal variables do you
have? How many levels are there to these ordinal variables?

What do you assume is the distribution of the continuous
variables? Gaussian?

Is there a sufficiently large number of binary variables that
you could perform an LCA just with the binary variables? I
would feel much better if an analysis could be performed
using code that is known to be valid (thanks Oliver!) and
comparing that to results with extensions that include a
mix of binary, ordinal, and continuous manifest variables.

I'll offer a couple of comments though that might help with
coding for the binary measures. In borrowing code from Guo
et al, I did not separate the manifest variable indicator
from the latent class indicator when constructing the
parameters bpi{i}{j} (where {i} is a digit indicating a
manifest variable and {j} is a digit indicating a latent
class). When the maximum value for {i} (and {j}) is 9,
then writing the variable as bpi{i}{j} is safe. However,
when the maximum value of {i} exceeds 9, this code may not
be safe. In particular, if {j} also exceeded 9, then I
can imagine conflicts.

For instance, suppose that you expected 11 latent classes.
There must be at least 11 manifest variables to support
11 latent classes. Now, we could have bpi{11}{1} and also
bpi{1}{11}. Both produce bpi111.

This problem can be got around easily by placing a
separator between indices. We could use an underscore
to separate indices and write bpi{i}_{j}. Now, we would
have bpi{11}_{1}-> bpi11_1 and bpi{1}_{11}->bpi1_11. I
would suggest that you rewrite your code with the
underscore just to be safe.

Also, with this many manifest variables and latent classes,
I would write a macro to loop over the indices to make
sure that everything gets written consistently. That
shouldn't be very difficult to do. But if you are not
comfortable writing macro code, you might want to refer
to the extensive discussion of macro coding for statisticians
that was initiated by Peter Flom a few weeks back. See
http://listserv.uga.edu/cgi-bin/wa?A1=ind0911c&L=sas-l#41

(Note: the above comment about making sure that indices
are written consistently might be read as "Oy vey! That
is a lot of code to look at to ensure that it is correct.
I will certainly not be able to look at it all line by
line, parameter by parameter.")

Dale

---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra(a)NO_SPAMfhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------


--- On Thu, 12/3/09, Ryan <ryan.andrew.black(a)GMAIL.COM> wrote:

> From: Ryan <ryan.andrew.black(a)GMAIL.COM>
> Subject: Latent Class Analysis via NLMIXED - UPDATE
> To: SAS-L(a)LISTSERV.UGA.EDU
> Date: Thursday, December 3, 2009, 7:03 AM
> Hi Dale and others,
>
> Thanks so much for the feedback yesterday. I was hoping
> Dale and/or
> others would consider taking a look at the code I
> constructed based on
> Dale's example. I'm certain there are errors in my code as
> I did not
> grasp fully the explanations of the code. Hopefully, I'm
> not
> completely off the mark.
>
> Note that my dataset consists of 19 response variables,
> some of which
> are dichotomous (0/1) and while others are
> continuous/ordinal. There
> are 6 hypothesized latent classes and a random intercept.
>
> Code starts now...
>
> /
> *--------------------------------------------------------------------------------------------
> */
> /*-----LCA with 6 classes, 19 response variables, &
> Person REs---*/
> /
> *--------------------------------------------------------------------------------------------
> */
> proc nlmixed data=mydata tech=quanew lis=2 method=gauss
> � � � � � � maxiter=1000
> gconv=.00000000001 fconv=.00000000001;
> parms
>
> � � � /* Parameter which expresses probability
> of */
> � � � /* latent class contrasts� �
> � � � � � �
> � � � */
> � � � alpha1 = 0.17 alpha2 = 0.17 alpha3 =
> 0.17
> � � � alpha4 = 0.17 alpha5 = 0.17
>
> � � � /* If there are more latent classes, then
> need */
> � � � /* alpha1, alpha2, etc.� Number of
> alpha parms */
> � � � /* is one less than number of latent
> classes.� */
> � � � log_Valpha1 -4 log_Valpha2 -4 log_Valpha3
> -4
> � � � log_Valpha4 -4 log_Valpha5 -4
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 1 */
> � � � bpi11 = 1 bpi21 = 1 bpi31 = 1 bpi41 = 1
> bpi51 = 1 bpi61 = 1
> � � � bpi71 = 1 bpi81 = 1 bpi91 = 1 bpi101 = 1
> bpi111 = 1
> � � � bpi121 = 1 bpi131 = 1 bpi141 = 1 bpi151 =
> 1 bpi161 = 1
> � � � bpi171 = 1 bpi181 = 1 bpi191 = 0
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 2 */
> � � � bpi12 = .5 bpi22 = .5 bpi32 = .5 bpi42 =
> .5 bpi51 = .5 bpi62 = .5
> � � � bpi72 = .5 bpi82 = .5 bpi92 = .5 bpi102 =
> .5 bpi112 = .5
> � � � bpi122 = .5 bpi132 = .5 bpi142 = .5
> bpi152 = .5 bpi162 = -.5
> � � � bpi172 = .5 bpi182 = .5 bpi192 = .5
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 3 */
> � � � bpi13 = 1 bpi23 = 1 bpi33 = 1 bpi43 = 1
> bpi53 = 1 bpi63 = 1
> � � � bpi73 = 1 bpi83 = 1 bpi93 = 1 bpi103 = 1
> bpi113 = 1
> � � � bpi123 = 1 bpi133 = 1 bpi143 = 1 bpi153 =
> 1 bpi163 = 1
> � � � bpi173 = 1 bpi183 = 1 bpi193 = 0
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 4 */
> � � � bpi14 = .5 bpi24 = .5 bpi34 = .5 bpi44 =
> .5 bpi54 = .5 bpi64 = .5
> � � � bpi74 = .5 bpi84 = .5 bpi94 = .5 bpi104 =
> .5 bpi114 = .5
> � � � bpi124 = .5 bpi134 = .5 bpi144 = .5
> bpi154 = .5 bpi164 = -.5
> � � � bpi174 = .5 bpi184 = .5 bpi194 = .5
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 5 */
> � � � bpi15 = 1 bpi25 = 1 bpi35 = 1 bpi45 = 1
> bpi55 = 1 bpi65 = 1
> � � � bpi75 = 1 bpi85 = 1 bpi95 = 1 bpi105 = 1
> bpi115 = 1
> � � � bpi125 = 1 bpi135 = 1 bpi145 = 1 bpi155 =
> 1 bpi165 = 1
> � � � bpi175 = 1 bpi185 = 1 bpi195 = 0
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 6 */
> � � � bpi16 = .5 bpi26 = .5 bpi36 = .5 bpi46 =
> .5 bpi51 = .5 bpi66 = .5
> � � � bpi76 = .5 bpi86 = .5 bpi96 = .5 bpi106 =
> .5 bpi116 = .5
> � � � bpi126 = .5 bpi136 = .5 bpi146 = .5
> bpi156 = .5 bpi166 = -.5
> � � � bpi176 = .5 bpi186 = .5 bpi196 = .5
> ;
>
> bounds -6 <= bpi11 - bpi191 <= 6;
>
> **** latent class part;
>
> pi11 = 1/(1+exp(-bpi11)); pi12 = 1/(1+exp(-bpi12));
> pi21 = 1/(1+exp(-bpi21)); pi22 = 1/(1+exp(-bpi22));
> pi31 = 1/(1+exp(-bpi31)); pi32 = 1/(1+exp(-bpi32));
> pi41 = 1/(1+exp(-bpi41)); pi42 = 1/(1+exp(-bpi42));
> pi51 = 1/(1+exp(-bpi51)); pi52 = 1/(1+exp(-bpi52));
> pi61 = 1/(1+exp(-bpi61)); pi62 = 1/(1+exp(-bpi62));
> pi71 = 1/(1+exp(-bpi71)); pi72 = 1/(1+exp(-bpi72));
> pi81 = 1/(1+exp(-bpi81)); pi82 = 1/(1+exp(-bpi82));
> pi91 = 1/(1+exp(-bpi91)); pi92 = 1/(1+exp(-bpi92));
> pi101 = 1/(1+exp(-bpi101)); pi102 = 1/(1+exp(-bpi102));
> pi111 = 1/(1+exp(-bpi111)); pi112 = 1/(1+exp(-bpi112));
> pi121 = 1/(1+exp(-bpi121)); pi122 = 1/(1+exp(-bpi122));
> pi131 = 1/(1+exp(-bpi131)); pi132 = 1/(1+exp(-bpi132));
> pi141 = 1/(1+exp(-bpi141)); pi142 = 1/(1+exp(-bpi142));
> pi151 = 1/(1+exp(-bpi151)); pi152 = 1/(1+exp(-bpi152));
> pi161 = 1/(1+exp(-bpi161)); pi162 = 1/(1+exp(-bpi162));
> pi171 = 1/(1+exp(-bpi171)); pi172 = 1/(1+exp(-bpi172));
> pi181 = 1/(1+exp(-bpi181)); pi182 = 1/(1+exp(-bpi182));
> pi191 = 1/(1+exp(-bpi191)); pi192 = 1/(1+exp(-bpi192));
>
> pi13 = 1/(1+exp(-bpi13)); pi14 = 1/(1+exp(-bpi12));
> pi23 = 1/(1+exp(-bpi23)); pi24 = 1/(1+exp(-bpi22));
> pi33 = 1/(1+exp(-bpi33)); pi34 = 1/(1+exp(-bpi34));
> pi43 = 1/(1+exp(-bpi43)); pi44 = 1/(1+exp(-bpi44));
> pi53 = 1/(1+exp(-bpi53)); pi54 = 1/(1+exp(-bpi54));
> pi63 = 1/(1+exp(-bpi63)); pi64 = 1/(1+exp(-bpi64));
> pi73 = 1/(1+exp(-bpi73)); pi74 = 1/(1+exp(-bpi74));
> pi83 = 1/(1+exp(-bpi83)); pi84 = 1/(1+exp(-bpi84));
> pi93 = 1/(1+exp(-bpi93)); pi94 = 1/(1+exp(-bpi94));
> pi103 = 1/(1+exp(-bpi103)); pi104 = 1/(1+exp(-bpi104));
> pi113 = 1/(1+exp(-bpi113)); pi114 = 1/(1+exp(-bpi114));
> pi123 = 1/(1+exp(-bpi123)); pi124 = 1/(1+exp(-bpi124));
> pi133 = 1/(1+exp(-bpi133)); pi134 = 1/(1+exp(-bpi134));
> pi143 = 1/(1+exp(-bpi143)); pi144 = 1/(1+exp(-bpi144));
> pi153 = 1/(1+exp(-bpi153)); pi154 = 1/(1+exp(-bpi154));
> pi163 = 1/(1+exp(-bpi163)); pi164 = 1/(1+exp(-bpi164));
> pi173 = 1/(1+exp(-bpi173)); pi174 = 1/(1+exp(-bpi174));
> pi183 = 1/(1+exp(-bpi183)); pi184 = 1/(1+exp(-bpi184));
> pi193 = 1/(1+exp(-bpi193)); pi194 = 1/(1+exp(-bpi194));
>
> pi15 = 1/(1+exp(-bpi15)); pi16 = 1/(1+exp(-bpi16));
> pi25 = 1/(1+exp(-bpi25)); pi26 = 1/(1+exp(-bpi26));
> pi35 = 1/(1+exp(-bpi35)); pi36 = 1/(1+exp(-bpi36));
> pi45 = 1/(1+exp(-bpi45)); pi46 = 1/(1+exp(-bpi46));
> pi55 = 1/(1+exp(-bpi55)); pi56 = 1/(1+exp(-bpi56));
> pi65 = 1/(1+exp(-bpi65)); pi66 = 1/(1+exp(-bpi66));
> pi75 = 1/(1+exp(-bpi75)); pi76 = 1/(1+exp(-bpi76));
> pi85 = 1/(1+exp(-bpi85)); pi86 = 1/(1+exp(-bpi86));
> pi95 = 1/(1+exp(-bpi95)); pi96 = 1/(1+exp(-bpi96));
> pi105 = 1/(1+exp(-bpi105)); pi106 = 1/(1+exp(-bpi106));
> pi115 = 1/(1+exp(-bpi115)); pi116 = 1/(1+exp(-bpi116));
> pi125 = 1/(1+exp(-bpi125)); pi126 = 1/(1+exp(-bpi126));
> pi135 = 1/(1+exp(-bpi135)); pi136 = 1/(1+exp(-bpi136));
> pi145 = 1/(1+exp(-bpi145)); pi146 = 1/(1+exp(-bpi146));
> pi155 = 1/(1+exp(-bpi155)); pi156 = 1/(1+exp(-bpi156));
> pi165 = 1/(1+exp(-bpi165)); pi166 = 1/(1+exp(-bpi166));
> pi175 = 1/(1+exp(-bpi175)); pi176 = 1/(1+exp(-bpi176));
> pi185 = 1/(1+exp(-bpi185)); pi186 = 1/(1+exp(-bpi186));
> pi195 = 1/(1+exp(-bpi195)); pi196 = 1/(1+exp(-bpi196));
>
> prod11 = (pi11**x1)*(1-pi11)**(1-x1);
> � � � prod12 = (pi12**x1)*(1-pi12)**(1-x1);
> � � � � prod13 =
> (pi13**x1)*(1-pi13)**(1-x1);
> � � � � � prod14 =
> (pi14**x1)*(1-pi14)**(1-x1);
> � � � � � � prod15 =
> (pi15**x1)*(1-pi15)**(1-x1);
> � � � � � � prod16 =
> (pi16**x1)*(1-pi16)**(1-x1);
> prod21 = (pi21**x2)*(1-pi21)**(1-x2);
> � � � prod22 = (pi22**x2)*(1-pi22)**(1-x2);
> � � � � prod23 =
> (pi23**x2)*(1-pi23)**(1-x2);
> � � � � � prod24 =
> (pi24**x2)*(1-pi24)**(1-x2);
> � � � � � � prod25 =
> (pi25**x2)*(1-pi25)**(1-x2);
> � � � � � � prod26 =
> (pi26**x2)*(1-pi26)**(1-x2);
> � prod31 = (pi31**x3)*(1-pi31)**(1-x3);
> � � prod32 = (pi32**x3)*(1-pi32)**(1-x3);
> � � � prod33 = (pi33**x3)*(1-pi33)**(1-x3);
> � � � � prod34 =
> (pi34**x3)*(1-pi34)**(1-x3);
> � � � � � prod35 =
> (pi35**x3)*(1-pi35)**(1-x3);
> � � � � � � prod36 =
> (pi36**x3)*(1-pi36)**(1-x3);
> � prod41 = (pi41**x1)*(1-pi41)**(1-x4);
> � � prod42 = (pi42**x4)*(1-pi42)**(1-x4);
> � � � prod43 = (pi43**x4)*(1-pi43)**(1-x4);
> � � � � prod44 =
> (pi44**x4)*(1-pi44)**(1-x4);
> � � � � � prod45 =
> (pi45**x4)*(1-pi45)**(1-x4);
> � � � � � � prod46 =
> (pi46**x4)*(1-pi46)**(1-x4);
> � prod51 = (pi51**x5)*(1-pi51)**(1-x5);
> � � prod52 = (pi52**x5)*(1-pi52)**(1-x5);
> � � � prod53 = (pi53**x5)*(1-pi53)**(1-x5);
> � � � � prod54 =
> (pi54**x5)*(1-pi54)**(1-x5);
> � � � � � prod55 =
> (pi55**x5)*(1-pi55)**(1-x5);
> � � � � � � prod56 =
> (pi56**x5)*(1-pi56)**(1-x5);
> � prod61 = (pi61**x6)*(1-pi61)**(1-x6);
> � � prod62 = (pi62**x6)*(1-pi62)**(1-x6);
> � � � prod63 = (pi63**x6)*(1-pi63)**(1-x6);
> � � � � prod64 =
> (pi64**x6)*(1-pi64)**(1-x6);
> � � � � � � � prod65 =
> (pi65**x6)*(1-pi65)**(1-x6);
> � � � � � � � � prod66
> = (pi66**x6)*(1-pi66)**(1-x6);
> � prod71 = (pi71**x7)*(1-pi71)**(1-x7);
> � � prod72 = (pi72**x7)*(1-pi72)**(1-x7);
> � � � prod73 = (pi73**x7)*(1-pi73)**(1-x7);
> � � � � prod74 =
> (pi74**x7)*(1-pi74)**(1-x7);
> � � � � � prod75 =
> (pi75**x7)*(1-pi75)**(1-x7);
> � � � � � � � � prod76
> = (pi76**x7)*(1-pi76)**(1-x7);
> � prod81 = (pi81**x8)*(1-pi81)**(1-x8);
> � � prod82 = (pi82**x8)*(1-pi82)**(1-x8);
> � � � prod83 = (pi83**x8)*(1-pi83)**(1-x8);
> � � � � prod84 =
> (pi84**x8)*(1-pi84)**(1-x8);
> � � � � � prod85 =
> (pi85**x8)*(1-pi85)**(1-x8);
> � � � � � � � prod86 =
> (pi86**x8)*(1-pi86)**(1-x8);
> � prod91 = (pi91**x9)*(1-pi91)**(1-x9);
> � � prod92 = (pi92**x9)*(1-pi92)**(1-x9);
> � � � prod93 = (pi93**x9)*(1-pi93)**(1-x9);
> � � � � prod94 =
> (pi94**x9)*(1-pi94)**(1-x9);
> � � � � � prod95 =
> (pi95**x9)*(1-pi95)**(1-x9);
> � � � � � � � prod96 =
> (pi96**x9)*(1-pi96)**(1-x9);
> � prod101 = (pi101**x10)*(1-pi101)**(1-x10);
> � � prod102 = (pi102**x10)*(1-pi102)**(1-x10);
> � � � prod103 =
> (pi103**x10)*(1-pi103)**(1-x10);
> � � � � prod104 =
> (pi104**x10)*(1-pi104)**(1-x10);
> � � � � � prod105 =
> (pi105**x10)*(1-pi105)**(1-x10);
> � � � � � � prod106 =
> (pi106**x10)*(1-pi106)**(1-x10);
> � prod111 = (pi111**x11)*(1-pi111)**(1-x11);
> � � prod112 = (pi112**x11)*(1-pi112)**(1-x11);
> � � � prod113 =
> (pi113**x11)*(1-pi113)**(1-x11);
> � � � � prod114 =
> (pi114**x11)*(1-pi114)**(1-x11);
> � � � � � prod115 =
> (pi115**x11)*(1-pi115)**(1-x11);
> � � � � � � prod116 =
> (pi116**x11)*(1-pi116)**(1-x11);
> � prod121 = (pi121**x12)*(1-pi121)**(1-x12);
> � � prod122 = (pi122**x12)*(1-pi122)**(1-x12);
> � � � prod123 =
> (pi123**x12)*(1-pi123)**(1-x12);
> � � � � prod124 =
> (pi124**x12)*(1-pi124)**(1-x12);
> � � � � � prod125 =
> (pi125**x12)*(1-pi125)**(1-x12);
> � � � � � � prod126 =
> (pi126**x12)*(1-pi126)**(1-x12);
> � prod131 = (pi131**x13)*(1-pi131)**(1-x13);
> � � prod132 = (pi132**x13)*(1-pi132)**(1-x13);
> � � � prod133 =
> (pi133**x13)*(1-pi133)**(1-x13);
> � � � � prod134 =
> (pi134**x13)*(1-pi134)**(1-x13);
> � � � � � prod135 =
> (pi135**x13)*(1-pi135)**(1-x13);
> � � � � � � prod136 =
> (pi136**x13)*(1-pi136)**(1-x13);
> � prod141 = (pi141**x14)*(1-pi141)**(1-x14);
> � � prod142 = (pi142**x14)*(1-pi142)**(1-x14);
> � � � prod143 =
> (pi143**x14)*(1-pi143)**(1-x14);
> � � � � prod144 =
> (pi144**x14)*(1-pi144)**(1-x14);
> � � � � � prod145 =
> (pi145**x14)*(1-pi145)**(1-x14);
> � � � � � � prod146 =
> (pi146**x14)*(1-pi146)**(1-x14);
> � prod151 = (pi151**x15)*(1-pi151)**(1-x15);
> � � prod152 = (pi152**x15)*(1-pi152)**(1-x15);
> � � � prod153 =
> (pi153**x15)*(1-pi153)**(1-x15);
> � � � � prod154 =
> (pi154**x15)*(1-pi154)**(1-x15);
> � � � � � prod155 =
> (pi155**x15)*(1-pi155)**(1-x15);
> � � � � � � prod156 =
> (pi156**x15)*(1-pi156)**(1-x15);
> � prod161 = (pi161**x16)*(1-pi161)**(1-x16);
> � � prod162 = (pi162**x16)*(1-pi162)**(1-x16);
> � � � prod163 =
> (pi163**x16)*(1-pi163)**(1-x16);
> � � � � prod164 =
> (pi164**x16)*(1-pi164)**(1-x16);
> � � � � � prod165 =
> (pi165**x16)*(1-pi165)**(1-x16);
> � � � � � � prod166 =
> (pi166**x16)*(1-pi166)**(1-x16);
> � prod171 = (pi171**x17)*(1-pi171)**(1-x17);
> � � prod172 = (pi172**x17)*(1-pi172)**(1-x17);
> � � � prod173 =
> (pi173**x17)*(1-pi173)**(1-x17);
> � � � � prod174 =
> (pi174**x17)*(1-pi174)**(1-x17);
> � � � � � prod175 =
> (pi175**x17)*(1-pi175)**(1-x17);
> � � � � � � prod176 =
> (pi176**x17)*(1-pi176)**(1-x17);
> � prod181 = (pi181**x18)*(1-pi181)**(1-x18);
> � � prod182 = (pi182**x18)*(1-pi182)**(1-x18);
> � � � prod183 =
> (pi183**x18)*(1-pi183)**(1-x18);
> � � � � prod184 =
> (pi184**x18)*(1-pi184)**(1-x18);
> � � � � � prod185 =
> (pi185**x18)*(1-pi185)**(1-x18);
> � � � � � � prod186 =
> (pi186**x18)*(1-pi186)**(1-x18);
> � prod191 = (pi191**x19)*(1-pi191)**(1-x19);
> � � prod192 = (pi192**x19)*(1-pi192)**(1-x19);
> � � � prod193 =
> (pi193**x19)*(1-pi193)**(1-x19);
> � � � � prod194 =
> (pi194**x19)*(1-pi194)**(1-x19);
> � � � � � prod195 =
> (pi195**x19)*(1-pi195)**(1-x19);
> � � � � � � prod196 =
> (pi196**x19)*(1-pi196)**(1-x19);
>
> /* model probability of each latent class.� */
> /* Note that we add random effect u1 to alpha1.� U1
> is */
> /* person random effect on probability of latent class */
> /* 1.� If there are more latent classes, then
> would� � */
> /* need terms u2, u3, etc.� � � �
> � � � � � � � �
> � � � � */
>
> *************Not Clear On How to Contstruct Code
> Below***************
>
> eta1=exp(alpha1 + u1)/(1+exp(alpha1 + u1));
> eta2=1/(1+exp(alpha2 + u2));
> eta3=exp(alpha3+ u3)/(1+exp(alpha3 + u3));
> eta4=1/(1+exp(alpha4 + u4));
> eta5=exp(alpha5 + u5)/(1+exp(alpha5 + u5));
> eta6=1/(1+exp(alpha5 + u5));
>
> /* Construct likelihood and log likelihood� �
> */
> l_latclass=eta1*prod11*prod21*prod31*prod41*
> � � � � � � �
> � � � prod51*prod61*prod71*prod81*
> � � � � � � �
> � � � prod91*prod101*prod111*prod121*
> � � � � � � �
> � � � prod131*prod141*prod151*prod161*
> � � � � � � �
> � � � prod171*prod181*prod191
> � � � � � � +
> � � � � � �
> eta2*prod12*prod22*prod32*prod42*
> � � � � � � �
> � � � prod52*prod62*prod72*prod82*
> � � � � � � �
> � � � prod92*prod102*prod112*prod122*
> � � � � � � �
> � � � prod132*prod142*prod152*prod162*
> � � � � � � �
> � � � prod172*prod182*prod192
> � � � � � � +
> � � � � � �
> eta3*prod13*prod23*prod33*prod43*
> � � � � � � �
> � � � prod53*prod63*prod73*prod83*
> � � � � � � �
> � � � prod93*prod103*prod113*prod123*
> � � � � � � �
> � � � prod133*prod143*prod153*prod163*
> � � � � � � �
> � � � prod173*prod183*prod193
> � � � � � � +
> � � � � � �
> eta4*prod14*prod24*prod34*prod44*
> � � � � � � �
> � � � prod54*prod64*prod74*prod84*
> � � � � � � �
> � � � prod94*prod104*prod114*prod124*
> � � � � � � �
> � � � prod134*prod144*prod154*prod164*
> � � � � � � �
> � � � prod174*prod184*prod194
> � � � � � � +
> � � � � � �
> eta5*prod15*prod25*prod35*prod45*
> � � � � � � �
> � � � prod55*prod65*prod75*prod85*
> � � � � � � �
> � � � prod95*prod105*prod115*prod125*
> � � � � � � �
> � � � prod135*prod145*prod155*prod165*
> � � � � � � �
> � � � prod175*prod185*prod195
> � � � � � � +
> � � � � � �
> eta6*prod16*prod26*prod36*prod46*
> � � � � � � �
> � � � prod56*prod66*prod76*prod86*
> � � � � � � �
> � � � prod96*prod106*prod116*prod126*
> � � � � � � �
> � � � prod136*prod146*prod156*prod166*
> � � � � � � �
> � � � prod176*prod186*prod196;
>
> ll_latclass = log(l_latclass);
>
> /* Maximize the latent class log likelihood */
> model ll_latclass ˜ general(ll_latclass);
>
> /* Model the variance of the latent class probability */
> random u1 u2 u3 u4 u5 ~ normal([0], [exp(2*log_Valpha1)],
> � � � � � � � �
> � � � � � � � � [0],
> [exp(2*log_Valpha2)],
> � � � � � � � �
> � � � � � � � � [0],
> [exp(2*log_Valpha3)],
> � � � � � � � �
> � � � � � � � � [0],
> [exp(2*log_Valpha4)],
> � � � � � � � �
> � � � � � � � � [0],
> [exp(2*log_Valpha5)] )
> subject=person;
> run;
>
> /------------------------------END SAS
> CODE--------------------------------------/
>
> Thanks!
>
> Ryan
>
From: Dale McLerran on
Ryan,

One more follow-up. I thought that I should take a look at
how you handled the random effects. That led me to look at
how you constructed the probabilities of the six latent
classes. Your code there was incorrect. You wrote:


*************Not Clear On How to Contstruct Code Below***************

eta1=exp(alpha1 + u1)/(1+exp(alpha1 + u1));
eta2=1/(1+exp(alpha2 + u2));
eta3=exp(alpha3+ u3)/(1+exp(alpha3 + u3));
eta4=1/(1+exp(alpha4 + u4));
eta5=exp(alpha5 + u5)/(1+exp(alpha5 + u5));
eta6=1/(1+exp(alpha5 + u5));


The latent class probability model should be constructed as

f1 = exp(alpha1 + u1);
f2 = exp(alpha2 + u2);
f3 = exp(alpha3 + u3);
f4 = exp(alpha4 + u4);
f5 = exp(alpha5 + u5);
eta1 = f1 / (1 + f1 + f2 + f3 + f4 + f5);
eta2 = f2 / (1 + f1 + f2 + f3 + f4 + f5);
eta3 = f3 / (1 + f1 + f2 + f3 + f4 + f5);
eta4 = f4 / (1 + f1 + f2 + f3 + f4 + f5);
eta5 = f5 / (1 + f1 + f2 + f3 + f4 + f5);
eta6 = 1 / (1 + f1 + f2 + f3 + f4 + f5);


You will note that with the construction which I show above,
the probabilities sum to 1.0. That is not be the case for
the code which you had.

Dale

---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra(a)NO_SPAMfhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------


--- On Thu, 12/3/09, Ryan <ryan.andrew.black(a)GMAIL.COM> wrote:

> From: Ryan <ryan.andrew.black(a)GMAIL.COM>
> Subject: Latent Class Analysis via NLMIXED - UPDATE
> To: SAS-L(a)LISTSERV.UGA.EDU
> Date: Thursday, December 3, 2009, 7:03 AM
> Hi Dale and others,
>
> Thanks so much for the feedback yesterday. I was hoping
> Dale and/or
> others would consider taking a look at the code I
> constructed based on
> Dale's example. I'm certain there are errors in my code as
> I did not
> grasp fully the explanations of the code. Hopefully, I'm
> not
> completely off the mark.
>
> Note that my dataset consists of 19 response variables,
> some of which
> are dichotomous (0/1) and while others are
> continuous/ordinal. There
> are 6 hypothesized latent classes and a random intercept.
>
> Code starts now...
>
> /
> *--------------------------------------------------------------------------------------------
> */
> /*-----LCA with 6 classes, 19 response variables, &
> Person REs---*/
> /
> *--------------------------------------------------------------------------------------------
> */
> proc nlmixed data=mydata tech=quanew lis=2 method=gauss
> � � � � � � maxiter=1000
> gconv=.00000000001 fconv=.00000000001;
> parms
>
> � � � /* Parameter which expresses probability
> of */
> � � � /* latent class contrasts� �
> � � � � � �
> � � � */
> � � � alpha1 = 0.17 alpha2 = 0.17 alpha3 =
> 0.17
> � � � alpha4 = 0.17 alpha5 = 0.17
>
> � � � /* If there are more latent classes, then
> need */
> � � � /* alpha1, alpha2, etc.� Number of
> alpha parms */
> � � � /* is one less than number of latent
> classes.� */
> � � � log_Valpha1 -4 log_Valpha2 -4 log_Valpha3
> -4
> � � � log_Valpha4 -4 log_Valpha5 -4
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 1 */
> � � � bpi11 = 1 bpi21 = 1 bpi31 = 1 bpi41 = 1
> bpi51 = 1 bpi61 = 1
> � � � bpi71 = 1 bpi81 = 1 bpi91 = 1 bpi101 = 1
> bpi111 = 1
> � � � bpi121 = 1 bpi131 = 1 bpi141 = 1 bpi151 =
> 1 bpi161 = 1
> � � � bpi171 = 1 bpi181 = 1 bpi191 = 0
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 2 */
> � � � bpi12 = .5 bpi22 = .5 bpi32 = .5 bpi42 =
> .5 bpi51 = .5 bpi62 = .5
> � � � bpi72 = .5 bpi82 = .5 bpi92 = .5 bpi102 =
> .5 bpi112 = .5
> � � � bpi122 = .5 bpi132 = .5 bpi142 = .5
> bpi152 = .5 bpi162 = -.5
> � � � bpi172 = .5 bpi182 = .5 bpi192 = .5
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 3 */
> � � � bpi13 = 1 bpi23 = 1 bpi33 = 1 bpi43 = 1
> bpi53 = 1 bpi63 = 1
> � � � bpi73 = 1 bpi83 = 1 bpi93 = 1 bpi103 = 1
> bpi113 = 1
> � � � bpi123 = 1 bpi133 = 1 bpi143 = 1 bpi153 =
> 1 bpi163 = 1
> � � � bpi173 = 1 bpi183 = 1 bpi193 = 0
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 4 */
> � � � bpi14 = .5 bpi24 = .5 bpi34 = .5 bpi44 =
> .5 bpi54 = .5 bpi64 = .5
> � � � bpi74 = .5 bpi84 = .5 bpi94 = .5 bpi104 =
> .5 bpi114 = .5
> � � � bpi124 = .5 bpi134 = .5 bpi144 = .5
> bpi154 = .5 bpi164 = -.5
> � � � bpi174 = .5 bpi184 = .5 bpi194 = .5
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 5 */
> � � � bpi15 = 1 bpi25 = 1 bpi35 = 1 bpi45 = 1
> bpi55 = 1 bpi65 = 1
> � � � bpi75 = 1 bpi85 = 1 bpi95 = 1 bpi105 = 1
> bpi115 = 1
> � � � bpi125 = 1 bpi135 = 1 bpi145 = 1 bpi155 =
> 1 bpi165 = 1
> � � � bpi175 = 1 bpi185 = 1 bpi195 = 0
>
> � � � /* Parameters which express probability
> of Xi=1 | latent class 6 */
> � � � bpi16 = .5 bpi26 = .5 bpi36 = .5 bpi46 =
> .5 bpi51 = .5 bpi66 = .5
> � � � bpi76 = .5 bpi86 = .5 bpi96 = .5 bpi106 =
> .5 bpi116 = .5
> � � � bpi126 = .5 bpi136 = .5 bpi146 = .5
> bpi156 = .5 bpi166 = -.5
> � � � bpi176 = .5 bpi186 = .5 bpi196 = .5
> ;
>
> bounds -6 <= bpi11 - bpi191 <= 6;
>
> **** latent class part;
>
> pi11 = 1/(1+exp(-bpi11)); pi12 = 1/(1+exp(-bpi12));
> pi21 = 1/(1+exp(-bpi21)); pi22 = 1/(1+exp(-bpi22));
> pi31 = 1/(1+exp(-bpi31)); pi32 = 1/(1+exp(-bpi32));
> pi41 = 1/(1+exp(-bpi41)); pi42 = 1/(1+exp(-bpi42));
> pi51 = 1/(1+exp(-bpi51)); pi52 = 1/(1+exp(-bpi52));
> pi61 = 1/(1+exp(-bpi61)); pi62 = 1/(1+exp(-bpi62));
> pi71 = 1/(1+exp(-bpi71)); pi72 = 1/(1+exp(-bpi72));
> pi81 = 1/(1+exp(-bpi81)); pi82 = 1/(1+exp(-bpi82));
> pi91 = 1/(1+exp(-bpi91)); pi92 = 1/(1+exp(-bpi92));
> pi101 = 1/(1+exp(-bpi101)); pi102 = 1/(1+exp(-bpi102));
> pi111 = 1/(1+exp(-bpi111)); pi112 = 1/(1+exp(-bpi112));
> pi121 = 1/(1+exp(-bpi121)); pi122 = 1/(1+exp(-bpi122));
> pi131 = 1/(1+exp(-bpi131)); pi132 = 1/(1+exp(-bpi132));
> pi141 = 1/(1+exp(-bpi141)); pi142 = 1/(1+exp(-bpi142));
> pi151 = 1/(1+exp(-bpi151)); pi152 = 1/(1+exp(-bpi152));
> pi161 = 1/(1+exp(-bpi161)); pi162 = 1/(1+exp(-bpi162));
> pi171 = 1/(1+exp(-bpi171)); pi172 = 1/(1+exp(-bpi172));
> pi181 = 1/(1+exp(-bpi181)); pi182 = 1/(1+exp(-bpi182));
> pi191 = 1/(1+exp(-bpi191)); pi192 = 1/(1+exp(-bpi192));
>
> pi13 = 1/(1+exp(-bpi13)); pi14 = 1/(1+exp(-bpi12));
> pi23 = 1/(1+exp(-bpi23)); pi24 = 1/(1+exp(-bpi22));
> pi33 = 1/(1+exp(-bpi33)); pi34 = 1/(1+exp(-bpi34));
> pi43 = 1/(1+exp(-bpi43)); pi44 = 1/(1+exp(-bpi44));
> pi53 = 1/(1+exp(-bpi53)); pi54 = 1/(1+exp(-bpi54));
> pi63 = 1/(1+exp(-bpi63)); pi64 = 1/(1+exp(-bpi64));
> pi73 = 1/(1+exp(-bpi73)); pi74 = 1/(1+exp(-bpi74));
> pi83 = 1/(1+exp(-bpi83)); pi84 = 1/(1+exp(-bpi84));
> pi93 = 1/(1+exp(-bpi93)); pi94 = 1/(1+exp(-bpi94));
> pi103 = 1/(1+exp(-bpi103)); pi104 = 1/(1+exp(-bpi104));
> pi113 = 1/(1+exp(-bpi113)); pi114 = 1/(1+exp(-bpi114));
> pi123 = 1/(1+exp(-bpi123)); pi124 = 1/(1+exp(-bpi124));
> pi133 = 1/(1+exp(-bpi133)); pi134 = 1/(1+exp(-bpi134));
> pi143 = 1/(1+exp(-bpi143)); pi144 = 1/(1+exp(-bpi144));
> pi153 = 1/(1+exp(-bpi153)); pi154 = 1/(1+exp(-bpi154));
> pi163 = 1/(1+exp(-bpi163)); pi164 = 1/(1+exp(-bpi164));
> pi173 = 1/(1+exp(-bpi173)); pi174 = 1/(1+exp(-bpi174));
> pi183 = 1/(1+exp(-bpi183)); pi184 = 1/(1+exp(-bpi184));
> pi193 = 1/(1+exp(-bpi193)); pi194 = 1/(1+exp(-bpi194));
>
> pi15 = 1/(1+exp(-bpi15)); pi16 = 1/(1+exp(-bpi16));
> pi25 = 1/(1+exp(-bpi25)); pi26 = 1/(1+exp(-bpi26));
> pi35 = 1/(1+exp(-bpi35)); pi36 = 1/(1+exp(-bpi36));
> pi45 = 1/(1+exp(-bpi45)); pi46 = 1/(1+exp(-bpi46));
> pi55 = 1/(1+exp(-bpi55)); pi56 = 1/(1+exp(-bpi56));
> pi65 = 1/(1+exp(-bpi65)); pi66 = 1/(1+exp(-bpi66));
> pi75 = 1/(1+exp(-bpi75)); pi76 = 1/(1+exp(-bpi76));
> pi85 = 1/(1+exp(-bpi85)); pi86 = 1/(1+exp(-bpi86));
> pi95 = 1/(1+exp(-bpi95)); pi96 = 1/(1+exp(-bpi96));
> pi105 = 1/(1+exp(-bpi105)); pi106 = 1/(1+exp(-bpi106));
> pi115 = 1/(1+exp(-bpi115)); pi116 = 1/(1+exp(-bpi116));
> pi125 = 1/(1+exp(-bpi125)); pi126 = 1/(1+exp(-bpi126));
> pi135 = 1/(1+exp(-bpi135)); pi136 = 1/(1+exp(-bpi136));
> pi145 = 1/(1+exp(-bpi145)); pi146 = 1/(1+exp(-bpi146));
> pi155 = 1/(1+exp(-bpi155)); pi156 = 1/(1+exp(-bpi156));
> pi165 = 1/(1+exp(-bpi165)); pi166 = 1/(1+exp(-bpi166));
> pi175 = 1/(1+exp(-bpi175)); pi176 = 1/(1+exp(-bpi176));
> pi185 = 1/(1+exp(-bpi185)); pi186 = 1/(1+exp(-bpi186));
> pi195 = 1/(1+exp(-bpi195)); pi196 = 1/(1+exp(-bpi196));
>
> prod11 = (pi11**x1)*(1-pi11)**(1-x1);
> � � � prod12 = (pi12**x1)*(1-pi12)**(1-x1);
> � � � � prod13 =
> (pi13**x1)*(1-pi13)**(1-x1);
> � � � � � prod14 =
> (pi14**x1)*(1-pi14)**(1-x1);
> � � � � � � prod15 =
> (pi15**x1)*(1-pi15)**(1-x1);
> � � � � � � prod16 =
> (pi16**x1)*(1-pi16)**(1-x1);
> prod21 = (pi21**x2)*(1-pi21)**(1-x2);
> � � � prod22 = (pi22**x2)*(1-pi22)**(1-x2);
> � � � � prod23 =
> (pi23**x2)*(1-pi23)**(1-x2);
> � � � � � prod24 =
> (pi24**x2)*(1-pi24)**(1-x2);
> � � � � � � prod25 =
> (pi25**x2)*(1-pi25)**(1-x2);
> � � � � � � prod26 =
> (pi26**x2)*(1-pi26)**(1-x2);
> � prod31 = (pi31**x3)*(1-pi31)**(1-x3);
> � � prod32 = (pi32**x3)*(1-pi32)**(1-x3);
> � � � prod33 = (pi33**x3)*(1-pi33)**(1-x3);
> � � � � prod34 =
> (pi34**x3)*(1-pi34)**(1-x3);
> � � � � � prod35 =
> (pi35**x3)*(1-pi35)**(1-x3);
> � � � � � � prod36 =
> (pi36**x3)*(1-pi36)**(1-x3);
> � prod41 = (pi41**x1)*(1-pi41)**(1-x4);
> � � prod42 = (pi42**x4)*(1-pi42)**(1-x4);
> � � � prod43 = (pi43**x4)*(1-pi43)**(1-x4);
> � � � � prod44 =
> (pi44**x4)*(1-pi44)**(1-x4);
> � � � � � prod45 =
> (pi45**x4)*(1-pi45)**(1-x4);
> � � � � � � prod46 =
> (pi46**x4)*(1-pi46)**(1-x4);
> � prod51 = (pi51**x5)*(1-pi51)**(1-x5);
> � � prod52 = (pi52**x5)*(1-pi52)**(1-x5);
> � � � prod53 = (pi53**x5)*(1-pi53)**(1-x5);
> � � � � prod54 =
> (pi54**x5)*(1-pi54)**(1-x5);
> � � � � � prod55 =
> (pi55**x5)*(1-pi55)**(1-x5);
> � � � � � � prod56 =
> (pi56**x5)*(1-pi56)**(1-x5);
> � prod61 = (pi61**x6)*(1-pi61)**(1-x6);
> � � prod62 = (pi62**x6)*(1-pi62)**(1-x6);
> � � � prod63 = (pi63**x6)*(1-pi63)**(1-x6);
> � � � � prod64 =
> (pi64**x6)*(1-pi64)**(1-x6);
> � � � � � � � prod65 =
> (pi65**x6)*(1-pi65)**(1-x6);
> � � � � � � � � prod66
> = (pi66**x6)*(1-pi66)**(1-x6);
> � prod71 = (pi71**x7)*(1-pi71)**(1-x7);
> � � prod72 = (pi72**x7)*(1-pi72)**(1-x7);
> � � � prod73 = (pi73**x7)*(1-pi73)**(1-x7);
> � � � � prod74 =
> (pi74**x7)*(1-pi74)**(1-x7);
> � � � � � prod75 =
> (pi75**x7)*(1-pi75)**(1-x7);
> � � � � � � � � prod76
> = (pi76**x7)*(1-pi76)**(1-x7);
> � prod81 = (pi81**x8)*(1-pi81)**(1-x8);
> � � prod82 = (pi82**x8)*(1-pi82)**(1-x8);
> � � � prod83 = (pi83**x8)*(1-pi83)**(1-x8);
> � � � � prod84 =
> (pi84**x8)*(1-pi84)**(1-x8);
> � � � � � prod85 =
> (pi85**x8)*(1-pi85)**(1-x8);
> � � � � � � � prod86 =
> (pi86**x8)*(1-pi86)**(1-x8);
> � prod91 = (pi91**x9)*(1-pi91)**(1-x9);
> � � prod92 = (pi92**x9)*(1-pi92)**(1-x9);
> � � � prod93 = (pi93**x9)*(1-pi93)**(1-x9);
> � � � � prod94 =
> (pi94**x9)*(1-pi94)**(1-x9);
> � � � � � prod95 =
> (pi95**x9)*(1-pi95)**(1-x9);
> � � � � � � � prod96 =
> (pi96**x9)*(1-pi96)**(1-x9);
> � prod101 = (pi101**x10)*(1-pi101)**(1-x10);
> � � prod102 = (pi102**x10)*(1-pi102)**(1-x10);
> � � � prod103 =
> (pi103**x10)*(1-pi103)**(1-x10);
> � � � � prod104 =
> (pi104**x10)*(1-pi104)**(1-x10);
> � � � � � prod105 =
> (pi105**x10)*(1-pi105)**(1-x10);
> � � � � � � prod106 =
> (pi106**x10)*(1-pi106)**(1-x10);
> � prod111 = (pi111**x11)*(1-pi111)**(1-x11);
> � � prod112 = (pi112**x11)*(1-pi112)**(1-x11);
> � � � prod113 =
> (pi113**x11)*(1-pi113)**(1-x11);
> � � � � prod114 =
> (pi114**x11)*(1-pi114)**(1-x11);
> � � � � � prod115 =
> (pi115**x11)*(1-pi115)**(1-x11);
> � � � � � � prod116 =
> (pi116**x11)*(1-pi116)**(1-x11);
> � prod121 = (pi121**x12)*(1-pi121)**(1-x12);
> � � prod122 = (pi122**x12)*(1-pi122)**(1-x12);
> � � � prod123 =
> (pi123**x12)*(1-pi123)**(1-x12);
> � � � � prod124 =
> (pi124**x12)*(1-pi124)**(1-x12);
> � � � � � prod125 =
> (pi125**x12)*(1-pi125)**(1-x12);
> � � � � � � prod126 =
> (pi126**x12)*(1-pi126)**(1-x12);
> � prod131 = (pi131**x13)*(1-pi131)**(1-x13);
> � � prod132 = (pi132**x13)*(1-pi132)**(1-x13);
> � � � prod133 =
> (pi133**x13)*(1-pi133)**(1-x13);
> � � � � prod134 =
> (pi134**x13)*(1-pi134)**(1-x13);
> � � � � � prod135 =
> (pi135**x13)*(1-pi135)**(1-x13);
> � � � � � � prod136 =
> (pi136**x13)*(1-pi136)**(1-x13);
> � prod141 = (pi141**x14)*(1-pi141)**(1-x14);
> � � prod142 = (pi142**x14)*(1-pi142)**(1-x14);
> � � � prod143 =
> (pi143**x14)*(1-pi143)**(1-x14);
> � � � � prod144 =
> (pi144**x14)*(1-pi144)**(1-x14);
> � � � � � prod145 =
> (pi145**x14)*(1-pi145)**(1-x14);
> � � � � � � prod146 =
> (pi146**x14)*(1-pi146)**(1-x14);
> � prod151 = (pi151**x15)*(1-pi151)**(1-x15);
> � � prod152 = (pi152**x15)*(1-pi152)**(1-x15);
> � � � prod153 =
> (pi153**x15)*(1-pi153)**(1-x15);
> � � � � prod154 =
> (pi154**x15)*(1-pi154)**(1-x15);
> � � � � � prod155 =
> (pi155**x15)*(1-pi155)**(1-x15);
> � � � � � � prod156 =
> (pi156**x15)*(1-pi156)**(1-x15);
> � prod161 = (pi161**x16)*(1-pi161)**(1-x16);
> � � prod162 = (pi162**x16)*(1-pi162)**(1-x16);
> � � � prod163 =
> (pi163**x16)*(1-pi163)**(1-x16);
> � � � � prod164 =
> (pi164**x16)*(1-pi164)**(1-x16);
> � � � � � prod165 =
> (pi165**x16)*(1-pi165)**(1-x16);
> � � � � � � prod166 =
> (pi166**x16)*(1-pi166)**(1-x16);
> � prod171 = (pi171**x17)*(1-pi171)**(1-x17);
> � � prod172 = (pi172**x17)*(1-pi172)**(1-x17);
> � � � prod173 =
> (pi173**x17)*(1-pi173)**(1-x17);
> � � � � prod174 =
> (pi174**x17)*(1-pi174)**(1-x17);
> � � � � � prod175 =
> (pi175**x17)*(1-pi175)**(1-x17);
> � � � � � � prod176 =
> (pi176**x17)*(1-pi176)**(1-x17);
> � prod181 = (pi181**x18)*(1-pi181)**(1-x18);
> � � prod182 = (pi182**x18)*(1-pi182)**(1-x18);
> � � � prod183 =
> (pi183**x18)*(1-pi183)**(1-x18);
> � � � � prod184 =
> (pi184**x18)*(1-pi184)**(1-x18);
> � � � � � prod185 =
> (pi185**x18)*(1-pi185)**(1-x18);
> � � � � � � prod186 =
> (pi186**x18)*(1-pi186)**(1-x18);
> � prod191 = (pi191**x19)*(1-pi191)**(1-x19);
> � � prod192 = (pi192**x19)*(1-pi192)**(1-x19);
> � � � prod193 =
> (pi193**x19)*(1-pi193)**(1-x19);
> � � � � prod194 =
> (pi194**x19)*(1-pi194)**(1-x19);
> � � � � � prod195 =
> (pi195**x19)*(1-pi195)**(1-x19);
> � � � � � � prod196 =
> (pi196**x19)*(1-pi196)**(1-x19);
>
> /* model probability of each latent class.� */
> /* Note that we add random effect u1 to alpha1.� U1
> is */
> /* person random effect on probability of latent class */
> /* 1.� If there are more latent classes, then
> would� � */
> /* need terms u2, u3, etc.� � � �
> � � � � � � � �
> � � � � */
>
> *************Not Clear On How to Contstruct Code
> Below***************
>
> eta1=exp(alpha1 + u1)/(1+exp(alpha1 + u1));
> eta2=1/(1+exp(alpha2 + u2));
> eta3=exp(alpha3+ u3)/(1+exp(alpha3 + u3));
> eta4=1/(1+exp(alpha4 + u4));
> eta5=exp(alpha5 + u5)/(1+exp(alpha5 + u5));
> eta6=1/(1+exp(alpha5 + u5));
>
> /* Construct likelihood and log likelihood� �
> */
> l_latclass=eta1*prod11*prod21*prod31*prod41*
> � � � � � � �
> � � � prod51*prod61*prod71*prod81*
> � � � � � � �
> � � � prod91*prod101*prod111*prod121*
> � � � � � � �
> � � � prod131*prod141*prod151*prod161*
> � � � � � � �
> � � � prod171*prod181*prod191
> � � � � � � +
> � � � � � �
> eta2*prod12*prod22*prod32*prod42*
> � � � � � � �
> � � � prod52*prod62*prod72*prod82*
> � � � � � � �
> � � � prod92*prod102*prod112*prod122*
> � � � � � � �
> � � � prod132*prod142*prod152*prod162*
> � � � � � � �
> � � � prod172*prod182*prod192
> � � � � � � +
> � � � � � �
> eta3*prod13*prod23*prod33*prod43*
> � � � � � � �
> � � � prod53*prod63*prod73*prod83*
> � � � � � � �
> � � � prod93*prod103*prod113*prod123*
> � � � � � � �
> � � � prod133*prod143*prod153*prod163*
> � � � � � � �
> � � � prod173*prod183*prod193
> � � � � � � +
> � � � � � �
> eta4*prod14*prod24*prod34*prod44*
> � � � � � � �
> � � � prod54*prod64*prod74*prod84*
> � � � � � � �
> � � � prod94*prod104*prod114*prod124*
> � � � � � � �
> � � � prod134*prod144*prod154*prod164*
> � � � � � � �
> � � � prod174*prod184*prod194
> � � � � � � +
> � � � � � �
> eta5*prod15*prod25*prod35*prod45*
> � � � � � � �
> � � � prod55*prod65*prod75*prod85*
> � � � � � � �
> � � � prod95*prod105*prod115*prod125*
> � � � � � � �
> � � � prod135*prod145*prod155*prod165*
> � � � � � � �
> � � � prod175*prod185*prod195
> � � � � � � +
> � � � � � �
> eta6*prod16*prod26*prod36*prod46*
> � � � � � � �
> � � � prod56*prod66*prod76*prod86*
> � � � � � � �
> � � � prod96*prod106*prod116*prod126*
> � � � � � � �
> � � � prod136*prod146*prod156*prod166*
> � � � � � � �
> � � � prod176*prod186*prod196;
>
> ll_latclass = log(l_latclass);
>
> /* Maximize the latent class log likelihood */
> model ll_latclass ˜ general(ll_latclass);
>
> /* Model the variance of the latent class probability */
> random u1 u2 u3 u4 u5 ~ normal([0], [exp(2*log_Valpha1)],
> � � � � � � � �
> � � � � � � � � [0],
> [exp(2*log_Valpha2)],
> � � � � � � � �
> � � � � � � � � [0],
> [exp(2*log_Valpha3)],
> � � � � � � � �
> � � � � � � � � [0],
> [exp(2*log_Valpha4)],
> � � � � � � � �
> � � � � � � � � [0],
> [exp(2*log_Valpha5)] )
> subject=person;
> run;
>
> /------------------------------END SAS
> CODE--------------------------------------/
>
> Thanks!
>
> Ryan
>
From: Ryan on
On Dec 3, 5:40 pm, stringplaye...(a)YAHOO.COM (Dale McLerran) wrote:
> Ryan,
>
> One more follow-up.  I thought that I should take a look at
> how you handled the random effects.  That led me to look at
> how you constructed the probabilities of the six latent
> classes.  Your code there was incorrect.  You wrote:
>
> *************Not Clear On How to Contstruct Code Below***************
>
> eta1=exp(alpha1 + u1)/(1+exp(alpha1 + u1));
> eta2=1/(1+exp(alpha2 + u2));
> eta3=exp(alpha3+ u3)/(1+exp(alpha3 + u3));
> eta4=1/(1+exp(alpha4 + u4));
> eta5=exp(alpha5 + u5)/(1+exp(alpha5 + u5));
> eta6=1/(1+exp(alpha5 + u5));
>
> The latent class probability model should be constructed as
>
> f1 = exp(alpha1 + u1);
> f2 = exp(alpha2 + u2);
> f3 = exp(alpha3 + u3);
> f4 = exp(alpha4 + u4);
> f5 = exp(alpha5 + u5);
> eta1 = f1 / (1 + f1 + f2 + f3 + f4 + f5);
> eta2 = f2 / (1 + f1 + f2 + f3 + f4 + f5);
> eta3 = f3 / (1 + f1 + f2 + f3 + f4 + f5);
> eta4 = f4 / (1 + f1 + f2 + f3 + f4 + f5);
> eta5 = f5 / (1 + f1 + f2 + f3 + f4 + f5);
> eta6 =  1 / (1 + f1 + f2 + f3 + f4 + f5);
>
> You will note that with the construction which I show above,
> the probabilities sum to 1.0.  That is not be the case for
> the code which you had.
>
> Dale
>
> ---------------------------------------
> Dale McLerran
> Fred Hutchinson Cancer Research Center
> mailto: dmclerra(a)NO_SPAMfhcrc.org
> Ph:  (206) 667-2926
> Fax: (206) 667-5977
> ---------------------------------------
>
> --- On Thu, 12/3/09, Ryan <ryan.andrew.bl...(a)GMAIL.COM> wrote:
>
>
>
> > From: Ryan <ryan.andrew.bl...(a)GMAIL.COM>
> > Subject: Latent Class Analysis via NLMIXED - UPDATE
> > To: SA...(a)LISTSERV.UGA.EDU
> > Date: Thursday, December 3, 2009, 7:03 AM
> > Hi Dale and others,
>
> > Thanks so much for the feedback yesterday. I was hoping
> > Dale and/or
> > others would consider taking a look at the code I
> > constructed based on
> > Dale's example. I'm certain there are errors in my code as
> > I did not
> > grasp fully the explanations of the code. Hopefully, I'm
> > not
> > completely off the mark.
>
> > Note that my dataset consists of 19 response variables,
> > some of which
> > are dichotomous (0/1) and while others are
> > continuous/ordinal. There
> > are 6 hypothesized latent classes and a random intercept.
>
> > Code starts now...
>
> > /
> > *--------------------------------------------------------------------------­------------------
> > */
> > /*-----LCA with 6 classes, 19 response variables, &
> > Person REs---*/
> > /
> > *--------------------------------------------------------------------------­------------------
> > */
> > proc nlmixed data=mydata tech=quanew lis=2 method=gauss
> >            maxiter=1000
> > gconv=.00000000001 fconv=.00000000001;
> >  parms
>
> > /* Parameter which expresses probability
> > of */
> > /* latent class contrasts  
> >          
> > */
> > alpha1 = 0.17 alpha2 = 0.17 alpha3 =
> > 0.17
> > alpha4 = 0.17 alpha5 = 0.17
>
> > /* If there are more latent classes, then
> > need */
> > /* alpha1, alpha2, etc.  Number of
> > alpha parms */
> > /* is one less than number of latent
> > classes.  */
> > log_Valpha1 -4 log_Valpha2 -4 log_Valpha3
> > -4
> > log_Valpha4 -4 log_Valpha5 -4
>
> > /* Parameters which express probability
> > of Xi=1 | latent class 1 */
> > bpi11 = 1 bpi21 = 1 bpi31 = 1 bpi41 = 1
> > bpi51 = 1 bpi61 = 1
> > bpi71 = 1 bpi81 = 1 bpi91 = 1 bpi101 = 1
> > bpi111 = 1
> > bpi121 = 1 bpi131 = 1 bpi141 = 1 bpi151 =
> > 1 bpi161 = 1
> > bpi171 = 1 bpi181 = 1 bpi191 = 0
>
> > /* Parameters which express probability
> > of Xi=1 | latent class 2 */
> > bpi12 = .5 bpi22 = .5 bpi32 = .5 bpi42 =
> > .5 bpi51 = .5 bpi62 = .5
> > bpi72 = .5 bpi82 = .5 bpi92 = .5 bpi102 =
> > .5 bpi112 = .5
> > bpi122 = .5 bpi132 = .5 bpi142 = .5
> > bpi152 = .5 bpi162 = -.5
> > bpi172 = .5 bpi182 = .5 bpi192 = .5
>
> > /* Parameters which express probability
> > of Xi=1 | latent class 3 */
> > bpi13 = 1 bpi23 = 1 bpi33 = 1 bpi43 = 1
> > bpi53 = 1 bpi63 = 1
> > bpi73 = 1 bpi83 = 1 bpi93 = 1 bpi103 = 1
> > bpi113 = 1
> > bpi123 = 1 bpi133 = 1 bpi143 = 1 bpi153 =
> > 1 bpi163 = 1
> > bpi173 = 1 bpi183 = 1 bpi193 = 0
>
> > /* Parameters which express probability
> > of Xi=1 | latent class 4 */
> > bpi14 = .5 bpi24 = .5 bpi34 = .5 bpi44 =
> > .5 bpi54 = .5 bpi64 = .5
> > bpi74 = .5 bpi84 = .5 bpi94 = .5 bpi104 =
> > .5 bpi114 = .5
> > bpi124 = .5 bpi134 = .5 bpi144 = .5
> > bpi154 = .5 bpi164 = -.5
> > bpi174 = .5 bpi184 = .5 bpi194 = .5
>
> > /* Parameters which express probability
> > of Xi=1 | latent class 5 */
> > bpi15 = 1 bpi25 = 1 bpi35 = 1 bpi45 = 1
> > bpi55 = 1 bpi65 = 1
> > bpi75 = 1 bpi85 = 1 bpi95 = 1 bpi105 = 1
> > bpi115 = 1
> > bpi125 = 1 bpi135 = 1 bpi145 = 1 bpi155 =
> > 1 bpi165 = 1
> > bpi175 = 1 bpi185 = 1 bpi195 = 0
>
> > /* Parameters which express probability
> > of Xi=1 | latent class 6 */
> > bpi16 = .5 bpi26 = .5 bpi36 = .5 bpi46 =
> > .5 bpi51 = .5 bpi66 = .5
> > bpi76 = .5 bpi86 = .5 bpi96 = .5 bpi106 =
> > .5 bpi116 = .5
> > bpi126 = .5 bpi136 = .5 bpi146 = .5
> > bpi156 = .5 bpi166 = -.5
> > bpi176 = .5 bpi186 = .5 bpi196 = .5
> >  ;
>
> >  bounds -6 <= bpi11 - bpi191 <= 6;
>
> >  **** latent class part;
>
> >  pi11 = 1/(1+exp(-bpi11)); pi12 = 1/(1+exp(-bpi12));
> >  pi21 = 1/(1+exp(-bpi21)); pi22 = 1/(1+exp(-bpi22));
> >  pi31 = 1/(1+exp(-bpi31)); pi32 = 1/(1+exp(-bpi32));
> >  pi41 = 1/(1+exp(-bpi41)); pi42 = 1/(1+exp(-bpi42));
> >  pi51 = 1/(1+exp(-bpi51)); pi52 = 1/(1+exp(-bpi52));
> >  pi61 = 1/(1+exp(-bpi61)); pi62 = 1/(1+exp(-bpi62));
> >  pi71 = 1/(1+exp(-bpi71)); pi72 = 1/(1+exp(-bpi72));
> >  pi81 = 1/(1+exp(-bpi81)); pi82 = 1/(1+exp(-bpi82));
> >  pi91 = 1/(1+exp(-bpi91)); pi92 = 1/(1+exp(-bpi92));
> >  pi101 = 1/(1+exp(-bpi101)); pi102 = 1/(1+exp(-bpi102));
> >  pi111 = 1/(1+exp(-bpi111)); pi112 = 1/(1+exp(-bpi112));
> >  pi121 = 1/(1+exp(-bpi121)); pi122 = 1/(1+exp(-bpi122));
> >  pi131 = 1/(1+exp(-bpi131)); pi132 = 1/(1+exp(-bpi132));
> >  pi141 = 1/(1+exp(-bpi141)); pi142 = 1/(1+exp(-bpi142));
> >  pi151 = 1/(1+exp(-bpi151)); pi152 = 1/(1+exp(-bpi152));
> >  pi161 = 1/(1+exp(-bpi161)); pi162 = 1/(1+exp(-bpi162));
> >  pi171 = 1/(1+exp(-bpi171)); pi172 = 1/(1+exp(-bpi172));
> >  pi181 = 1/(1+exp(-bpi181)); pi182 = 1/(1+exp(-bpi182));
> >  pi191 = 1/(1+exp(-bpi191)); pi192 = 1/(1+exp(-bpi192));
>
> >  pi13 = 1/(1+exp(-bpi13)); pi14 = 1/(1+exp(-bpi12));
> >  pi23 = 1/(1+exp(-bpi23)); pi24 = 1/(1+exp(-bpi22));
> >  pi33 = 1/(1+exp(-bpi33)); pi34 = 1/(1+exp(-bpi34));
> >  pi43 = 1/(1+exp(-bpi43)); pi44 = 1/(1+exp(-bpi44));
> >  pi53 = 1/(1+exp(-bpi53)); pi54 = 1/(1+exp(-bpi54));
> >  pi63 = 1/(1+exp(-bpi63)); pi64 = 1/(1+exp(-bpi64));
> >  pi73 = 1/(1+exp(-bpi73)); pi74 = 1/(1+exp(-bpi74));
> >  pi83 = 1/(1+exp(-bpi83)); pi84 = 1/(1+exp(-bpi84));
> >  pi93 = 1/(1+exp(-bpi93)); pi94 = 1/(1+exp(-bpi94));
> >  pi103 = 1/(1+exp(-bpi103)); pi104 = 1/(1+exp(-bpi104));
> >  pi113 = 1/(1+exp(-bpi113)); pi114 = 1/(1+exp(-bpi114));
> >  pi123 = 1/(1+exp(-bpi123)); pi124 = 1/(1+exp(-bpi124));
> >  pi133 = 1/(1+exp(-bpi133)); pi134 = 1/(1+exp(-bpi134));
> >  pi143 = 1/(1+exp(-bpi143)); pi144 = 1/(1+exp(-bpi144));
> >  pi153 = 1/(1+exp(-bpi153)); pi154 = 1/(1+exp(-bpi154));
> >  pi163 = 1/(1+exp(-bpi163)); pi164 = 1/(1+exp(-bpi164));
> >  pi173 = 1/(1+exp(-bpi173)); pi174 = 1/(1+exp(-bpi174));
> >  pi183 = 1/(1+exp(-bpi183)); pi184 = 1/(1+exp(-bpi184));
> >  pi193 = 1/(1+exp(-bpi193)); pi194 = 1/(1+exp(-bpi194));
>
> >  pi15 = 1/(1+exp(-bpi15)); pi16 = 1/(1+exp(-bpi16));
> >  pi25 = 1/(1+exp(-bpi25)); pi26 = 1/(1+exp(-bpi26));
> >  pi35 = 1/(1+exp(-bpi35)); pi36 = 1/(1+exp(-bpi36));
> >  pi45 = 1/(1+exp(-bpi45)); pi46 = 1/(1+exp(-bpi46));
> >  pi55 = 1/(1+exp(-bpi55)); pi56 = 1/(1+exp(-bpi56));
> >  pi65 = 1/(1+exp(-bpi65)); pi66 = 1/(1+exp(-bpi66));
> >  pi75 = 1/(1+exp(-bpi75)); pi76 = 1/(1+exp(-bpi76));
> >  pi85 = 1/(1+exp(-bpi85)); pi86 = 1/(1+exp(-bpi86));
> >  pi95 = 1/(1+exp(-bpi95)); pi96 = 1/(1+exp(-bpi96));
> >  pi105 = 1/(1+exp(-bpi105)); pi106 = 1/(1+exp(-bpi106));
> >  pi115 = 1/(1+exp(-bpi115)); pi116 = 1/(1+exp(-bpi116));
> >  pi125 = 1/(1+exp(-bpi125)); pi126 = 1/(1+exp(-bpi126));
> >  pi135 = 1/(1+exp(-bpi135)); pi136 = 1/(1+exp(-bpi136));
> >  pi145 = 1/(1+exp(-bpi145)); pi146 = 1/(1+exp(-bpi146));
> >  pi155 = 1/(1+exp(-bpi155)); pi156 = 1/(1+exp(-bpi156));
> >  pi165 = 1/(1+exp(-bpi165)); pi166 = 1/(1+exp(-bpi166));
> >  pi175 = 1/(1+exp(-bpi175)); pi176 = 1/(1+exp(-bpi176));
> >  pi185 = 1/(1+exp(-bpi185)); pi186 = 1/(1+exp(-bpi186));
> >  pi195 = 1/(1+exp(-bpi195)); pi196 = 1/(1+exp(-bpi196));
>
> >  prod11 = (pi11**x1)*(1-pi11)**(1-x1);
> > prod12 = (pi12**x1)*(1-pi12)**(1-x1);
> >   prod13 =
> > (pi13**x1)*(1-pi13)**(1-x1);
> >     prod14 =
> > (pi14**x1)*(1-pi14)**(1-x1);
> >       prod15 =
> > (pi15**x1)*(1-pi15)**(1-x1);
> >            prod16 =
> > (pi16**x1)*(1-pi16)**(1-x1);
> >  prod21 = (pi21**x2)*(1-pi21)**(1-x2);
> > prod22 = (pi22**x2)*(1-pi22)**(1-x2);
> >   prod23 =
> > (pi23**x2)*(1-pi23)**(1-x2);
> >     prod24 =
> > (pi24**x2)*(1-pi24)**(1-x2);
> >       prod25 =
> > (pi25**x2)*(1-pi25)**(1-x2);
> >            prod26 =
> > (pi26**x2)*(1-pi26)**(1-x2);
> >  prod31 = (pi31**x3)*(1-pi31)**(1-x3);
> >    prod32 = (pi32**x3)*(1-pi32)**(1-x3);
> >      prod33 = (pi33**x3)*(1-pi33)**(1-x3);
> >        prod34 =
> > (pi34**x3)*(1-pi34)**(1-x3);
> >          prod35 =
> > (pi35**x3)*(1-pi35)**(1-x3);
> >            prod36 =
> > (pi36**x3)*(1-pi36)**(1-x3);
> >  prod41 = (pi41**x1)*(1-pi41)**(1-x4);
> >    prod42 = (pi42**x4)*(1-pi42)**(1-x4);
> >      prod43 = (pi43**x4)*(1-pi43)**(1-x4);
> >        prod44 =
> > (pi44**x4)*(1-pi44)**(1-x4);
> >          prod45 =
> > (pi45**x4)*(1-pi45)**(1-x4);
> >            prod46 =
>
> ...
>
> read more »- Hide quoted text -
>
> - Show quoted text -

Hi Dale,

Thank you for responding. I should've just posted part of the code.
Sorry for all the lines.

I realized after my original post that I do not currently have any
continuous variables, although I might consider adding a couple in the
future. I'll stick with the dichotomous variables for now, and I'll
make sure to validate the fixed effects only model using another
procedure, such as proc lca.

Thanks again!

Ryan