Announcement

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

  • Specifying Categorical Variables in Multivariate Probit Analysis

    I am running a multivariate probit (MVP) model, but when it comes to categorical variables, Stata treats them as continuous variables. Let's take the example of 'Education Level,' which has 5 categories. However, when I run the command, it only brings a single coefficient despite labeling and variable management efforts. I have tried using the 'i' prefix, but it is also not working. What is the best way to treat categorical variables when running a multivariate probit?

  • #2
    I have tried using the 'i' prefix, but it is also not working. What is the best way to treat categorical variables when running a multivariate probit?
    Unless you are using some truly ancient version of Stata, this should do what you need. So either there is something wrong with the way you are doing it, or there is something about your data that is unsuitable. Since you show neither the code you have tried nor the data, however, it is anybody's guess what the problem might be.

    So please post back. Tell us which version of Stata you are using. Show the exact code you tried and also show the output that Stata gave you. Do this exactly by copy/pasting directly from the Results window or your log file directly into the Forum editor. Enclose it between code delimiters so it is readable. (If you are not familiar with code delimiters, read the Forum FAQ for instructions.) Also show example data that exhibits this same problem. Do that by using the -dataex- commands so that whoever responds can import your data readily and test possible solutions to your problem. If you are running version 18, 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Comment


    • #3
      Thanks a lot Clyde for replying. I am actually usingStata version 17. with the below command
      Code:
      mvprobit (Pests = Age Sex EducationLevel Fexperience Landsize AccesstoCWI Farmincome Offfarmincome experiencewithCR BeliefthatCRaredangerus) (Diseases = Age Sex EducationLevel Fexperience Landsize AccesstoCWI Farmincome Offfarmincome experiencewithCR BeliefthatCRaredangerus) (Floods = Age Sex EducationLevel Fexperience Landsize AccesstoCWI Farmincome Offfarmincome experiencewithCR BeliefthatCRaredangerus) (Droughts = Age Sex EducationLevel Fexperience Landsize AccesstoCWI Farmincome Offfarmincome experiencewithCR BeliefthatCRaredangerus) (Climatechanges = Age Sex EducationLevel Fexperience Landsize AccesstoCWI Farmincome Offfarmincome experiencewithCR BeliefthatCRaredangerus)
      and when i add the "i" preefix on Education Level" its replys *factor-variable and time-series operators not allowed*

      My data looks like below:
      -----------------------
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input byte(Pests Diseases Floods Droughts Climatechanges Age Sex EducationLevel Fexperience) double Landsize byte AccesstoCWI long(Farmincome Offfarmincome) byte(experiencewithCR BeliefthatCRaredangerus)
      1 1 0 1 1 35 1 3  8    3 1 4000000  600000 1 1
      1 1 1 0 1 42 0 2  4    8 0  850000  520000 1 0
      1 0 1 1 1 56 0 3  9    6 1  400000 1000000 1 1
      1 1 0 1 1 30 1 5 14   .5 1 3800000  460000 1 0
      1 1 1 1 1 63 0 2  5    7 1 3800000 2100000 1 1
      1 1 1 0 1 49 0 3  7    6 1 1100000  980000 1 0
      1 1 1 1 1 35 1 3 12   .5 1 2300000  780000 0 1
      1 1 0 0 0 51 0 1  6    5 1  790000  610000 1 0
      1 1 1 1 1 28 0 3  8    8 1 4600000 2400000 0 0
      1 1 1 1 1 59 0 3 10    5 1 4500000  380000 0 1
      1 1 1 1 1 46 0 2 13    1 1 2100000 2300000 0 0
      1 1 0 1 1 32 0 3 15    7 1 3000000  560000 1 1
      1 0 1 1 1 61 1 3 11    7 1  850000 2800000 0 1
      1 1 1 1 1 54 0 3  8    5 1  940000  650000 0 0
      1 1 0 1 1 41 0 2  9    2 1 2500000 1900000 0 1
      1 1 1 1 1 29 0 2  4    3 1 2000000  340000 0 0
      1 1 1 0 1 58 1 1 10   12 0 4300000 2600000 1 0
      0 1 1 1 1 37 1 4  7    4 1  580000  270000 0 1
      1 1 1 1 1 45 0 3  5   10 1 2800000 1700000 0 1
      1 0 1 0 1 60 0 2  8   .5 1 3000000  910000 1 0
      0 1 0 1 1 48 0 3  6    2 1 5000000 2000000 0 1
      1 1 1 1 1 33 1 4  9    5 1  690000  720000 0 1
      0 1 1 1 1 62 0 4 12    1 1 2000000 1300000 0 0
      1 1 1 0 1 31 0 2 10    7 1  460000  240000 1 1
      1 0 0 0 1 50 0 2  8   .5 1 3500000 2200000 0 0
      1 0 1 0 1 64 0 2 13    4 1  810000  550000 1 0
      0 1 0 1 1 43 0 3  7    1 1 2200000 1600000 0 1
      1 1 1 1 1 55 1 3  5    5 1 2900000  470000 0 1
      0 1 1 1 1 36 0 2 14    4 1 4800000 2500000 0 1
      1 1 1 0 1 53 0 2  8   .5 1  640000  830000 0 0
      1 1 1 1 1 39 0 1  6    6 1 1900000 1100000 0 1
      1 0 1 1 1 28 0 2 11    2 1 4300000  300000 0 0
      1 1 1 1 1 57 0 2  9    9 1 3500000 2900000 0 1
      1 0 1 1 1 47 1 2 10    6 1  940000  780000 1 0
      0 0 1 0 1 34 0 2  8    1 1  900000 1800000 0 0
      0 0 1 0 1 52 0 1 15 10.5 1  240000  410000 1 1
      1 1 1 1 1 40 0 3  7   .5 1 4400000 2700000 1 1
      1 1 1 0 1 44 0 2  9    4 1 2500000  600000 1 1
      0 1 1 0 1 38 0 1  4    2 0 2900000 1400000 1 0
      0 1 1 1 1 30 0 4 12    8 1  720000  390000 0 1
      0 1 1 1 1 59 1 3 10    2 1 1800000 2400000 1 0
      1 0 0 0 1 35 0 2  8    3 1 2600000  760000 1 1
      1 1 1 1 1 61 0 3 11    5 1 3300000 1200000 1 0
      0 1 1 0 1 52 0 2  7   .5 1  860000  290000 0 1
      1 0 0 1 1 56 0 3 13    7 1 1500000 2100000 1 1
      0 1 0 0 1 45 0 2  9    8 1  420000  570000 1 0
      1 1 1 0 1 29 0 2  6    2 1 4200000 1500000 1 1
      1 1 1 1 1 63 0 3  8   .5 1  610000  450000 1 1
      0 1 1 0 1 31 0 2  5    5 1 1700000 2300000 0 1
      1 1 1 1 1 58 0 2 14    1 1  280000  710000 1 1
      1 1 1 0 1 62 0 2 10    4 1 3900000 1000000 0 0
      0 1 1 0 1 49 0 3  7    3 1  980000  320000 0 0
      1 1 1 1 1 54 1 2 12   .5 1 2100000 2800000 0 1
      1 1 0 0 1 37 0 2  8    5 1  460000  950000 0 0
      0 1 0 1 1 32 0 2  7    8 1 4500000 1900000 0 1
      0 1 1 1 0 47 0 3  5    2 1  500000  430000 1 1
      1 0 1 0 1 33 0 3  8    7 0 1200000 2600000 1 1
      1 1 0 1 0 64 1 2  7    4 1  340000  880000 0 0
      0 1 1 0 0 46 0 3  4    1 1 1000000 1700000 0 1
      1 1 0 0 1 42 0 2  7    6 0  880000  510000 1 1
      0 0 1 0 1 53 0 2  6   .5 1 1100000 2200000 0 0
      1 1 1 0 1 38 0 2  6    7 0  670000  740000 0 1
      1 0 1 0 1 55 1 2  8    3 1 4700000 1100000 0 1
      0 0 1 0 1 43 1 3  3    5 1  730000  350000 1 1
      0 0 1 0 1 60 1 5  8    1 1 1500000 2500000 0 1
      0 1 1 0 1 34 1 2  5    7 1  400000  820000 1 1
      0 1 1 0 1 51 1 2  7    2 1 3400000 1600000 0 0
      0 0 1 1 0 48 0 2  7    3 1  930000  400000 1 1
      1 0 1 0 0 50 0 3 12    4 0  800000 2300000 0 1
      1 0 1 1 1 57 0 3 10   .5 1 4600000  690000 1 1
      1 0 1 1 1 41 0 3  9    5 1 4300000 1300000 1 1
      1 1 1 1 1 44 0 2  8    1 1 4200000  530000 1 1
      0 0 0 0 0 39 0 3  6    3 1  500000 2000000 0 1
      0 1 1 0 1 36 0 2  8    4 1  320000  770000 1 1
      1 1 1 0 1 28 1 3  6    5 1 3200000 1500000 1 1
      1 1 1 0 1 59 1 2 11   .5 1  950000  370000 1 1
      0 1 0 1 1 62 1 2  8    2 0 2200000 2100000 0 1
      1 1 1 0 1 56 1 2  7    8 1  430000  610000 1 1
      1 0 0 1 1 63 1 2 15    4 0 4000000 1200000 1 1
      0 1 0 0 1 45 1 2  7    1 1  510000  260000 0 1
      0 1 1 0 1 34 1 2  6    9 1 1300000 2400000 0 1
      0 1 0 1 0 45 1 3  8    7 0  260000  920000 0 1
      0 0 0 1 0 60 0 5  4   .5 0 1200000 1700000 1 0
      0 1 1 1 1 52 0 2  3    4 1 3800000  440000 1 1
      1 1 1 0 0 30 0 3  5    1 1  800000 2800000 0 1
      0 0 1 1 1 61 0 2  7    7 0 3900000  750000 1 1
      1 1 1 1 0 33 0 2 13    2 1  400000 1400000 1 0
      1 1 0 1 1 53 0 3  8    7 1 4200000  280000 1 1
      1 1 1 0 1 58 0 3  6   .5 1 1200000 2200000 1 1
      1 1 0 0 1 52 1 2  9    5 1  370000  630000 1 1
      0 1 1 0 1 57 0 2  5    1 1 3000000 1000000 0 1
      0 1 1 0 1 42 1 3  7    6 1  920000  310000 0 1
      1 1 1 1 1 49 0 2 10    3 1 3000000 2600000 1 1
      1 1 1 0 1 46 0 2  8    7 0  310000  860000 1 1
      0 1 1 1 1 54 1 3  3   .5 1 3800000 1600000 0 1
      0 1 1 1 1 64 1 2  7    4 1 4200000  470000 0 1
      1 1 1 1 0 47 1 3  7    2 0  900000 2000000 0 1
      0 1 1 1 0 37 1 2  6    3 0  450000  790000 1 0
      0 0 1 1 1 48 1 2  9    1 1 2800000 1500000 0 0
      1 1 1 1 0 46 1 2  8    1 0  950000  330000 0 0
      end
      label values EducationLevel Edulevel
      label def Edulevel 1 "No Formal Education", modify
      label def Edulevel 2 "Primary Education", modify
      label def Edulevel 3 "Secondary Education", modify
      label def Edulevel 4 "Vocational Education", modify
      label def Edulevel 5 "University Education", modify
      ------------------

      Looking forward to hearing from you soon. Thanks

      Comment


      • #4
        OK. The problem is that -mvprobit-, in its latest version (and maybe you even have an earlier version than that) dates back to 2006 which is long before Stata introduced factor-variable notation. So this is one of those increasingly rare situations where using -xi:- will bail you out. Put an i. prefix in front of each of the variables you want treated as discrete, and precede the entire command with -xi:-. Alternatively, and I think more work than is warranted, you can just create a family of indicator variables for each of your discrete variables and then put those into the command (omitting one as the reference category in each case) in lieu of the original ones.

        Comment


        • #5
          Thanks comrade, i think creating a family of indicator variables for each discrete variables works well. Thanks again, you are the best.

          Comment

          Working...
          X