Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Latent class analysis


From   Michael Ingre <Michael.Ingre@ipm.ki.se>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Latent class analysis
Date   Fri, 29 Oct 2004 15:29:17 +0200

On 2004-10-28, at 14.17, Modesto G Gayo-Cal wrote:

1. Is it possible to do latent class analysis with STATA?
Yes you can do it with -gllamm- as a discrete latent variable model.

2. If the answer to 1 is "yes", how?
. gen const=1
. eq intercept: const
. eq slope: time
. gllamm y x time, nrf(2) eqs(intercept slope) ip(f) nip(3)

The above syntax defines equations for two -nrf(2)- random effects -eq(intercept slope)- in a linear growth curve model and estimates 3 latent trajectory classes -nip(3)- defined by the random effects.

. rename sleep_complaints y1
. rename health_complaints y2
. rename fatigue_complaint y3
. rename pain_complaint y4
. gen id = _n
. reshape long y , i(id) j(item)
. tab var , gen(d)
. eq d1: d1
. eg d2: d2
. eq d3: d3
. eq d4: d4
. gllamm y , i(id) nrf(4) eqs(d1 d2 d3 d4) link(logit) fam(bin) ip(f) nip(2) nocons

The above syntax estimates two latent classes from the responses in a cross sectional dataset of three binary items indicating complaints (sleep health fatigue pain). To do it the variables has to be renamed and the dataset reshaped to long form so that the responses from all items are stacked in -y- with dummy variables indicating the specific items (d1-d4). Item dummys are modelled as random effects -eq(d1 d2 d3)- and the number of classes is set -nip(2)-.

Probability for class membership is obtained by:

. gllapred prob_class , p


Michael

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index