Announcement

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

  • #16
    As I mentioned in the beginning of my answer: 3D graphs are not appropriate for your problem, so no.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #17
      Originally posted by Clyde Schechter View Post
      Joseph,

      It does work:

      Code:
      webuse nlswork, clear
      
      xtreg ln_wage c.age##c.hours
      margins, at(age = (15(5)40) hours = (40(10)80))
      marginsplot, xdimension(hours)
      If the fewer points are desired, that's just a matter of specifying fewer values in the -margins- command. The confidence interval bars can be suppressed with the -noci- option. It differs from the original request only in that it covers a wider range of values of both variables and doesn't dichotomize anything. What you posted also works and, in concept, is the same except that you have chosen the 25th and 75th percentiles to be the values I referred to as interesting.
      Hey Clyde,

      thank you for your help. Your approach is working fine!

      But I have some problems with my results. An interaction term that I've used showed a negative association to the dependent variable. But if I use your commands to illustrate it in a graph, the effect is for all combinations of the indenpendent and moderator variable positiv. How can that be?

      In general, I have problems with interpreting my moderation. I used performance as the independent variable, resources as the dependent variable and skill as a moderator. I ran a regression with the control variables, the independent variable and the interaction of resources and skill . Let's assume that I get a negative result for the interaction term. But I want a more detailed analysis with high and low values of the dependent variable and the moderator. However, if I construct low/high values of these variables and ran a regression, I always get the error about omitted variables. So, do you think the approach to go into further detail with the graph is reasonable? Or could you think of other possibilities to analyze high/low values of the variables?

      Thanks!

      Comment


      • #18
        Originally posted by Michael Rumpf View Post
        Is it even possible to create a 3D graph like in my picture above?
        See the video in the link given in #8 above. It shows how to create a contour plot for an interaction. Actually, all of the matrix stuff that I show there in that post was needed only if you want to create a contour plot; what Clyde and Oded showed above my post is the best route to a line graph.

        Keep in mind that it's a contour plot and not the pseudo-3D plot like you show. By the way, I don't understand how you got a wavy ribbon in your pseudo-3D plot like you show. From a simple interaction of two binary predictors in a linear model, I would have expected a flat trapezoid.

        Comment


        • #19
          Originally posted by Michael Rumpf View Post
          But I have some problems with my results. An interaction term that I've used showed a negative association to the dependent variable. But if I use your commands to illustrate it in a graph, the effect is for all combinations of the indenpendent and moderator variable positiv. How can that be?
          Compute the linear predictions manually and see what's dominating the contributions to the predicted values. Depending upon the relative magnitude and sign of the regression coefficients for the dichotomous main effects and their interaction term, and upon what is chosen for the x-axis (xdimension()), you can get different appearing profile plots.

          Originally posted by Michael Rumpf View Post
          In general, I have problems with interpreting my moderation. I used performance as the independent variable, resources as the dependent variable and skill as a moderator. I ran a regression with the control variables, the independent variable and the interaction of resources and skill . Let's assume that I get a negative result for the interaction term. But I want a more detailed analysis with high and low values of the dependent[?] variable and the moderator. However, if I construct low/high values of these variables and ran a regression, I always get the error about omitted variables. So, do you think the approach to go into further detail with the graph is reasonable? Or could you think of other possibilities to analyze high/low values of the variables?
          I don't understand what you're driving at here, but I think that you might have missed Clyde's point. He recommended against dichotomizing your continuous predictors, rather, keep them continuous and choose pertinent values of each for the profile plot of the interaction. You should probably explain what you mean with "I always get the error about omitted variables".

          Comment


          • #20
            Michael Rumpf I also recommend to check the graph3d ado (SSC). You might find it very useful for your aim to visualize interactions between two continuous variables. See also this post.
            BTW in 11# you wrote that you got an error message after running my code, but it works fine for me. To make it work, you must copy the code to do file, highlight all the code and run it once (not line by line).

            Comment


            • #21
              Dear statalisters, I am writing you quoted the previous post (at the end of my message) because I ran the code and works perfectly, but I need to do some changes.
              I have a specific question, I am trying to do the same plot, but instead of having both variables (headroom and trunk) as continuous variables, one is a dummy variable. Saying that, how can I get the marginplot if I want on the x axis the dummy and the other (continuous) variable -1 SD and +1SD in the plot?. Additionally, if it is possible, in the plot I would like three values for the continuous variable, -1SD, mean, +1SD, is it possible?

              Hope to be clear.
              Thank you very much for your help!!

              Alejandro.

              Originally posted by Oded Mcdossi View Post
              I share previous comments about the possibility for misleading when these kind of graphs are presented, however it is a common technique in the behavioral sciences to present these graphs when using interactions between two continuous variables. I lean on the previous example and show a way to produce this graph in Stata.

              Code:
              sysuse auto, clear
              
              //RUN YOUR REGRESSION
              regress length c.headroom##c.trunk
              
              //STORE THE RESULTS
              est sto regression
              
              //DEFINE HIGH AND LOW VALUES BASED ON +-1SD FROM THE MEAN OF THE ESTIMATED SAMPLE
              foreach v of var headroom trunk {
              su `v' if e(sample)
              local low_`v'=r(mean)-r(sd)
              local high_`v'=r(mean)+r(sd)
              }
              
              // LOAD BACK YOUR RESULTS
              est restore regression
              
              // CALCULATE THE MARGINAL PREDICTIONS
              margins , at(headroom=(`low_headroom' `high_headroom') trunk = (`low_trunk' `high_trunk'))
              
              //PLOT THE RESULTS
              marginsplot , title("") ylabel( , angle(horizontal) nogrid) noci

              Comment


              • #22
                You can modify it like this:
                Code:
                sysuse auto, clear
                
                //RUN YOUR REGRESSION
                regress length i.rep78##c.trunk
                
                //STORE THE RESULTS
                est sto regression
                
                //DEFINE HIGH AND LOW VALUES BASED ON +-1SD FROM THE MEAN OF THE ESTIMATED SAMPLE
                su trunk if e(sample)
                local low_trunk=r(mean)-r(sd)
                local high_trunk=r(mean)+r(sd)
                
                // LOAD BACK YOUR RESULTS
                est restore regression
                
                // CALCULATE THE MARGINAL PREDICTIONS
                margins rep78, at(trunk = (`low_trunk' `high_trunk'))
                
                //PLOT THE RESULTS
                marginsplot , title("") xdimension(rep78) ylabel( , angle(horizontal) nogrid) noci

                Comment


                • #23
                  Dear Clyde,

                  Grear to read you again. I test the code and received this message
                  invalid numlist has too few elements
                  .
                  Do you know what it means please?

                  Thank you !
                  Alejandro

                  Comment


                  • #24
                    Yes, I know what it means, but that won't help figure out why it happened. I ran this code before posting it, and it produced no error messages. You are adapting the code to your own data, and it may be that in editing it you made some change that is producing this result. Or perhaps there is something about your data that is different from that in the auto.dta data set in some crucial way. Please post back showing the exact code you ran (all of the commands corresponding to what was recommended in #22) and the complete exact output you got from Stata.

                    Comment


                    • #25
                      Dear Clyde,

                      Thank you for your answer!! I just made the code work, I don't know why, but from the code you sent me and in the part that I am sending you below, instead of writing "trunk" (actually, the name of my variable", I changed for a letter "v" and works.

                      Code:
                      //DEFINE HIGH AND LOW VALUES BASED ON +-1SD FROM THE MEAN OF THE ESTIMATED SAMPLE
                      Code:
                      su trunk if e(sample)
                      Code:
                      local low_trunk=r(mean)-r(sd)
                      Code:
                      ​​​​​​local high_trunk=r(mean)+r(sd)
                      I really appreciatte your help, I can say that the PhD is going faster just because your help (and some other statalisters) all this time.

                      Best regards,

                      Alejandro

                      Comment

                      Working...
                      X