# st: simulating choices for nested logit

 From "Bo Cutter" To Subject st: simulating choices for nested logit Date Thu, 17 Jun 2004 09:44:40 -0700

```I want to find standard errors for the number of people who make each of the
1st level nest choices in a 2-level nested logit.  I used the simulate
command to do this by first drawing from the covariance matrix generated by
the nested logit model using the drawnorm command, then generating predicted
probabilities using the generated set of coefficients, and then adding them
up across all people.  I tested my program which generates the predicted
probabilities against the Stata command and it matches up exactly.  However,
when I run the simulation, the means of the simulation does not equal the
choice numbers generated from the Stata predict command.

I.e. sum of predicted for three nests is:

. predict double  p_act, p1;

. tabstat p_act if (choice==1|choice==8|choice==13),by(choice) s(sum);
(I am summing over one choice in each nest)

Summary for variables: p_act
by categories of: choice

nest |       sum
---------+----------
1 |  278.3562
2 |  60.31723
3 |  182.3266
---------+----------
Total |       521
--------------------
my probability prediction program matches this (as well as the individual
probabilities) when using the identical coefficients
the relevant command is:

tabstat `tempprob' if (choice==1|choice==8|choice==13),by(choice) s(sum)save

where `tempprob' is the variable that holds the first-level nest choice
probabilities (and the saved results are what I assign to my return
scalars).

, but the mean of the simulation (2000 draws) is:

nest    mean

1	278.89
2	70.78
3	171.62

I expected the mean of the simulation to match up to the predicted choices
from the Stata command, is there a theoretical reason they might not match?
I also saved the coefficient draws from the simulation, and their means
match the nested logit coefficient vector almost exactly, so there is
nothing wrong there.

Thanks,

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```