Announcement

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

  • [mixlogit] constraint in the parameters distribution

    Dear all,

    I'm using the 'mixlogit' command to estimate a RPL model. I want to put interactions to a variable that is random, with a parameter with a log-normal distribution. But I want the interactions to be fixed. However, I need their parameters to be log-normal, to be sure that when adding to the random variable that has a log-normal parameter, the values are still positive.

    I didn't find a straight way to restrict parameters distribution (neither in this command or anywhere in stata). I find a way following an answer by Arne Risa Hole (author on -mixlogit- ) to how to constraint parameter values, that was very useful. Following that, I constructed the example below to my end, but I wander if that is the right way to do it. Any advice is very welcome.

    Code:
     use http://fmwww.bc.edu/repec/bocode/t/traindata.dta  *this inverts price variable, because I will want to put it log-norma gen mprice=-1*price  *this creates a variable that vary by individual, but not by option attribute. That is, is an observed feature of the individual gen obs_feat = rnormal() bysort pid: replace obs_feat= obs_feat[1]  *generate the interaction of the price and the observed feature  gen int1=mprice*obs_feat  gen int2=price*obs_feat  * Define constraints constraint 1 [SD]int1 = 0  * Generate starting values clogit y contract local wknown int2 price , group(gid) matrix start = e(b),0,0,0,0,0  * Run mixed logit model mixlogit y , group(gid) id(pid) /// rand(contract local wknown int1 mprice) constraints(1) ln(2) from(start, copy)


    thanks,
    Matías


  • #2
    Here is a more friendly view of the code. Sorry for the mistake before:

    Code:
    use http://fmwww.bc.edu/repec/bocode/t/traindata.dta
    
    *this inverts price variable, because I will want to put it log-normal
    gen mprice=-1*price
    
    *this creates a variable that vary by individual, but not by option attribute. That is, is an observed ///
    *feature of the individual
    gen obs_feat = rnormal()
    bysort pid: replace obs_feat= obs_feat[1]
    
    *generate the interaction of the price and the observed feature
    
    gen int1=mprice*obs_feat
    
    gen int2=price*obs_feat
    
    * Define constraints
    constraint 1 [SD]int1 = 0
    
    * Generate starting values
    clogit y contract local wknown int2 price , group(gid)
    matrix start = e(b),0,0,0,0,0
    
    * Run mixed logit model
    mixlogit y , group(gid) id(pid) ///
    rand(contract local wknown int1 mprice) constraints(1) ln(2) from(start, copy)

    Comment


    • #3
      Have you solved the problem? I have the same problem at the moment.

      Comment


      • #4
        Hi Laura, sorry for the late reply. Not really, end up using a simpler model. Any suggestions is welcome, I'm still curious about how this issue is handled

        Comment

        Working...
        X