Announcement

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

  • Choice models

    I have this example data that I have reshaped from wide to long. I want to use it to compare different choice models, specifically, the multinomial probit, mixed logit model, and random parameter model. The problem is that I keep getting the error "depvar choice must be a 0/1 variable indicating which alternatives are chosen." I would appreciate some assistance.[
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(cost indemnity diseaseuncertainty) str17 responseid long choice str7 alternative2
    1.5               .75 0 "R_12c0WhpSacmBfND" 3 "choiceA"
    1.5               .75 0 "R_12c0WhpSacmBfND" 2 "choiceB"
    1.5               .75 0 "R_12c0WhpSacmBfND" 3 "choiceC"
      0               .75 1 "R_130tjeDa0SB0a7n" 2 "choiceA"
      0               .75 1 "R_130tjeDa0SB0a7n" 2 "choiceB"
      0               .75 1 "R_130tjeDa0SB0a7n" 4 "choiceC"
      3 .8999999761581421 0 "R_17ro9DXzTCsyb4d" 3 "choiceA"
      3 .8999999761581421 0 "R_17ro9DXzTCsyb4d" 4 "choiceB"
      3 .8999999761581421 0 "R_17ro9DXzTCsyb4d" 4 "choiceC"
      3 .8999999761581421 0 "R_1B19p1QowTgqSm5" 3 "choiceA"
      3 .8999999761581421 0 "R_1B19p1QowTgqSm5" 4 "choiceB"
      3 .8999999761581421 0 "R_1B19p1QowTgqSm5" 4 "choiceC"
    1.5               .75 0 "R_1H7wPWuH1CbkDmD" 3 "choiceA"
    1.5               .75 0 "R_1H7wPWuH1CbkDmD" 4 "choiceB"
    1.5               .75 0 "R_1H7wPWuH1CbkDmD" 3 "choiceC"
      .                 . . "R_1Ino1LWi1nJIdUn" 3 "choiceA"
      .                 . . "R_1Ino1LWi1nJIdUn" 2 "choiceB"
      .                 . . "R_1Ino1LWi1nJIdUn" 4 "choiceC"
      3 .8999999761581421 0 "R_1JFmXqFfifSI8p2" 3 "choiceA"
      3 .8999999761581421 0 "R_1JFmXqFfifSI8p2" 4 "choiceB"
    end
    label values diseaseuncertainty diseaseuncertainty
    label def diseaseuncertainty 0 "low", modify
    label def diseaseuncertainty 1 "high", modify
    label values choice choice
    label def choice 2 "1", modify
    label def choice 3 "2", modify
    label def choice 4 "3", modify
    ]

  • #2
    It would be helpful if you show the command(s) that generated that error message.
    Devra Golbe
    Professor Emerita, Dept. of Economics
    Hunter College, CUNY

    Comment


    • #3
      sure! this is code.
      "cmmprobit choice cost indemnity diseaseuncertainty"

      Comment


      • #4
        Please see the FAQs about how best to pose a question. If you supply a data example and code, test for yourself that it runs as posted. If I tack the code you just provided onto the code in your first post I get a different error.
        Devra Golbe
        Professor Emerita, Dept. of Economics
        Hunter College, CUNY

        Comment


        • #5
          Thank you Devra,
          This is the error I got when i tried estimating the model.

          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input double(cost indemnity diseaseuncertainty) str17 responseid long choice str7 alternative2
          1.5               .75 0 "R_12c0WhpSacmBfND" 3 "choiceA"
          1.5               .75 0 "R_12c0WhpSacmBfND" 2 "choiceB"
          1.5               .75 0 "R_12c0WhpSacmBfND" 3 "choiceC"
            0               .75 1 "R_130tjeDa0SB0a7n" 2 "choiceA"
            0               .75 1 "R_130tjeDa0SB0a7n" 2 "choiceB"
            0               .75 1 "R_130tjeDa0SB0a7n" 4 "choiceC"
            3 .8999999761581421 0 "R_17ro9DXzTCsyb4d" 3 "choiceA"
            3 .8999999761581421 0 "R_17ro9DXzTCsyb4d" 4 "choiceB"
            3 .8999999761581421 0 "R_17ro9DXzTCsyb4d" 4 "choiceC"
            3 .8999999761581421 0 "R_1B19p1QowTgqSm5" 3 "choiceA"
          end
          label values diseaseuncertainty diseaseuncertainty
          label def diseaseuncertainty 0 "low", modify
          label def diseaseuncertainty 1 "high", modify
          label values choice choice
          label def choice 2 "1", modify
          label def choice 3 "2", modify
          label def choice 4 "3", modify
          ------------------ copy up to and including the previous line ------------------

          Listed 10 out of 231 observations

          . cmmprobit choice cost indemnity diseaseuncertainty
          depvar choice must be a 0/1 variable indicating which alternatives are chosen

          Comment


          • #6
            I can't help thinking you've not shown us exactly [FAQ 12.1] what you typed, because when I type the code you specified in the code block and then the cmmprobit command, the error I get is

            Code:
            cmmprobit choice cost indemnity diseaseuncertainty
            data not cmset
                Use cmset caseidvar ....
            r(459);
            I highly recommend following FAQ 12 in full, especially the part about showing a reproducible example that demonstrates your problem. If you can do so using a publicly available dataset (for instance, the travel dataset used in the cmmprobit manual entry), all the better.
            Devra Golbe
            Professor Emerita, Dept. of Economics
            Hunter College, CUNY

            Comment


            • #7
              As the error message suggests, the variable that indicates chosen alternatives has to be a binary variable that takes on the value 1 if an alternative is chosen, and 0 otherwise. This is not true for the variable choice in your dataset.

              Comment

              Working...
              X