Announcement

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

  • how to generate group and choice variables in mixlogit

    Hi,everyone,
    I need to use mixlogit to excuete the random coefficent model,but the data has no choice and group as required by mixlogit.How can I generate these variables based on thechoice brand1-brand4?
    clear
    input byte PanID double Expend byte(Income HHSize) int IPT byte(Quantity Brand1 Brand2 Brand3 Brand4 Feature1 Feature2 Feature3 Feature4) double(Price1 Price2 Price3 Price4) byte PanelistFirstObs
    1 40.900002 9 2 5 2 0 0 0 1 0 0 0 0 .108 .081 .061000001 .079000004 1
    1 16.809999 9 2 5 2 0 1 0 0 0 0 0 0 .108 .097999997 .064000003 .075000003 0
    1 4.0599999 9 2 1 2 0 1 0 0 0 0 0 0 .108 .097999997 .061000001 .086000003 0
    2 24.43 7 2 3 2 0 0 0 1 0 0 0 0 .108 .081 .050000001 .079000004 0
    2 16.49 7 2 1 4 0 0 0 1 0 0 0 0 .108 .081 .050000001 .081 0
    2 4.2600002 7 2 1 4 0 0 0 1 0 0 0 0 .108 .081 .050000001 .079000004 0
    end
    Thanks a lot!

  • #2
    Is there a reason the data sample here has fewer observations for each of your two IDs than did your earlier post at

    https://www.statalist.org/forums/for...up-in-mixlogit

    Comment


    • #3
      The data should be like this :
      clear

      input byte PanID double Expend byte(Income HHSize) int IPT byte(Quantity Brand1 Brand2 Brand3 Brand4 Feature1 Feature2 Feature3 Feature4) double(Price1 Price2 Price3 Price4) byte PanelistFirstObs

      1 40.900002 9 2 5 2 0 0 0 1 0 0 0 0 .108 .081 .061000001 .079000004 1

      1 16.809999 9 2 5 2 0 1 0 0 0 0 0 0 .108 .097999997 .064000003 .075000003 0

      1 4.0599999 9 2 1 2 0 1 0 0 0 0 0 0 .108 .097999997 .061000001 .086000003 0

      1 34.459999 9 2 4 2 0 1 0 0 0 0 0 0 .108 .097999997 .061000001 .086000003 0

      1 8.3900003 9 2 7 2 0 1 0 0 0 0 0 0 .125 .097999997 .048999999 .079000004 0

      1 60.990002 9 2 3 2 0 1 0 0 0 0 0 0 .108 .092 .050000001 .079000004 0

      1 20.790001 9 2 4 1 0 1 0 0 0 0 0 0 .103 .081 .048999999 .079000004 0

      1 33.950001 9 2 8 2 0 0 0 1 0 0 0 0 .108 .086000003 .054000001 .079000004 0

      2 3.6900001 7 2 5 1 1 0 0 0 0 0 0 0 .108 .097999997 .050000001 .079000004 1

      2 50.93 7 2 2 1 1 0 0 0 0 0 0 0 .108 .097999997 .050000001 .079000004 0

      2 18.35 7 2 2 1 1 0 0 0 0 0 0 0 .108 .097999997 .050000001 .079000004 0

      2 31.91 7 2 2 1 1 0 0 0 0 0 0 0 .108 .097999997 .050000001 .079000004 0

      2 25.27 7 2 2 6 0 0 0 1 0 0 0 0 .108 .081 .050000001 .086000003 0

      2 35.700001 7 2 2 2 0 0 0 1 0 0 0 0 .108 .081 .050000001 .086000003 0

      2 30.65 7 2 4 2 0 0 0 1 0 0 0 0 .108 .081 .050000001 .079000004 0

      2 58.259998 7 2 2 8 0 0 0 1 0 0 0 0 .108 .081 .050000001 .079000004 0

      2 24.459999 7 2 3 8 0 0 0 1 0 0 0 0 .108 .081 .050000001 .079000004 0

      2 46.73 7 2 7 6 0 0 0 1 0 0 0 0 .108 .081 .050000001 .079000004 0

      2 24.43 7 2 3 2 0 0 0 1 0 0 0 0 .108 .081 .050000001 .079000004 0

      2 16.49 7 2 1 4 0 0 0 1 0 0 0 0 .108 .081 .050000001 .081 0

      2 4.2600002 7 2 1 4 0 0 0 1 0 0 0 0 .108 .081 .050000001 .079000004 0

      2 67.230003 7 2 3 2 0 0 0 1 0 0 0 0 .108 .081 .050000001 .079000004 0

      2 15.14 7 2 1 2 0 0 0 1 0 0 0 0 .108 .081 .050000001 .079000004 0

      2 27.440001 7 2 5 7 0 0 0 1 0 0 0 0 .108 .081 .050000001 .081 0

      Thanks a lot!

      Comment


      • #4
        The data should be :https://www.statalist.org/forums/for...up-in-mixlogit

        Comment

        Working...
        X