Announcement

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

  • #16
    Dear all, I have a question about marginsplot after bootstrapping:
    Here is my two-stage model:

    *** IV Model 1
    capture program drop boot
    program boot, rclass
    ***First Stage***
    reg X i.IV Controls, robust
    predict Residuals, resid
    est store Residuals

    ***Second Stage***
    probit Y c.X##c.X c.Residuals##c.Residuals Controls
    margins, at(X=(0(1)48)) post
    est store margins3
    drop Residuals
    end
    bootstrap _b, reps(3) seed(123): boot

    Then, I use the following command to plot margins:
    est restore margins3
    margins
    marginsplot

    I can see margins and their confidence intervals, but I am getting the following error: "variable Residuals not found" Margins and their confidence interval are already calculated, why does marginsplot command need Residuals? Is there any other command to plot already calculated margins and their confidence intervals?

    Thank you very much!

    Comment


    • #17
      Hi Sidika
      The reason for the error is because how margins (and marginsplot) work. It is trying to verify ALL variables in the original model exist, even if they are not part of the plot of interest.
      The easiest solution is just to create your variable "residuals" equal to 0. and then make the plot.
      HTH
      Fernando

      Comment


      • #18
        FernandoRios Dear Fernando,

        Thank you very much for your response! It worked perfectly, I have been trying to solve this problem for a long time, appreciate your help a lot!
        Last edited by Sidika Tunc Candogan; 15 Mar 2021, 06:17.

        Comment

        Working...
        X