Announcement

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

  • How to plot intercepts (constants using coefplot?

    Hello, Statalisters,

    Is there a way to plot constants from regression models without covariates using coefplot?


    Code:
    use sysauto, clear
    regress mpg
    eststo reg1: regress mpg
    eststo reg2: regress trunk
    eststo reg3: regress price
    coefplot (reg1  \ reg2   \ reg3)
    In the example above, the mean estimates are plotted side by side. Is there a way to solve that issue?

  • #2
    Tiago, in a regression model without a covariate, I don't think there is an intercept or constant term. In a regression model, the constant is the mean of y given that x is 0. The thing is, in the regression models you used, there is no x. So, it is just the mean y. Or am I misunderstanding something?
    Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

    When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

    Comment


    • #3
      Yes, quite right Weiwen. The objective is to plot the means

      Comment


      • #4
        You just need to use parentheses and add a keep() clause:

        Code:
        sysuse auto, clear
        regress mpg
        eststo reg1: regress mpg i.foreign
        eststo reg2: regress trunk i.foreign
        eststo reg3: regress price i.foreign
        coefplot (reg1) (reg2) (reg3), keep(_cons)

        Comment

        Working...
        X