Announcement

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

  • Plotting confidence intervals

    Dear all,

    I am doing a 2SLS to grasp the relation between legal crop prices and coca production for a range of crops in Colombia. To test whether my results are driven by a specific region in Colombia I perform my regression also only for this specific region. This is how the code for my baseline regression looks like:

    Code:
    foreach var of varlist cocaprod{ 
        xi: xtivreg2 `var' lpop ylxlrer_ban ///
            yearxMuncode* YearInd*xWkmean    ///
            (yieldxprice  = yieldxtop3export) ///
            i.year, fe cluster(dept) partial(i.year) first 
            outreg2 using CI_Analysis.xls, se bdec(3) tdec(3) nocons excel 
            }
    in which (yieldxprice = yieldxtop3export) is my first stage and cocaprod is my y-variable. All other variables are controls.

    Now I would like to compare the confidence intervals of this regression with the regression when excluding a specific region (so basically comparing confidence intervals of two regressions) in a plot or graph in Stata. Is there a command for this?

    I am using Stata 14.2

    Help would be very much appreciated!

    Best,

    Sophie

  • #2
    You can compute the confidence interval by -ci-, and later you can draw the plot manually.

    Tom

    Comment


    • #3
      Hi Tom,

      thank you for your reply. However that is not really what I am looking for. I would like to draw CI-plots of multiple models in one plot. I have the following code:
      Code:
      coefplot (ban_sx, keep(sxxlip_ban)) (banoa_sx, keep(sxxlip_ban)), bylabel(Suitability) ///
            || (ban_yl, keep(ylxlip_ban)) (banoa_yl, keep(ylxlip_ban)), bylabel(Yield) ///
            || (suc_sx, keep(sxxlip_suc)) (sucoa_sx, keep(sxxlip_suc)), bylabel(Suitability) ///
            || (suc_yl, keep(ylxlip_suc)) (sucoa_yl, keep(ylxlip_suc)), bylabel(Yield) ///
            ||, drop(_cons) xline(0) byopts(xrescale)
      This yields the following result:
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	25.4 KB
ID:	1424155



      however I would like two panels, and not four; one depicting CI's of "suitability" and the other one of "yield" on which I can append CI'plots of some other models next to _ban and _suc.

      Hope this is somewhat clear and that you can help me.

      Best,

      Sophie

      Comment


      • #4
        Oh,

        Did you mean a forest map? If so, you could install a package called 'metan'.

        Comment


        • #5
          no i did not mean a forest map

          Comment


          • #6
            Originally posted by Sophie Robbe View Post
            ... I would like to draw CI-plots of multiple models in one plot. I have the following code:

            Code:
            coefplot (ban_sx, keep(sxxlip_ban)) (banoa_sx, keep(sxxlip_ban)), bylabel(Suitability) ///
            || (ban_yl, keep(ylxlip_ban)) (banoa_yl, keep(ylxlip_ban)), bylabel(Yield) ///
            || (suc_sx, keep(sxxlip_suc)) (sucoa_sx, keep(sxxlip_suc)), bylabel(Suitability) ///
            || (suc_yl, keep(ylxlip_suc)) (sucoa_yl, keep(ylxlip_suc)), bylabel(Yield) ///
            ||, drop(_cons) xline(0) byopts(xrescale)
            ...
            however I would like two panels, and not four; one depicting CI's of "suitability" and the other one of "yield" on which I can append CI'plots of some other models next to _ban and _suc.

            ...
            Every time you insert a ||, you tell -coefplot- (by Ben Jann, available on SSC) to add a new panel (technically, a "subgraph" in the author's documentation). In contrast, any time you type:

            Code:
            coefplot (graph1) (graph2) (graph3) || (blah blah blah)
            Graphs 1 to 3 go on one subgraph (akin to a -by- group). Perhaps this modification to your syntax gets you closer to what you want:

            Code:
            coefplot (ban_sx, keep(sxxlip_ban)) (banoa_sx, keep(sxxlip_ban)) (suc_sx, keep(sxxlip_suc)) (sucoa_sx, keep(sxxlip_suc)), bylabel(Suitability) || ///
            || (ban_yl, keep(ylxlip_ban)) (banoa_yl, keep(ylxlip_ban)) (suc_yl, keep(ylxlip_suc)) (sucoa_yl, keep(ylxlip_suc)),, bylabel(Yield) ///
            ||, drop(_cons) xline(0) byopts(xrescale)
            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


            • #7
              Dear Weiwen,

              Thank you very much, this works!

              Best,

              Sophie

              Comment


              • #8
                Also, this is a helpful resource: https://opr.princeton.edu/workshops/...lotKoffman.pdf
                Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

                Comment

                Working...
                X