Announcement

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

  • Marginsplot with Standard Deviations

    I want to plot a model using marginsplot for two hypothetical predictors. I have a simple model:

    Code:
     xtreg Y x1 i.x2 c.x1#i.x2 x3, fe
    I want to get two values for x1: the first should be 1 SD more than average and the second should be 1 SD less than average, and I want to use these two to plot the expected outcome along i.x2. How can I do that by using the margins command?

    Btw, the problem is x1 is continuous, so using margins and marginsplot produces problems because of its not being a factor variable.
    Last edited by selim keskin; 26 Feb 2020, 12:58.

  • #2
    For example:

    Code:
    webuse grunfeld
    qui sum kstock
    local sd = r(sd)
    local sd = r(sd)
    local mean = r(mean)
    xtreg invest c.kstock##i.year,fe
    margins year , at(kstock =(`=`mean' - `sd'' `=`mean' + `sd''))
    marginsplot, xdim(year) xlabel(1935(2)1954)

    Comment


    • #3
      It works! Thanks a lot!

      Comment

      Working...
      X