Announcement

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

  • Factor variables and time-series operators not allowed

    Hello,

    I am working on interpreting the interaction term in a logistic difference-in-differences model . For this, I am using the -logit- command followed by the -inteff- command. My logit model has several terms specified as factors variables. When I use the -inteff- command following the -logit- command, I get the "Factor variables and time-series operators not allowed" error message.

    My actual model contains more than 35 variables, several of which are factor variables with more than 2 levels. I am presenting below the code for a simple model. x is binary 0/1, after is binary 0/1, treatment is coded as a categorical variable with 4 categories, year is coded as categorical with 6 categories.

    Code:
    logit x i.after##i.treatment i.year, or
    inteff x .after##i.treatment i.year, savedata(home/logit_inteff,replace) savegraph1(home/logit_inteff, replace) savegraph2(home/logit_inteff2, replace)
    
    Factor variables and time-series operators not allowed
    r(101)
    Is there a way for me to convert the factor variables 'en masse' to dummy variables, or must I do it one variable at a time?

    I am using Stata 13.1 MP on Unix.

    Thank you,
    Caroline



  • #2
    It turns out that inteff is a user-written command from the Stata Journal in 2004. I believe, and others have previously recommended on this list, that the newer margins command, part of the official Stata distribution, is to be preferred. I would suggest that since inteff has not been updated to take advantage of factor variable notation, the authors might be likely to agree that their work has been superceded.

    If you are unfamiliar with the margins command, Richard Williams, an honored contributor to Statalist, has made an excellent introduction to the command and its capabilities available.

    http://www3.nd.edu/~rwilliam/stats/Margins01.pdf

    Comment


    • #3
      Not surprisingly, I agree with William. I also recommend Vince Wiggins' post on marginal effects and interactions:

      http://www.stata.com/statalist/archi.../msg00293.html

      Personally I have never been a fan of the inteff approach. On the other hand I see that the 2004 SJ article on the command has 1200 Google Scholar citations, so I assume somebody must like it. Does anybody want to make a case for the inteff approach?
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

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

      Comment


      • #4
        Thank you William and Richard for your thoughtful suggestions, and directing me to excellent resources.

        Best,
        Caroline

        Comment


        • #5
          The published version of Richard's article can now be downloaded for free:
          http://www.stata-journal.com/article...article=st0260

          Comment


          • #6
            I would like to extend this discussion to interpreting the interaction term in a multilevel logistic model with random effects with the following code. I am using Stata 13.1 MP on Unix:
            Code:
            melogit x i.after##i.treatment i.year ||id:, or
            
            /*Margin: 1*/
            margins r.after
            default prediction is a function of possibly stochastic quantities other than e(b)
            r(498)
            
            /*Margin: 2*/
            margins after, predict(mu)
            prediction is a function of possibly stochastic quantities other than e(b)
            r(498);
            I obtained the code for the first margins command from the Stata 14 highlights website (http://www.stata.com/new-in-stata/marginal-margins/), and the code for the second margins command from a previous discussion on the Statalist (http://www.statalist.org/forums/foru...-after-melogit). However, my guess is that both these will work only on Stata14.

            I then used the approach suggested on the UCLA website (http://www.ats.ucla.edu/stat/stata/f...logit_prob.htm), and the 'by hand' calculations help me obtain predicted probabilities that incorporate both the fixed and random effects. However, I am unable to determine the statistical significance of the marginal effect. Is there a way the I can 'by hand' calculate the z-statistic (similar to the one reported by -margins, predict(mu)- had I been able to use it) for the marginal effect generated using the UCLA approach .

            Many thanks in advance,
            Caroline

            Comment


            • #7
              Hi!

              I am working on an ordered logistic regression model. For this, I am ologit command and tried to use prvalue. When i enter the p​rvalue command, I get the "Factor variables and time-series operators not allowed" error message.

              this i the ologit command that I enter:
              ologit amount_auth male age age2 i.edu_cat i.univ_attended i.level_uni i.bank i.bank_dep work_hrs tenure work_exp married child_pres i.help_child help

              Any help would be appreciated.

              Rich

              Comment


              • #8
                Is there any way I can use the prvalue command while using i.x categorical dependent variables*?
                Last edited by rich eriksson; 05 Apr 2016, 04:35.

                Comment


                • #9
                  Rich E., prvalue is part of the old Long and Freese spost9 package. I suggest you uninstall spost9. Then -findit spost13_ado- and install it. Then use commands like -mtable- instead of -prvalue-. If you want both the spost9 and spost13 commands, see Scott Long's advice at

                  http://www.indiana.edu/~jslsoc/web_s..._faqspost9.htm

                  You may also wish to see Long & Freese's book:

                  http://www.stata.com/bookstore/regre...ent-variables/
                  -------------------------------------------
                  Richard Williams, Notre Dame Dept of Sociology
                  StataNow Version: 19.5 MP (2 processor)

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

                  Comment


                  • #10
                    Thank you so much Richard! I appreciate the time you've spent replying, especially for someone like me who is self-teaching OLOGIT commands for my thesis!

                    Comment


                    • #11
                      Originally posted by Richard Williams View Post
                      Not surprisingly, I agree with William. I also recommend Vince Wiggins' post on marginal effects and interactions:

                      http://www.stata.com/statalist/archi.../msg00293.html

                      Personally I have never been a fan of the inteff approach. On the other hand I see that the 2004 SJ article on the command has 1200 Google Scholar citations, so I assume somebody must like it. Does anybody want to make a case for the inteff approach?
                      I would rather not use inteff either as I cannot get it to function properly in spite of having created all the dummies and lag variables since it does not support time and factor operators. Another issue is the time it takes to run if it runs one logistic regression for each observation. How long will it take if your model contains hundreds of thousands of observations and hundreds of variables?

                      To address Richard's point, I believe the main reason why people use inteff is because you can discuss the statistical significance of the interaction effect. Reviewers ask about the consistency of the parameters for different predicted probabilities. The first graph of inteff shows the sign of the interaction effect, which can vary based on other covariates and the second graph whether that effect is statistically significant. We can then report for which predicted probabilities is the interaction significant.

                      I do not believe it is something that is addressed in Richard's paper about margins or Vince Wiggins' post. If I misunderstood them, how would you decide whether an interaction effect is significant or not, let's say for a categorical by continuous interaction, with the margins command?

                      We test hypotheses and eventually must report whether they are supported or not. It looks like that for non-linear models you cannot do that unless you test the interaction effect for each observations (or using the ratio of odds ratio as suggested by Maarten Buis).

                      I would appreciate some insight in this matter.

                      Comment

                      Working...
                      X