# Re: st: GLLAMM

 From Stas Kolenikov To statalist@hsphsun2.harvard.edu Subject Re: st: GLLAMM Date Fri, 12 Feb 2010 14:24:28 -0600

```On Fri, Feb 12, 2010 at 9:33 AM, arosella <arosella@irccsdebellis.it> wrote:

> Dear Stata Listers, I am trying to estimate a model using GLLAMM. I have an
> unobserved response variable (performance) that is comprised of three
> numerical items (perf1, perf2,perf3). This unobserved response shoul be
> regressed on two latent variables (iute, iure) each comprised of four and
> two numerical items respectively. There are moreover eight covariates with
> direct effect on unobserved response variable and on both iure and iute. I
> have written some code (and have pasted it below) to build a responde
> variable but I cannot figure out how to construc the DV as latent variable
> and the other latent variable. It's too complicated for me. Does anyone have
> any advice? Any help would be greatly appreciated.
>

I'll give you some building blocks to work with.

======== beginning of sample code =========

// Let the indicators of the performance be perf1 - perf3
gen resp1 = perf1
gen resp2 = perf2
gen resp3 = perf3

// Let the indicators of iute be iute1, iute2
gen resp4 = iute1
gen resp5 = iute2

// Let the indicators of iure be iure1 - iure4
gen resp6 = iure1
gen resp7 = iure2
gen resp8 = iure3
gen resp9 = iure4

// reshape to gllamm
gen i = _n
reshape long resp, i(i) j(j 1-9)
tab j,  gen( v )

// you now have variables v1-v9 corresponding to 9 indicators of all the
latents

// measurement equations
eq f1 : v1 v2 v3
eq f2 : v4 v5
eq f3 : v6 v7 v8 v9

// exogenous variables affecting the latent variables: x1 - x8
eq r1 : x1 x2 x3 x4 x5 x6 x7 x8
eq r2 : x1 x2 x3 x4 x5 x6 x7 x8
eq r3 : x1 x2 x3 x4 x5 x6 x7 x8

// define the regression of latent variable on one another
mat B = (0, 1, 1 \ 0, 0, 0 \ 0, 0, 0)
// BIG BANG
gllamm resp v*, i(i) nrf(3) eq( f1 f2 f3 ) geq( r1 r2 r3 ) bmat( B )

======== end of sample code =========

No warranties that this will run, just some guidelines. It will take a very
long time to converge, given the number of parameters.

If you have categorical indicators, then you'd want to use -family() fv()
link() lv()- options to fully utilize the infinite powers of -gllamm- :))

If you are interested, I have a working paper in progress where I show how
to estimate structural equation models using -gmm-. That's much faster than
in -gllamm-, although requires some custom coding, too.

--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/```

• References:
• st: GLLAMM
• From: "arosella" <arosella@irccsdebellis.it>