Announcement

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

  • Including confidence intervals in estimate plots

    I have a dataset in which per country, the estimates of coefficients are given as well as their t score and SE (all as separate variables, so the variables are: country var1 t_var1 SE_var1). I would like to plot the estimates of the coefficient per country with its confidence interval. Is there any way to easily do this?

  • #2
    there is so little information here that I am just guessing: meta-analytic plots may work well for you; start with
    Code:
    help meta

    Comment


    • #3
      You can also install coefplot from SSC, place the coefficients and standard errors into a matrix using mkmat and plot. Here is an example:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str8 group float(coef t se)
      "Foreign"  .0047562   .64  .007431563
      "Domestic" -.005813 -6.64 .0008754518
      end
      
      mkmat coef se, mat(R) rownames(group)
      mat R= R'
      coefplot mat(R), se(2) scheme(s1mono)
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	31.0 KB
ID:	1617865

      Comment


      • #4
        I am sorry for the unclarity in my previous post, I am new to statalist. The first graph below I made by generating a row variable (which takes 1 for row one, 2 for row two etc) and running the following command:
        Code:
         twoway (rcap upperbound lowerbound row, sort vertical) (scatter QQfemale row, sort mcolor(black) msymbol(smcircle)), ytitle(Gender gap) ylabel(, labsize(tiny) angle(horizontal) nogrid) xtitle(Country ISO code) xlabel(1 "ALB" 2 "ARE" 3 "ARG" 4 "AUS" 5 "AUT" 6 "AZE" 7 "BEL" 8 "BGR" 9 "BRA" 10 "CAN" 11 "CHE" 12 "CHL" 13 "COL" 14 "CRI" 15 "CZE" 16 "DEU" 17 " DNK" 18 "ESP" 19 "EST" 20 " FIN" 21 "FRA" 22 "GBR" 23 "GEO" 24 "GRC" 25 "HKG" 26 "HRV" 27 "HUN" 28 "IDN" 29 "IRL" 30 "ISL" 31 "ISR" 32 "ITA" 33 "JOR" 34 " JPN" 35 "KAZ" 36 "KGZ" 37 "KOR" 38 "LIE" 39 "LTU" 40 "LUX" 41 "LVA" 42 "MAC" 43 "MDA" 44 "MEX" 45 "MLT" 46 "MNE" 47 "MUS" 48 " MYS" 49 "NLD" 50 "NOR" 51 "NZL" 52 "PAN" 53 "PER" 54 "POL" 55 "PRT" 56 "QAT" 57 "QCN" 58 "QHP" 59 "QTN" 60 "QVE" 61 "ROU" 62 " RUS" 63 "SGP" 64 "SRB" 65 "SVK" 66 "SVN" 67 "SWE" 68 "TAP" 69 "THA" 70 "TTO" 71 "TUN" 72 "TUR" 73 "URY" 74 "USA", angle(vert) labsize(tiny) ticks tposition(inside)) yline(0.0, lpattern(dash) lcolor(gs8))
        

        However, I would like to sort the plots in a descending order, with the highest value of the gender gap estimate on the left and the lowest value on the right (as shown in the second graph below).

        The graph at the bottom plots the estimates of the coefficient per country. I created this using the boxplot graph and marking the median as a small circle. Besides the gendergap variable I have two separate variables, one of the upper bound and one of the lower bound of the confidence interval of the estimate that is plotted. I would like to include these as error bars, but a boxplot is not the right way to do this. The command I used for the second graph is:
        Code:
        graph box QQfemale, over(CNT, sort(QQfemale) descending label(angle(vertical) labsize(tiny))) medtype(marker) medmarker(mcolor(black) msymbol(smcircle)) ytitle(Gender gap) ytitle(, size(vsmall)) yscale(range(-0.06 0.1)) yline(0, lpattern(dash) lcolor("128 128 128")) ylabel(#10, labsize(tiny) angle(horizontal) nogrid) ymtick(none, nolabels) note(Country ISO code, size(vsmall) position(6)) legend(off) scheme(s1mono)
        So my question is: is there any way in which I can sort the estimates in a descending order as well as including the error bars of the estimates?


        Click image for larger version

Name:	Graphstata1.png
Views:	1
Size:	89.1 KB
ID:	1617919


        Click image for larger version

Name:	Graphstata2.png
Views:	1
Size:	52.5 KB
ID:	1617920
        Attached Files

        Comment


        • #5
          Code:
          gsort -QQfemale
          replace row=_n
          twoway (rcap upperbound lowerbound row, vertical) (scatter QQfemale row, mcolor(black) msymbol(smcircle)), ytitle(Gender gap) ylabel(, labsize(tiny) angle(horizontal) nogrid) yline(0.0, lpattern(dash) lcolor(gs8))
          You want to label the row variable so that you avoid manually specifying the xlabels. Install labmask from the Stata Journal, by Nick Cox and look at the help. Also, better to have the country names on the y-axis to enhance readability.

          Code:
          search labmask

          Comment


          • #6
            Thank you so much for your help!

            Comment


            • #7
              A possibility, if you already have a dataset with 1 observation per confidence interval, is to use the eclplot package, which you can download from SSC. This produces 56 varieties of confidence interval plots, some of which are used more often than others. See Newson (2005) for more about eclplot, which can be used either with commands or with a dialog box.

              I hope this helps.

              Best wishes

              Roger

              Newson RB. Generalized confidence interval plots using commands or dialogs. Presented at the 11th UK Stata User Meeting, 17-18 May, 2005. Download from
              https://ideas.repec.org/p/boc/usug05/01.html

              Comment


              • #8
                PS you can use eclplot after sorting the dataset, or using sort options in Stata graphics.

                Comment


                • #9
                  Thank you for your help Roger, I will look into it.

                  Comment

                  Working...
                  X