Hi,
I estimated a mixed logit model via the user written command mixlogit on the data from a discrete choice experiment (DCE).
I need to generate the probabilities of different combinations of levels outside those included in the DCE data. For every combinations I set, I need to generate the corresponding probabilities via mixlpred as a new variable in the data editor.
For this, I am using mixlpred and what described at page 16 and reported below:
uk13_hole.pdf (stata.com)
preserve
set seed 12345
gen rnd = runiform()
bysort pid gid (rnd): gen alt = _n
replace wknown = 0 if alt==1
mixlpred p0, nrep(500)
tabstat p0, statistics( mean)
restore
The code above generate p0 that can be used to produce statistics etc. as shown here. As I need to do this several times, I found particularly useful the use of "preserve" and "restore" as no data are modified. However, using mixlpred within "preserve" and "restore" does not generate any new variable as when I use mixlpred without them.
Any help would be greatly appreciated.
Simone
I estimated a mixed logit model via the user written command mixlogit on the data from a discrete choice experiment (DCE).
I need to generate the probabilities of different combinations of levels outside those included in the DCE data. For every combinations I set, I need to generate the corresponding probabilities via mixlpred as a new variable in the data editor.
For this, I am using mixlpred and what described at page 16 and reported below:
uk13_hole.pdf (stata.com)
preserve
set seed 12345
gen rnd = runiform()
bysort pid gid (rnd): gen alt = _n
replace wknown = 0 if alt==1
mixlpred p0, nrep(500)
tabstat p0, statistics( mean)
restore
The code above generate p0 that can be used to produce statistics etc. as shown here. As I need to do this several times, I found particularly useful the use of "preserve" and "restore" as no data are modified. However, using mixlpred within "preserve" and "restore" does not generate any new variable as when I use mixlpred without them.
Any help would be greatly appreciated.
Simone
Comment