capture log close log using coff, replace set more off * Read data insheet using coff.dat, clear sort id set alt list alt brand1 brand2 cap1 cap2 price1 price2 therm filter if id==1&alt==3&set==1 list set alt brand1 brand2 cap1 cap2 price1 price2 therm filter if id==1&alt==1 list set alt brand1 brand2 cap1 cap2 price1 price2 therm filter if id==1&alt==2 list set alt brand1 brand2 cap1 cap2 price1 price2 therm filter if id==100&alt==1 list set alt brand1 brand2 cap1 cap2 price1 price2 therm filter if id==100&alt==2 * one class model matrix a=(-.2501341,-.6190279,-1.536721,-.0281915,.9982744,1.057279, /* */ .6247699,.6803732) gllamm alt brand1 brand2 cap1 cap2 price1 price2 therm filter, i(id) /* */ nocons l(mlogit) f(binom) expand(ind ch o) init from(a) copy trace * predictions insheet using coffpred.dat, clear gllapred p, mu marg fsample save coffp, replace insheet using coff.dat, clear * two class model eq brand1: brand1 eq brand2: brand2 eq cap1: cap1 eq cap2: cap2 eq price1: price1 eq price2: price2 eq therm: therm eq filter: filter matrix a=(-.3741151,-.4046775,-2.484026,.0602947,1.96566,1.482599,1.13633, /* */ .9201916,.9212055,.1210968,-1.434993,-.2476023,.0675716,-.489632, /* */ -.0361355,.346111,1.00166) gllamm alt, i(id) nrf(8) eqs(brand1 brand2 cap1 cap2 price1 price2 therm filter) /* */ nocons l(mlogit) f(binom) expand(ind ch o) nip(2) ip(fn) from(a) copy trace allc * predictions use coffp, clear gllapred p1, mu marg fsample save coffp, replace insheet using coff.dat, clear * X-factor model matrix a=(-.3122817, -.6476055,-2.076853,.1265304,1.521768,1.204662,1.094804,/* */ .9655845,.5079313,-.5094916,1.723556,.1910858,-1.71689,-1.108429,-.6040595,.086756) cons def 1 [id1_1]brand1=1 eq load: brand1 brand2 cap1 cap2 price1 price2 therm filter gllamm alt brand1 brand2 cap1 cap2 price1 price2 therm filter, i(id) /* */ nocons l(mlogit) f(binom) expand(ind ch o) nrf(1) eqs(load) /* */ constr(1) frload(1) trace from(a) copy nip(12) adapt * predictions use coffp, clear gllapred p2, mu marg fsample save coffp, replace log close exit