Announcement

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

  • #16
    Also, when I try to run the code to place the stars below as the second graph in #4, Stata returns an error in msym (which did not happen to me when building the first graph with stars in the right corner); the only difference I see in the code is the use of msym instead of msymbol, but typing msysmbol does not work either.
    Thanks.
    Juan Vicente-Valor
    StataIC 16
    Attached Files

    Comment


    • #17
      A 34 \(\times\) 34 matrix seems too big, but you can specify the font size directly within -mlabsize()-. See

      Code:
      help scatter##marker_options
      Code:
      sysuse auto, clear
      // compute correlations and p-values
      pwcorr price mpg trunk weight length turn foreign, sig
      matrix C = r(C)
      matrix sig = r(sig)
      // apply heatplot without displaying a graph, just to collect information;
      // option generate stores the information (coordinates etc) as variables
      heatplot C, values(label(sig)) lower nodraw generate
      // significance stars
      gen str sig = cond(_Mlab<.001, "<.001", string(_Mlab, "%4.3f"))
      // second call to heatplot useing addplot to print the marker labels
      
      heatplot C, color(hcl diverging, intensity(.6)) lower legend(off) aspectratio(1) ///
          addplot(scatter _Y _X if _Y!=_X, msym(i) mlab(_Z) mlabf(%9.2f) mlabpos(0) mlabc(black) mlabsize(2) ///
              || scatter _Y _X if _Y==_X, msym(i) mlab(_Z) mlabf(%9.0f) mlabpos(0) mlabc(black) ///
              || scatter _Y _X if _Y!=_X, msym(i) mlab(sig) mlabpos(6) mlabgap(2) mlabc(black) ///
                 mlabsize(2) xlab(, noticks) ylab(, noticks) plotregion(margin(zero)))
      For the second question, we need a reproducible example.
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	48.6 KB
ID:	1750115

      Comment


      • #18
        When you say you need a more reproducible example, do you mean copy and paste the code?

        import excel "C:\Users\file.xlsx", sheet("TABLA FINAL") firstrow clear
        spearman, stats(rho p) star(0.05)
        matrix C = r(Rho)
        matrix sig = r(P)
        *apply heatplot without displaying a graph, just to collect information; option generate stores the information (coordinates etc) as variables
        heatplot C, values(label(sig)) lower nodraw generate
        *significance stars
        gen str sig = cond(_Mlab<.001, "***", cond(_Mlab<.01, "**", cond(_Mlab<.1, "*", "")))
        *second call to heatplot useing addplot to print the marker labels
        heatplot C, color(hcl diverging, intensity(.6)) lower legend(off) aspectratio(1) addplot(scatter _Y _X if _Y!=_X, msym(i) mlab(_Z) mlabf(%9.2f) mlabpos(0) mlabc(black) mlabsize(tiny) scatter _Y _X if _Y==_X, msym(i) mlab(_Z) mlabf(%9.0f) mlabpos(0) mlabc(black) mlabsize(tiny) scatter _Y _X if _Y!=_X, msym(i) mlab(sig) mlabpos(6) mlabgap(2) mlabc(black) mlabsize(tiny))

        Comment


        • #19
          A reproducible example means that people can run your code, which includes access to your data, and get your results. See for example https://en.wikipedia.org/wiki/Minima...ucible_example

          #18 fails because we can't access your spreadsheet file. But if you provided the matrices, someone familiar with heatplot might be able to give good advice. But I fear that unless you are displaying at an enormous size, you will not be able to get the results you want to show in legible form.

          Note that you're asked not to post spreadsheet files here. For positive advice too, see https://www.statalist.org/forums/help#stata

          Comment


          • #20
            Ok! Thanks a million. I run the same database from Andrew Musau #17 and I get the same error. I am able to run the code until the last call to heatplot, where I get:
            invalid 'msym'
            r(198);



            sysuse auto, clear
            spearman, stats(rho p) star(0.05)
            matrix C = r(Rho)
            matrix sig = r(P)
            *apply heatplot without displaying a graph, just to collect information; option generate stores the information (coordinates etc) as variables
            heatplot C, values(label(sig)) lower nodraw generate
            *significance stars
            gen str sig = cond(_Mlab<.001, "***", cond(_Mlab<.01, "**", cond(_Mlab<.1, "*", "")))
            *second call to heatplot useing addplot to print the marker labels
            heatplot C, color(hcl diverging, intensity(.6)) lower legend(off) aspectratio(1) addplot(scatter _Y _X if _Y!=_X, msym(i) mlab(_Z) mlabf(%9.2f) mlabpos(0) mlabc(black) mlabsize(tiny) scatter _Y _X if _Y==_X, msym(i) mlab(_Z) mlabf(%9.0f) mlabpos(0) mlabc(black) mlabsize(tiny) scatter _Y _X if _Y!=_X, msym(i) mlab(sig) mlabpos(6) mlabgap(2) mlabc(black) mlabsize(tiny))

            Comment


            • #21
              You left out the instances of || in Andrew's code.

              Comment


              • #22
                Brillinant! That worked. I thougth || were a separation mark I could miss, but not. The code mlabsize(2) leaves letters too big for a 34x34 matrix, but with Stata Graph editor I managed to make the characters smaller and increase the aspect/size ratio. Now everything fits. Thanks a lot and best wishes.

                Comment

                Working...
                X