Announcement

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

  • Scatter plot with a categorical variable

    I have three categorical variables (capacity, times, prices). The capacity has three levels ( 4 cups, 8 cups, and 10 cups). After run regression with these three categorical variables (capacity, times, prices), I have predicted values of preference (prefhat).
    How can I have a scatter plot of prefhat against capacity (with three level) along with a connected line of average prefhat in each level of capacity? (The scatter plot and the line is in the same graph)
    Thank You

  • #2
    Code:
    sysuse auto, clear
    regress mpg i.foreign i.rep78
    predict prehat
    egen mean = mean(prehat), by(rep78)
    scatter prehat rep78 || line mean rep78, sort

    Comment


    • #3
      Thank you very much.

      Comment

      Working...
      X