Announcement

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

  • Generating one categorical variable from the multiple response variable

    Hi Family,
    I trust everyone is doing well.
    I have a data set that contains multiple response with 7 choices each as a variable with dummy response.

    The seven Items under the multiple response are;
    Rice
    Sorghum
    Millet
    Maize
    Tomatoes
    Bana or plantain
    Shea butter.

    During the data collection, there is this indicator of interest that I am trying to measure called the type of value chain, but unfortunately, we could not categorically include to that question to allow the respondent to choose the main type of value chain they do.
    We want to find know and categorize them into.
    Type of Value chain
    1. Cereal
    2. Vegetables
    3. Shea butter

    NB: Per this context
    Cereal= = Rice, Sorghum, millet, and Maize
    Vegetable = tomatoes. Banana or plantain
    Shea nut= = Shea butter



    So I want to use the multiple-choice response to generate the "type of value chain" to recover my indicator.

    I will be very grateful if anyone can help me resolve this issue.

    My God continue to bless us all.

    Thank you.
    Sham.
    This is a sample data below for more details.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str9 Whatisyourgender str89 Various_agric_value_chain double(vc_activity3 vc_activity6 vc_activity7 vc_activity9 vc_activity10 vc_activity11 vc_activity16 vc_activity17 vc_activity20)
    "b) Female" "t) Tomatoes"                                                                           0 0 0 0 0 0 0 0 1
    "a) Male"   "t) Tomatoes p) Maize (Corn)"                                                           0 0 0 0 0 0 1 0 1
    "b) Female" "t) Tomatoes"                                                                           0 0 0 0 0 0 0 0 1
    "b) Female" "c) Rice"                                                                               1 0 0 0 0 0 0 0 0
    "a) Male"   "p) Maize (Corn)"                                                                       0 0 0 0 0 0 1 0 0
    "b) Female" "t) Tomatoes"                                                                           0 0 0 0 0 0 0 0 1
    "b) Female" "i) Sorghum"                                                                            0 0 0 1 0 0 0 0 0
    "a) Male"   "t) Tomatoes"                                                                           0 0 0 0 0 0 0 0 1
    "a) Male"   "t) Tomatoes"                                                                           0 0 0 0 0 0 0 0 1
    "b) Female" "u) Other (please specify)"                                                             0 0 0 0 0 0 0 0 0
    "a) Male"   "g) Groundnuts (Peanuts) n) Yams p) Maize (Corn)"                                       0 0 1 0 0 0 1 0 0
    "a) Male"   "n) Yams p) Maize (Corn) h) Cassava"                                                    0 0 0 0 0 0 1 0 0
    "b) Female" "u) Other (please specify)"                                                             0 0 0 0 0 0 0 0 0
    "a) Male"   "p) Maize (Corn)"                                                                       0 0 0 0 0 0 1 0 0
    "a) Male"   "p) Maize (Corn) c) Rice"                                                               1 0 0 0 0 0 1 0 0
    "a) Male"   "c) Rice p) Maize (Corn) u) Other (please specify)"                                     1 0 0 0 0 0 1 0 0
    "a) Male"   "p) Maize (Corn) c) Rice u) Other (please specify)"                                     1 0 0 0 0 0 1 0 0
    "b) Female" "g) Groundnuts (Peanuts) p) Maize (Corn)"                                               0 0 1 0 0 0 1 0 0
    "b) Female" "c) Rice p) Maize (Corn) g) Groundnuts (Peanuts)"                                       1 0 1 0 0 0 1 0 0
    "a) Male"   "p) Maize (Corn) g) Groundnuts (Peanuts) u) Other (please specify)"                     0 0 1 0 0 0 1 0 0
    "b) Female" "g) Groundnuts (Peanuts) h) Cassava p) Maize (Corn)"                                    0 0 1 0 0 0 1 0 0
    "b) Female" "h) Cassava u) Other (please specify) p) Maize (Corn)"                                  0 0 0 0 0 0 1 0 0
    "b) Female" "u) Other (please specify)"                                                             0 0 0 0 0 0 0 0 0
    "a) Male"   "p) Maize (Corn) h) Cassava n) Yams"                                                    0 0 0 0 0 0 1 0 0
    "b) Female" "u) Other (please specify)"                                                             0 0 0 0 0 0 0 0 0
    "b) Female" "g) Groundnuts (Peanuts) n) Yams p) Maize (Corn) t) Tomatoes u) Other (please specify)" 0 0 1 0 0 0 1 0 1
    "b) Female" "u) Other (please specify)"                                                             0 0 0 0 0 0 0 0 0
    "b) Female" "c) Rice"                                                                               1 0 0 0 0 0 0 0 0
    "b) Female" "l) Poultry"                                                                            0 0 0 0 0 0 0 0 0
    end




  • #2
    Your terminology may differ but I regard indicator as implying a (0, 1) variable. It's hard to see how that idea could cover your wants.

    This may help with some technique. See also https://journals.sagepub.com/doi/pdf...36867X19830921

    Code:
    gen Cereal = strpos(lower(Various), "rice") | strpos(lower(Various), "sorghum") | strpos(lower(Various), "millet") | strpos(lower(Various), "maize")

    Comment


    • #3
      Generating one categorical variable from the multiple response variable
      If you think about it logically, this is possible only if the choices are mutually exclusive. This appears not to be the case looking at your responses, e.g.,

      "a) Male" "t) Tomatoes p) Maize (Corn)"

      Comment


      • #4
        Hi Family,
        I thank you all for your support.
        @ Nick You are right about the indicator variable thing. All along, I used to think that an indicator variable is a variable of interest regardless of whether it contained numeric, categorical, or dummy data.

        Thank you for your hint. I think the code really helps.
        God bless us all.
        I have used the code and it helps, so basically I had to create 7 variables based on your assist code to now have;
        1. Cereal only
        2. Vegetables only
        3. Shea only
        4. Cereal and Vegetable
        5. Cereal and shae
        6.Vegetable and shea
        7. ALl(ceral,Vegetable,shea)

        Recoding it at three levels might be a mercy.

        Andrew. Thank you very much for the hint. It is very true.

        I do appreciate it.
        Sham

        Comment


        • #5
          Hi, Shamsudini,
          Stata is not particularly well suited for handling multi-response variables, but as it is a language very open to programming, there are some programs for handling them, such as mrtab (ssc install mrtab) and coin (net sj 15-4 st0416)
          However, if what you need is to obtain three non-mutually exclusive and distinct values of the Type of value chain mult-variable, I would recommend the use of the egen command as follows:
          Code:
          rename (vc_activity3-vc_activity20)(rice nothing1 nuts sorghum nothing2 nothing3 maize nothing4 tomatoes)
          egen cereal=rowmax(rice sorghum maize)
          egen vegetable=rowmax(tomatoes)
          egen sheanut=rowmax(nuts)
          mrtab cereal vegetable sheanut
          coin cereal vegetable sheanut, frequencies vertical
          Note that I rename vc_activity6, vc_activity10 and vc_activity11 as nothing1 nothing2 and nothing3 because I don't know the commodity of these columns.

          Comment


          • #6
            Hi Modesto,
            Waoo! this code is equally very useful.

            Thank you soo much for your support.
            I am forever grateful to all of you for paying detail attention to my challenges and swiftly feed back
            I really appreciate.

            Sham.

            Comment

            Working...
            X