1

I'm trying to simulate data that can be estimated using a nested logit model. If epsilon is distributed nested logit with a nesting structure $B_1, ..., B_K $, and nesting parameters $\lambda_1, ... \lambda_K$ then the CDF of epsilon is

enter image description here

I am looking for a way of simulating random deviates from this distribution in R. The package evd does not allow the user to specify a particular nesting structure. Clearly, the inverse CDF method won't work here, either.

Any advice would be greatly appreciated.

EB727
  • 43
  • 5
  • Thanks, I looked there and it appears that someone had already asked this [question](https://stats.stackexchange.com/questions/422092/simulating-draws-of-multivariate-ev-type-distribution) which was never answered. – EB727 Feb 21 '22 at 00:56

1 Answers1

1

In fact, EVD does allow users to simulate nested logit deviates. The function is rmvevd (random multivariate EVD). The documentation provides an example of how to simulate deviates from the multivariate EVD, but it's a little cumbersome, so I'll provide an example for a simple nested logit problem.

D = 4 alternatives, alternative 1 is in nest 1; alternatives 2,3,4 are in nest 2.

lambda_2 = 0.5 is the nesting parameter.

B = the set of all possible sets that can be formed from the 4 alternatives: (B = {1}, {2}, {3}, {4}, {1,2} {1,3}, {1,4}, {2,3}, {2,4} {3,4}, {1,2,3}, {1,2,4}, {1,3,4}, {2,3,4}, {1,2,3,4})

mvevd requires the user to specify the arguments dep and asy. dep is a vector of nesting parameters on the sets in B of length 2 or greater. asy (in the nested logit example) is a list that specifies the nesting structure. In the example here asy will be vector of 1s in the 1st and 14th entries (corresponding to alternative 1 in its own group, and alternatives 2,3,4 in group 2). dep will have a 1 in all entries except for the 10th entry, which will equal lambda_2 (as {2,3,4} is the 10th element of B that is not of unit length). A code example to simulate 10 4-d nested logit deviates according to this example is as follows:

library('evd')
vdep <- c(rep(1,9), lambda, 1)
asy_list <- list(1, 0, 0, 0, c(0,0), c(0,0), c(0,0), c(0,0), c(0,0), c(0,0),
            c(0,0,0), c(0,0,0), c(0,0,0), c(1,1,1), c(0,0,0,0))
deviates <- rmvevd(10, dep = vdep, asy = asy_list, model = "alog", d = 4)
EB727
  • 43
  • 5