Announcement

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

  • #16
    Thank you!

    Comment


    • #17
      Hello everyone,
      I do have a follow-up question for #11.
      Is there a way to do here what would usually be done with headings?
      Specifically, adding a heading between var 1 and var 2.

      This of course does not really make sense with only two variables displayed on the y axis, but as I mentioned, my original data includes more than just those two variables and it would be great if there was a way to group some of the variables and then add headings inbetween.

      Thank you!

      Comment


      • #18
        Substitute -headings()- for -groups()- if the below does not work for you, only including the first coefficient if using the former.

        This of course does not really make sense with only two variables displayed on the y axis, but as I mentioned, my original data includes more than just those two variables
        Again, the responsibility for creating an adequate data example is yours. You risk not getting responses if you leave this to those who might otherwise help you.

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input float(treatment north mean_v1 mean_v2 mean_v3 mean_v4 yu_v1 yu_v2 yu_v3 yu_v4 yl_v1 yl_v2 yl_v3 yl_v4)
        0 0 12.92 4.38 12.92 4.38 15.19 5.21 15.19 5.21 10.61  3.5 10.61  3.5
        0 1  8.05 3.07  8.05 3.07 10.59 4.15 10.59 4.15  5.47 1.99  5.47 1.99
        1 0  13.4 5.42  13.4 5.42 17.96 6.76 17.96 6.76 10.82 4.08 10.82 4.08
        1 1  8.11 2.99  8.11 2.99 12.54 3.68 12.54 3.68  5.62 2.32  5.62 2.32
        end
        
        
        gen id=_n
        reshape long mean_ yu_ yl_, i(id) j(which) string
        destring which, ignore(v) replace
        cap noisily{
            mkmat which-yl if north & !treatment, mat(coefs10) rowname(which)
            mkmat which-yl if north & treatment, mat(coefs11) rowname(which)
            mkmat which-yl if !north & !treatment, mat(coefs00) rowname(which)
            mkmat which-yl if !north & treatment, mat(coefs01) rowname(which)
        }
        
        coefplot (mat(coefs10[,4]), ci((coefs10[,6] coefs10[,5])) msy(Oh)) ///
        (mat(coefs11[,4]), ci((coefs11[,6] coefs11[,5])) msy(Th)), offset(0) bylabel(North) || ///
        (mat(coefs00[,4]), ci((coefs00[,6] coefs00[,5]))) ///
        (mat(coefs01[,4]), ci((coefs01[,6] coefs01[,5]))), offset(0) bylabel(South) ||, ///
        leg(order(2 "Control" 4 "Treatment")) byopts(note(Dashed line represents true values)) ///
        ciopts(recast(rcap)) ylab(1 "Var 1" 2 "Var 2" 4 "Var 3" 5 "Var 4") ///
        groups(var 1 var 2= "{bf:Label A}" var 3 var 4 = "{bf:Label B}", angle(vert))
        Res.:

        Click image for larger version

Name:	Graph.png
Views:	1
Size:	30.5 KB
ID:	1762073

        Comment


        • #19
          Andrew, thank you for your help.

          I did not mean to leave you without an adequate data example.

          Specifically, adding a heading between var 1 and var 2.
          Since I phrased my question like this, I thought my data example would be adequate. I only mentioned additional variables as an explanation why I would even ask this question in the first place. I didn't mean for you to create a more extensive data example and I'm truly sorry I caused you more work. Thank you for taking the time.


          Is there a way to have the labels horizontally and above Var 1 and Var 3?

          I tried the code below but the labels don't show.

          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input float(treatment north mean_v1 mean_v2 mean_v3 mean_v4 yu_v1 yu_v2 yu_v3 yu_v4 yl_v1 yl_v2 yl_v3 yl_v4)
          0 0 12.92 4.38 12.92 4.38 15.19 5.21 15.19 5.21 10.61  3.5 10.61  3.5
          0 1  8.05 3.07  8.05 3.07 10.59 4.15 10.59 4.15  5.47 1.99  5.47 1.99
          1 0  13.4 5.42  13.4 5.42 17.96 6.76 17.96 6.76 10.82 4.08 10.82 4.08
          1 1  8.11 2.99  8.11 2.99 12.54 3.68 12.54 3.68  5.62 2.32  5.62 2.32
          end
          
          
          gen id=_n
          reshape long mean_ yu_ yl_, i(id) j(which) string
          destring which, ignore(v) replace
          cap noisily{
              mkmat which-yl if north & !treatment, mat(coefs10) rowname(which)
              mkmat which-yl if north & treatment, mat(coefs11) rowname(which)
              mkmat which-yl if !north & !treatment, mat(coefs00) rowname(which)
              mkmat which-yl if !north & treatment, mat(coefs01) rowname(which)
          }
          
          
          coefplot (mat(coefs10[,4]), ci((coefs10[,6] coefs10[,5])) msy(Oh)) ///
          (mat(coefs11[,4]), ci((coefs11[,6] coefs11[,5])) msy(Th)), offset(0) bylabel(North) || ///
          (mat(coefs00[,4]), ci((coefs00[,6] coefs00[,5]))) ///
          (mat(coefs01[,4]), ci((coefs01[,6] coefs01[,5]))), offset(0) bylabel(South) ||, ///
          leg(order(2 "Control" 4 "Treatment")) byopts(note(Dashed line represents true values)) ///
          ciopts(recast(rcap)) ylab(2 "Var 1" 3 "Var 2" 6 "Var 3" 7 "Var 4") ///
          headings(var 1 = "{bf:Label A}" var 3 = "{bf:Label B}")
          Again, thank you!

          Comment


          • #20
            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input float(treatment north mean_v1 mean_v2 mean_v3 mean_v4 yu_v1 yu_v2 yu_v3 yu_v4 yl_v1 yl_v2 yl_v3 yl_v4)
            0 0 12.92 4.38 12.92 4.38 15.19 5.21 15.19 5.21 10.61  3.5 10.61  3.5
            0 1  8.05 3.07  8.05 3.07 10.59 4.15 10.59 4.15  5.47 1.99  5.47 1.99
            1 0  13.4 5.42  13.4 5.42 17.96 6.76 17.96 6.76 10.82 4.08 10.82 4.08
            1 1  8.11 2.99  8.11 2.99 12.54 3.68 12.54 3.68  5.62 2.32  5.62 2.32
            end
            
            
            gen id=_n
            reshape long mean_ yu_ yl_, i(id) j(which) string
            destring which, ignore(v) replace
            cap noisily{
                mkmat which-yl if north & !treatment, mat(coefs10) rowname(which)
                mkmat which-yl if north & treatment, mat(coefs11) rowname(which)
                mkmat which-yl if !north & !treatment, mat(coefs00) rowname(which)
                mkmat which-yl if !north & treatment, mat(coefs01) rowname(which)
            }
            
            coefplot (mat(coefs10[,4]), ci((coefs10[,6] coefs10[,5])) msy(Oh)) ///
            (mat(coefs11[,4]), ci((coefs11[,6] coefs11[,5])) msy(Th)), offset(0) bylabel(North) || ///
            (mat(coefs00[,4]), ci((coefs00[,6] coefs00[,5]))) ///
            (mat(coefs01[,4]), ci((coefs01[,6] coefs01[,5]))), offset(0) bylabel(South) ||, ///
            leg(order(2 "Control" 4 "Treatment")) byopts(note(Dashed line represents true values)) ///
            ciopts(recast(rcap)) coeflab(1 = "Var 1" 2 = "Var 2" 3 = "Var 3" 4 = "Var 4") ///
            headings(var 1 = "Label A" var 3 = "Label B")
            Click image for larger version

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

            Comment

            Working...
            X