```Date: Thu, 3 Dec 2009 15:35:42 -0800 Reply-To: Ryan Sender: "SAS(r) Discussion" From: Ryan Organization: http://groups.google.com Subject: Re: Latent Class Analysis via NLMIXED - UPDATE Comments: To: sas-l@uga.edu Content-Type: text/plain; charset=ISO-8859-1 On Dec 3, 5:40 pm, stringplaye...@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@NO_SPAMfhcrc.org > Ph: (206) 667-2926 > Fax: (206) 667-5977 > --------------------------------------- > > --- On Thu, 12/3/09, Ryan wrote: > > > > > From: Ryan > > Subject: Latent Class Analysis via NLMIXED - UPDATE > > To: SA...@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 ```

Back to: Top of message | Previous page | Main SAS-L page