Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scrambled Halton draws with -mixlogit-

    Dear all,

    I was wondering if there is a way to induce the user-written command -mixlogit- by Hole (2007) to use ''scrambled Halton draws'' to overcome the problem of highly correlated sequences in case of high dimensional integrations?

    Thank you for your help in advance,
    Emma

  • #2
    Hi Emma,

    Yes, it is possible by using a combination of the "userdraws" option of mixlogit (for using a matrix of user-specified draws) and Stanislav Kolenikov's Mata function for generating scrambled Halton draws. See the final example below:

    Code:
    discard
    use "http://fmwww.bc.edu/repec/bocode/t/traindata.dta", clear
    
    /* Example using Halton draws */
    
    * Define matrix of user-specified draws
    * The matrix should have number of rows equal to the number of random coefficients in the model
    * and number of columns equal to the number of respondents times the number of draws per respondent
    
    mata: nrep = 500
    mata: krnd = 5
    mata: burn = 16
    mata: nresp = 100
    
    mata: mixl_USERDRAWS = halton(nrep*nresp,krnd,burn)'
    
    mixlogit y price, group(gid) id(pid) rand(contract local wknown tod seasonal) nrep(500) userdraws
    
    * replicate using standard mixlogit syntax
    mixlogit y price, group(gid) id(pid) rand(contract local wknown tod seasonal) nrep(500)
    
    /* Example using pseudorandom draws */
    
    mata: rseed(12345)
    mata: mixl_USERDRAWS = runiform(krnd,nrep*nresp)
    
    mixlogit y price, group(gid) id(pid) rand(contract local wknown tod seasonal) nrep(500) userdraws
    
    /* Example using scrambled Halton draws */
    
    capture mata: mata drop SqrtScrambler()
    
    mata:
    real scalar SqrtScrambler(real scalar k, real scalar b,real scalar j) {
        return(mod(k*floor(sqrt(b)), b))
    }
    end
    
    mata: mixl_USERDRAWS = ScrHalton(nrep*nresp,krnd,&SqrtScrambler())'
    
    mixlogit y price, group(gid) id(pid) rand(contract local wknown tod seasonal) nrep(500) userdraws
    Last edited by Arne Risa Hole; 29 Oct 2019, 08:50.

    Comment


    • #3
      Thank you very much for your help,

      Best regards,
      Emma

      Comment

      Working...
      X