/* Do file for some of the multiple-group bifactor models from: Jeon, M., Rijmen, F. and Rabe-Hesketh (in press). Modeling differential item functioning using a generalization of the multiple-group bifactor model. ournal of Educational and Behavioral Statistics, in press. http://dx.doi.org/10.3102/1076998611432173 */ *** prepare data insheet using simdata.csv, clear generate group = v1 - 1 drop v1 generate id=_n reshape long v, i(id) j(item) replace item = item-1 rename v y tabulate item, gen(it) generate dif = it10*group *** Unidimensional one-parameter IRT model with DIF xtset id xtlogit y it1-it12 group dif, nocons * install gllamm using the command: ssc install gllamm, replace gllamm y it1-it12 group dif, nocons i(id) link(logit) fam(binom) adapt *** Uncorrelated bifactor model, constant variances recode item 1/4 = 1 5/8 = 2 9/12 = 3, gen(testlet) tabulate testlet, gen(t) * loadings for general and specific dimensions eq loadg: it1-it12 eq loads: it1-it12 * group by testlet interactions generate t1_gr = t1*group generate t2_gr = t2*group generate t3_gr = t3*group * equations for group mean differences: f1=specific, f2=general eq f1: t1_gr t2_gr t3_gr eq f2: gr * constrain variances of thetas: tes1_1: testlet, id2_1: general constr def 1 [tes1_1]it1=1 constr def 2 [id2_1]it1=1 *** Uncorrelated bifactor model, constant variances, without DIF gllamm y it1-it12, nocons i(testlet id) eqs(loads loadg) frload(1 2) /// geqs(f1 f2) link(logit) fam(binom) adapt trace constr(1 2) estimates save bifac, replace /* saves estimates in a file */ *** Uncorrelated bifactor model, constant variances, with DIF (main model) matrix a=e(b) gllamm y it1-it12 dif, nocons i(testlet id) eqs(loads loadg) frload(1 2) /// geqs(f1 f2) link(logit) fam(binom) adapt trace constr(1 2) from(a) long estimates save bifacdif, replace