Announcement

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

  • Plotting a twoway graph from linear regression while using controls

    I want to plot a twoway graph from a linear regression model that predicts the probability to be employed over age interacted with education while controlling for cohort effects. The resulting graph should include two lines (education is binary) and this works fine as long as I do not include any controls. However, as soon as I include controls in the regression model, the lines in the graph start to look funky (i.e. the lines become thick bars and there is something that looks like missing pixels at the beginning and at the end of those bars). It only works if I select a specific cohort in the graph command but this should not be necessary or am I making some conceptual mistake?

    There already is a similar post about this issue (https://www.statalist.org/forums/for...-with-controls) but the solution there does not work for me.

    I use the following code:
    Code:
    reg emp c.age##i.educ c.cohort
    predict pr, xb
    graph twoway line pr age if educ==0 || line pr age if educ==1
    And a picture of the graph that I get:
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	78.0 KB
ID:	1654407

  • #2
    Given your other predictors, your predictions no longer define lines in that space. It is not the job of twoway line to adjust for the predictors not shown on the graph.

    I think you will be better off with marginsplot.

    Comment

    Working...
    X