Announcement

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

  • factor variables not allowed r(101) using medeff

    I am trying to use medeff command but there is always this error "factor variables not allowed". I am not sure what is the problem. I will highly appreciate if someone can help me out.

    I use the following code:
    medeff (regress M T x i.year i.ID) (regress Y T M x i.year i.ID) , treat(T) mediate(M) sims(1000) seed(619) vce(cluster ID)

  • #2
    medeff is a user-written command apparently last updated in 2012. It may have been written before factor variable notation existed. Perhaps the program could be tweaked to support FV. I don't know, but it is often a minor tweak. You may just need to create the dummies yourself.

    I normally hate hate hate xi, but in a situation like this it might be handy:

    xi: medeff (regress M T x i.year i.ID) (regress Y T M x i.year i.ID) , treat(T) mediate(M) sims(1000) seed(619) vce(cluster ID)
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://academicweb.nd.edu/~rwilliam/

    Comment


    • #3
      Thank you Richard. Using your most hated tweak "xi" then error message changed to "no room to add more variables. Up to 5,000 variables are currently allowed, although you could reset the maximum using set maxvar; see help memory." Now when I try to increase the maximum variable limit Stata does not allow me to do so, saying "no; data in memory would be lost". Now is this due to a limitation of the computer in which I am running stata? I must mention, the "x" variable is a collection of 12 control variables.

      Comment


      • #4
        How many values do year and id have? All but one of each will count as a variable, so if you have thousands of cases, you have thousands of variables.

        You may need to increase the max before running xi.

        You might also want to generate the vars yourself, e.g.

        tab year, gen(yr)
        tab ID, gen(id)
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://academicweb.nd.edu/~rwilliam/

        Comment


        • #5
          Ok I know what to do now. Thanks

          Comment

          Working...
          X