Announcement

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

  • Plot a specific coefficient and its confidence interval from different regressions

    Hi,

    I am running 5 different regressions and store a main coefficient of interest in order to graph them using `coefplot`. The data if interest is continuous
    of type double. I just want the one coefficient.


    For example:
    ```
    reg price quantity X
    local coef1 = _b[quantity]
    .
    .
    .

    *matrix Z = (`coef1',`coef2',`coef3',`coef4',`coef5')

    coefplot (matrix(Z), base vertical noci recast(connected) xlabel(1 "P1" 2 "P2" 3 "P3" 4 "P4" 5 "P5") yline(0)
    ```

    This works, but now I want to store the confidence interval so the coefficient and its CI can be plotted together. How can I adjust my methods to do this?

    I did try defining a matrix and then storing upper and lower limits with the coefficient, but it did not graph appropriately so I assume my syntax is wrong.

    This is what I tried:
    ```

    matrix Z = J(5,3,.)
    matrix coln Z = coef ll95 ul95

    reg price quantity X
    matrix Z[1,1] = _b[quantity], r(lb_1), r(ub_1)
    .
    .
    .

    coefplot (matrix(Z[,1]), ci(Z[,2] Z[,3])), ciopts(recast(rcap)) base vertical noci recast(connected) xlabel(1 "P1" 2 "P2" 3 "P3" 4 "P4" 5 "P5") yline(0)
    ```

    How can I adjust this code to achieve the desired result?


Working...
X