Announcement

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

  • no variation in the outcome variable in xtmlogit

    Dear all,
    I'm using Stata 17 xtmlogit.
    I have a dataset of 55 individuals, each making six repeated choice tasks, between regular face mask=1, cloth face mask=2, and Nano mask=3. 35 individuals chose, the same type of mask in all tasks. However, while the DV doesn't vary the IVs (which are the attributes of the alternatives) do vary.
    The problem is that 35 groups (210 obs) were omitted because of no variation in the outcome variable over time.
    I'm not sure if I'm using the correct model.
    I have attached a sample of 10 respondents using dataex, I hope I could get some advice.
    regards,
    Anat

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(id chosen_alt reject_virus) float virus_effctive byte(desgin_level price_month)
     1 3 1 .95 2 35
     1 3 1 .95 2 35
     1 3 1 .95 2 35
     1 3 1 .99 1 30
     1 3 1 .99 2 25
     1 3 1  .9 1 35
     2 3 1 .95 2 35
     2 3 1 .95 2 35
     2 3 1 .95 2 35
     2 3 1 .99 1 30
     2 3 1 .99 2 25
     2 3 1  .9 1 35
     3 1 0  .9 1 25
     3 1 0 .85 1 15
     3 1 0 .85 1 15
     3 1 0  .9 1 15
     3 1 0  .9 1 20
     3 1 0  .9 1 25
     4 3 1 .95 2 35
     4 3 1 .95 2 35
     4 3 1 .95 2 35
     4 3 1 .99 1 30
     4 3 1 .99 2 25
     4 3 1  .9 1 35
     5 3 1 .95 2 35
     5 3 1 .95 2 35
     5 2 0  .9 1 20
     5 3 1 .99 1 30
     5 3 1 .99 2 25
     5 2 0  .8 2 20
     6 3 1 .95 2 35
     6 3 1 .95 2 35
     6 2 0  .9 1 20
     6 3 1 .99 1 30
     6 3 1 .99 2 25
     6 3 1  .9 1 35
     7 2 0  .7 1 15
     7 1 0 .85 1 15
     7 1 0 .85 1 15
     7 1 0  .9 1 15
     7 3 1 .99 2 25
     7 2 0  .8 2 20
     8 1 0  .9 1 25
     8 1 0 .85 1 15
     8 1 0 .85 1 15
     8 1 0  .9 1 15
     8 1 0  .9 1 20
     8 1 0  .9 1 25
     9 3 1 .95 2 35
     9 3 1 .95 2 35
     9 2 0  .9 1 20
     9 3 1 .99 1 30
     9 3 1 .99 2 25
     9 3 1  .9 1 35
    10 3 1 .95 2 35
    10 3 1 .95 2 35
    10 3 1 .95 2 35
    10 3 1 .99 1 30
    10 3 1 .99 2 25
    10 3 1  .9 1 35
    end

  • #2
    Anat:
    a possible cause of the drawback is the insufficient variation in the variable pattern of your observations.
    If we take -id-=1 and investigate the number of very same repetitions in both regressand and predictors via -group- function available from -egen-, we obtain:
    Code:
    . egen wanted=group( id chosen_alt reject_virus virus_effctive desgin_level price_month ) if id==1
    (54 missing values generated)
    
    . list id chosen_alt reject_virus virus_effctive desgin_level price_month wanted if id==1
    
         +--------------------------------------------------------------------+
         | id   chosen~t   reject~s   virus_~e   desgin~l   price_~h   wanted |
         |--------------------------------------------------------------------|
      1. |  1          3          1        .99          2         25        4 |
      2. |  1          3          1         .9          1         35        1 |
      3. |  1          3          1        .95          2         35        2 |
      4. |  1          3          1        .95          2         35        2 |
      5. |  1          3          1        .99          1         30        3 |
         |--------------------------------------------------------------------|
      6. |  1          3          1        .95          2         35        2 |
         +--------------------------------------------------------------------+
    
    .
    As we can see, for 3 out of 6 observations, the variable pattern is absolutely the same (see -wanted- #2).
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Originally posted by Anat Tchetchik View Post
      I'm using Stata 17 xtmlogit.
      I have a dataset of 55 individuals, each making six repeated choice tasks, between regular face mask=1, cloth face mask=2, and Nano mask=3. 35 individuals chose, the same type of mask in all tasks. However, while the DV doesn't vary the IVs (which are the attributes of the alternatives) do vary.
      The problem is that 35 groups (210 obs) were omitted because of no variation in the outcome variable over time.
      To add onto Carlo's advice, this will happen with the fixed effects estimator as there is no within variation for the 35 individuals. But you should still get estimates using the subsample of 20 individuals who have at least one switch in the outcome. For experimental studies, there is a good chance that you fail to reject the random effects assumption. Therefore, you should also estimate a random effects model and compare the coefficients with the fixed effects estimates using a Hausman test. The good news is that the random effects estimator is efficient in the case that it is consistent. Therefore, it will allow you to use the entire sample.

      Comment


      • #4
        Thank you very much Andrew Musau and Carlo Lazzaro. your replies are very helpful!

        Comment


        • #5
          Carlo Lazzaro as per your example, I am trying to locate all identical observations (which are typos) using the following code to loop the -egen- command over all obs. The code does not work,
          I can't figure out what is the problem..
          Code:
          foreach v of var id  {
                egen wanted_`v' = group(id chosen_alt reject_virus eco_friendly virus_effctive safety_level desgin_level confort_level price_month ) if id==`v'
              
          }

          Comment


          • #6
            These are duplicates, which you can tag using the duplicates command. Alternatively, from #1:

            Code:
            bys *: gen tag= _N>1
            l if tag, sepby(*)
            If you want to specify a subset of variables, replace "*" with the variable list. (Note that you may have misspelled comfort in #5).

            Res.:

            Code:
            
            . bys *: gen tag= _N>1
            
            . l if tag, sepby(*)
            
                 +-----------------------------------------------------------------+
                 | id   chosen~t   reject~s   virus_~e   desgin~l   price_~h   tag |
                 |-----------------------------------------------------------------|
              2. |  1          3          1        .95          2         35     1 |
              3. |  1          3          1        .95          2         35     1 |
              4. |  1          3          1        .95          2         35     1 |
                 |-----------------------------------------------------------------|
              8. |  2          3          1        .95          2         35     1 |
              9. |  2          3          1        .95          2         35     1 |
             10. |  2          3          1        .95          2         35     1 |
                 |-----------------------------------------------------------------|
             13. |  3          1          0        .85          1         15     1 |
             14. |  3          1          0        .85          1         15     1 |
                 |-----------------------------------------------------------------|
             17. |  3          1          0         .9          1         25     1 |
             18. |  3          1          0         .9          1         25     1 |
                 |-----------------------------------------------------------------|
             20. |  4          3          1        .95          2         35     1 |
             21. |  4          3          1        .95          2         35     1 |
             22. |  4          3          1        .95          2         35     1 |
                 |-----------------------------------------------------------------|
             27. |  5          3          1        .95          2         35     1 |
             28. |  5          3          1        .95          2         35     1 |
                 |-----------------------------------------------------------------|
             33. |  6          3          1        .95          2         35     1 |
             34. |  6          3          1        .95          2         35     1 |
                 |-----------------------------------------------------------------|
             37. |  7          1          0        .85          1         15     1 |
             38. |  7          1          0        .85          1         15     1 |
                 |-----------------------------------------------------------------|
             43. |  8          1          0        .85          1         15     1 |
             44. |  8          1          0        .85          1         15     1 |
                 |-----------------------------------------------------------------|
             47. |  8          1          0         .9          1         25     1 |
             48. |  8          1          0         .9          1         25     1 |
                 |-----------------------------------------------------------------|
             51. |  9          3          1        .95          2         35     1 |
             52. |  9          3          1        .95          2         35     1 |
                 |-----------------------------------------------------------------|
             56. | 10          3          1        .95          2         35     1 |
             57. | 10          3          1        .95          2         35     1 |
             58. | 10          3          1        .95          2         35     1 |
                 +-----------------------------------------------------------------+

            Comment


            • #7
              Thank so much @Andrew Musau

              Comment

              Working...
              X