Announcement

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

  • How to plot interaction effects with confidence intervaI?

    Hi Experts,
    I employ panel data methodology in a model type: y = b0 + b1*x1 + b2*x2 + b3*x1*x2 + control variables. I need create a graph for the interaction effect with confidence interval. Someone could help me, please?

  • #2
    You should begin by reading the manual entries for -margins- and -marginsplot-.
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      Is it possible use these commands after xtreg command?

      Comment


      • #4
        yes, as a review of
        Code:
        help xtreg postestimation
        would have shown you - please read and follow the advice in the FAQ for this forum

        Comment


        • #5
          I'm sorry but I do not understand how do it. This is the first time I do it. My model is

          COMPR = b0 + b1*BUSY + b2*GENDER + b3*BUSY*GENDER + control variables

          Using the coefficients from the panel data estimation and I elaborated the next graph and now I need represent the confidence interval in the graph.

          Thanks in advance
          Click image for larger version

Name:	Captura de pantalla 2018-09-21 a las 17.37.55.png
Views:	1
Size:	28.4 KB
ID:	1462955


          Last edited by Nuria Reguera; 21 Sep 2018, 10:00.

          Comment


          • #6
            You don't provide any of your Stata syntax, but here's a simple example of plotting the predicted values after a regression with an interaction. If you are not already using factor notation in your model estimation command, it is imperative that you do so when using margins. See help fvvarlist

            Code:
            clear
            sysuse auto
            reg price i.foreign##c.mpg
            margins foreign, at(mpg=(10(5)50))
            marginsplot
            Stata/MP 14.1 (64-bit x86-64)
            Revision 19 May 2016
            Win 8.1

            Comment


            • #7
              The Stata syntax is:

              xtreg Compromiso Gender Busy Gender_Busy Leverage ROA Size Meetings Tenure, fe

              Results are attach to this post.


              After this, I use coefficient for get graph using the next website: http://www.jeremydawson.co.uk/slopes.htm

              Thank you very much for your help





              Attached Files

              Comment


              • #8
                The best way that I know how to do what you ask is described in #6. Please heed my warning about using factor variable notation in your model instead of creating the interaction variable yourself.
                Stata/MP 14.1 (64-bit x86-64)
                Revision 19 May 2016
                Win 8.1

                Comment


                • #9
                  Sorry, Carole J. Wilson but I think I can't apply factor notation because all my variables are continuos not categorical.

                  Comment


                  • #10
                    #9 Not a problem. As explained e.g. at

                    Code:
                    help fvvarlist
                    factor variable notation applies to continuous variables too. Carole J. Wilson not only pointed this out in #6; she gave you a code example you can run and which worked.

                    By the way, please note our longstanding request to use full real names, e.g. given name and family name. https://www.statalist.org/forums/help#realnames and https://www.statalist.org/forums/help#adviceextras #3 explain why and what to do to fix your alias.

                    Comment


                    • #11
                      Nick Cox I have run the code example in #6. In it the factor variable ("foreign") is a categorical variable which takes two values: domestic or foreign. However, my factor variable is continuos and when I try to run my model I obtain the error message: factor variables may not contain noninteger values.

                      Comment


                      • #12
                        Adding to Carole's example in #6, you can use the r. contrast operator to plot the difference between foreign & domestic cars for a range of mpg values.

                        Code:
                        * Plot difference between foreign & domestic as function of mpg
                        quietly margins r.foreign, at(mpg=(10 50))
                        marginsplot, recast(line) recastci(rarea)
                        HTH.
                        --
                        Bruce Weaver
                        Email: [email protected]
                        Version: Stata/MP 18.5 (Windows)

                        Comment


                        • #13
                          Well, I don't think that Carole J. Wilson was implying that her example mirrors your set-up exactly.

                          We still lack a data example and I guess the lack of such an example was behind Carole's decision to use a standard dataset in her example. Ditto for Bruce's post.

                          All you have to do, please, is to read the help for fvvarlist -- as suggested in #6 and again in #10 -- and just a short way down you will see examples of syntax like

                          Code:
                               c.age             same as age
                          
                               c.age#c.age       age squared
                          which suggest how continuous-continuous interactions can be coded. If the interaction involves two different variables, you need two different names.

                          Again, you give no code in #11. The advice to show code, explicit or implicit in earlier posts, still applies.

                          However, I came late to this thread and haven't read all posts until just now. I am still unclear what is going on. In #5 you state that you are interested in the interaction BUSY * GENDER. You need to explain how those variables are quantified that makes you regard both of them as continuous. That is what you are saying: e.g. in #9 you declare that all of your variables are continuous. Yet the implication of #5 is that BUSY is just binary (low, high) and while there is scope for some categorization more complicated than (male. female) it is also a puzzle how data for GENDER could be continuous.

                          Comment

                          Working...
                          X