Announcement

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

  • Interaction and mkspline2 / restricted cubic splines

    Dear all,

    I would like to investigate the the relationship between to variables. Y is my dependent variable, A and B are independent.
    I guess the effect of the variable B is not linear. I use a panel dataset, my final version is a fixed effects estimation.

    My Problem:
    I used the very good command "mkspline2" . I think the problem is I can´t use the post estimation plot "mfxrcspline" with interaction terms.

    My Aim:
    Estimate something like this:
    Code:
    mkspline2 spline_B = B, cubic nknots(3)
    
    gen spline_interact1 = spline_B1*A
    ​​​​​​​gen spline_interact2 = spline_B2*A
    
    xtreg Y A spline_B*  spline_interact* ,fe
    and a marginal plot or (at least) a predicted value plot, that shows the effect of B (for different values of A) on Y.

    Got anybody an idea? Thanks your help
    Best regards

  • #2
    Hi Marcel,

    Have you tried using the xblc command? Details here: http://www.stata-journal.com/sjpdf.h...iclenum=st0215

    I haven't used it for interactions before but I have found it is generally a very useful command for working with restricted cubic splines so it might be worth a try.

    Cheers,

    Al

    Comment


    • #3
      You cannot use the postrcspline package (user written and available from SSC) to look at interactions. For that there would need to be a mechanism with which you tell the postrcspline commands what the interaction terms are, and I did not implement that.

      You could look at the examples here: http://maartenbuis.nl/wp/inter_quadr...quadr_new.html on how to use margins and marginsplot to get such a graph like adjustrcspline, i.e. for the predicted values. Getting a graph like mfxrcspline, i.e. for marginal effects, using margins and marginsplot would not be possible as there is no way of telling margins that the cubic spline variables belong together.
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Thanks a lot, Al! The paper is very interesting to read anyway.

        You could look at the examples here: http://maartenbuis.nl/wp/inter_quadr...quadr_new.html on how to use margins and marginsplot to get such a graph like adjustrcspline, i.e. for the predicted values.
        Thanks Maarten! I will try out!

        Comment


        • #5
          Hey Maarten,

          one thing about splines: by assumption I´m not interested in main effects. What would stata tell me, if I would try this command:

          Code:
          mkspline2 spline_A = A, cubic nknots(3) display
          
          gen spline_int1 = spline_A1*B 
          gen spline_int2 = spline_A2*B
          
          drop spline_A1
          drop spline_A2
          
          rename spline_int1 spline_A1
          rename spline_int2 spline_A2
          
          xtreg Y   spline_A*  A B
          mfxrcspline, link(identity) showknots
          I know, for a single variable mfxrcspline shows the marginal effect of dY/dA.

          In this version, I think it´s still dY/dA and to show the total effect on Y one got to choose different levels of B? (like dY/dA * B)
          (It´s a kind of manipulation of your code because of the very good post estimation plot)

          Best regards

          Comment

          Working...
          X