# st: data management for the weight option of -gllamm-

 From Alessio Fusco To "'statalist@hsphsun2.harvard.edu'" Subject st: data management for the weight option of -gllamm- Date Fri, 31 Oct 2008 15:21:27 +0100

```Dear Stata users,

I want to estimate a MIMIC model with –gllamm- but I am facing difficulty of data management to use the weight option when I include the covariates of the structural equation.

The measurement model I estimate is a two parameter logistic IRT model.
I have 5 dichotomous items and for item i and subject j, we have

Logit[P(yij=1|nj)]=betai+lambdai.nj

Where betai is the difficulty parameter of the item, lambdai  the discriminate parameter and nj is the person ability.

nj = v0 + v1 male + v2 CL2 + v0 CL3 + e
where male is a dummy (1 if men and 0 if women)
I categorized the variable age in dummys:
[CL1] = <30
[CL2] = 30-49
[CL3] = 50+

// create the pattern
egen pattern = group(item1 item2 item3 item4 item5 male CL2 CL3)
// compute wt2
contract item1 item2 item3 item4 item5 male CL2 CL3 pattern, f(wt2)
// stack variables into a single vector

reshape long item, i(pattern) j(art)

//create the dummies
tab art, gen(d)

// MIMIC model - difficulty parameter of item 1 set at 0
gen cons=1
eq f1: cons male CL2 CL3

gllamm item d2-d5, i(pattern) eqs(load) l(logit) f(binom) weight(wt) /*
*/ geqs(f1) from(a) nocons adapt nip(12)

This works but I am not sure if I should also include CL1 in the command
egen pattern = group(item1 item2 item3 item4 item5 male CL1 CL2 CL3)
Also, what shall I do if I want to add a continuous covariate…

The use of –gllamm- is not so easy so that any help would be greatly appreciated as I am not sure I handle the things properly.

Thanks
Alessio Fusco