Announcement

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

  • Line graph fitted values from categorical variables

    Hi

    I'm trying to create a line graph with predicted (fitted) values from a regression where the dependent variable is continuous (log earnings) but the explanatory variable is categorical (educational attainments).

    The graph I get looks like a "nest", with every point connected to the others, and is unreadable.

    Click image for larger version

Name:	returns to education.jpg
Views:	1
Size:	29.3 KB
ID:	1357708


    I do not understand why this is happening.
    While playing around with my data, I managed to have it appear "clean" once, but ever since this has been happening, even though I don't think I changed anything.

    I use stata 12.

    Here is my code:

    reg logearn i.educrec, r
    predict discretefitted
    twoway (line discretefitted educyears)

    Thank you so much!

  • #2
    Your model fit doesn't lead me to suppose that the predictions are necessarily even monotonic in educyears -- which isn't a predictor.

    But minimally you could insist on sorting

    Code:
    twoway (line discretefitted educyears), sort 
    but as the predictions traverse a large region I think the problem is different.

    Otherwise put, you need to explain the relationships between educrec and educyears for the question to be clear.

    Comment


    • #3
      Thanks for your answer! "educyears" is just the continuous version of my education variable, so that the X-axis is labeled in years instead of arbitrary education levels.

      The sort option is what I needed!

      Comment

      Working...
      X