Announcement

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

  • Graphing Coefficients From an LPM

    I'm using the following code to estimate an LPM and the effect of the treatment and interacted variables combined using the lincom. I'm having trouble graphing these results, though. I'm looking to produce a graph that has the y variable from the regression on the y axis and the variable relative on the x-axis. The code for the regression is copied below. I've attempted to use coeffplot and marginsplot to produce the graph I want, but to no avail.

    Thanks!

    regress y_accept offer c.relative trt_intentional ///
    offer_intentional relative_intentional age i.female i.married i.party i.educ i.income, vce(robust)

  • #2
    Matthew, what you'd like to plot is unclear to me. For example, is the y-axis the actual y variable, the predicted y variable from LPM, or the effect of x on y (-coefplot- is usually for plotting effect of x on y)? What are you attempting to show with this graph? More details would help.

    Comment


    • #3
      I'm looking to compare the predicted change in acceptance based on the change in relative inequality.

      Comment


      • #4
        My understanding is that you'd like to plot how the predicted y changes as an x changes (the x could be interacted with other covariates), other variables being constant (at their mean levels). Below is an example of plotting predicted car price against miles per gallon (mpg), based on a regression of price on mpg and covariates.

        Code:
        sysuse auto, clear
        
        reg price mpg weight length c.mpg#c.length c.weight#c.length
        sum length if e(sample)
        local slope = _b[mpg] + _b[c.mpg#c.length]*r(mean)
        
        margins, predict(xb) at(mpg = 0)
        local cons = r(table)[1,1]
        
        sum mpg if e(sample)
        local min = r(min)
        local max = r(max)
        
        set scheme s1color
        twoway function `cons' + `slope'*x, range(`min' `max') ytitle("Predicted price at means of covariates") xtitle("Miles per gallon")
        Click image for larger version

Name:	fig.png
Views:	1
Size:	46.9 KB
ID:	1636720
        Last edited by Fei Wang; 15 Nov 2021, 22:38.

        Comment


        • #5
          In your case, code would be like something below. I'm not sure if "relative_intentional" is the interaction of "relative" and "international". Please rewrite all interactions using Stata's "#" operator so that -margins- will give correct answers.

          Code:
          regress y_accept offer relative intentional c.offer#c.intentional c.relative#c.intentional age i.female i.married i.party i.educ i.income, vce(robust)
          
          margins, dydx(relative)
          local slope = r(table)[1,1]
          
          margins, predict(xb) at(relative = 0)
          local cons = r(table)[1,1]
          
          sum relative if e(sample)
          local min = r(min)
          local max = r(max)
          
          set scheme s1color
          twoway function `cons' + `slope'*x, range(`min' `max') ytitle("Predicted acceptance") xtitle("Relative inequality")

          Comment

          Working...
          X