Announcement

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

  • #31
    what if I don't want grey lines to appear in grunfield data, let suppose I want only orange line to appear,

    Comment


    • #32
      Then fabplot is irrelevant to you. Use xtline

      Comment


      • #33
        Thanks to Kit Baum as ever, fabplot has been updated on SSC. The update adds several more references to the help and -- perhaps more interesting and useful -- a new select() option.

        The deal with
        fabplot -- think front and back plot -- is a mixed strategy. Several groups to compare? You could put them on top of each other (superimposed), which might well turn out to be a mess, or side by side (juxtaposed), which is likely to be clearer but makes comparison more difficult in some ways. The mixed strategy is to show each group in turn -- but with all the other groups as context.

        So, as already shown, you can do something like this:

        Code:
        webuse grunfeld, clear
        fabplot line invest year, by(company) ysc(log) yla(1 10 100 1000)
        Click image for larger version

Name:	fabplot1.png
Views:	1
Size:	89.8 KB
ID:	1570351



        and by all means zap "year", decide that you want a thicker line for each series, and so on. But what to do if only want to focus on fewer panels, say companies 1 to 4? In your case you might have 32 countries but 9 are of interest and importance, or 123 causes of death, but for the moment let's just look at the top 9.

        The restriction say

        Code:
        ... if company <= 4
        will show 4 panels, but in each case the backdrop will be the other 3. This is what the new option does:

        Code:
        fabplot line invest year, by(company) ysc(log) yla(1 10 100 1000) select(company <= 4) xla(, format(%tyYY)) xtitle("") frontopts(lw(thick))
        showing in passing that there are always small details to tweak.
        Click image for larger version

Name:	fabplot2.png
Views:	1
Size:	78.0 KB
ID:	1570352






        https://www.youtube.com/watch?v=HeERupuicHE
        Last edited by Nick Cox; 27 Aug 2020, 12:10.

        Comment


        • #34
          Absolutely fab-ulous

          Comment


          • #35
            https://www.youtube.com/watch?v=ivPk6p8O30I

            Comment


            • #36
              See https://www.economist.com/graphic-de...-to-lose-steam for a nice example of this strategy.

              Comment


              • #37
                I hope that you got your cut Nick!

                Comment


                • #38
                  Another example at https://www.theguardian.com/business...big-to-stomach

                  As always, I suspect that this method has been re-invented many times, but it's just not part of everyone's toolkit yet. The help file for fabplot on SSC has several references and I've found more since that was posted in August 2020.

                  Comment


                  • #39
                    Hi Nick Cox In #30 you state that fabplot reduces
                    repetition of stuff along the axes.
                    In some cases, the distance of say three levels without x-axis values (such as in #33) may impact interpretation. Is there a way in fabplot to add x-axis values for graphs like in #33?

                    Also, could you kindly show in #33 how one may add a line at a specific point in the graph as a way of delineating between values above and below that point?

                    Comment


                    • #40
                      @Chris Boulis

                      fabplot is using the by() option of twoway so in principle you can add its suboptions, In practice twoway seems to ignore ixlabel and I don't know why but don't think that's any side-effect of my code. I have noted that in other instances.

                      In my view adding xla(, grid) is a much better way to help interpretation. There is no data example in #30 but this should give the flavour:

                      webuse grunfeld, clear
                      fabplot line invest year, by(company) ysc(log) yla(1 10 100 1000) frontopts(lw(thick)) select(company <= 4) xla(, grid)



                      "add a line at a specific point" is hard to decode geometrically but, again, twoway options such as xline() and yline() are available as extras.

                      Comment


                      • #41
                        Nick Cox. Thank you for the code and suggestions.

                        I don't understand either as subsetplot also uses the by() option, but x-axis labels are given. Anyway, fabplot looks nicer - particularly the removal of repetitive y-axis labels. I agree, using xla(, grid) largely offsets this if there are an even number of graphs. I have five graphs in my case, so I see an inconsistency. I will look to add a summary graph to fill the void.

                        Your suggestion to use twowayoptions yline() xline() was perfect - it does just as I wanted - thanks.

                        Is lfit() compatible with fabplot? I tried including it, but Stata output read "varlist not allowed r(101);"
                        Last edited by Chris Boulis; 01 May 2021, 05:49.

                        Comment


                        • #42
                          Actually, no. subsetplot has a by() option but that just indicates the grouping variable. The juxtaposition of graphs is done by graph combine. So, I am less surprised that the commands behave quite differently in this respect because they were written differently, although the help file doesn't explain that because it doesn't need to.

                          But I can't explain why ixlabel doesn't seem to work as I expect it to with fabplot. I just don't see that is my bug.

                          You don't show the code that doesn't work. Something like
                          Code:
                          webuse grunfeld
                          fabplot lfit invest year, by(company)  frontopts(lw(thick)) select(company <= 4) xla(, grid)
                          "works" but it doesn't do what you probably hope.

                          The help for fabplot at least on my machine has a weaselly disclaimer

                          fabplot does not attempt to trap calls to twoway that are legal with two numeric variables, but will not be helpful with its design. It is
                          most obviously useful with calls to scatter, line and connected and written with those subcommands in mind.
                          Last edited by Nick Cox; 01 May 2021, 06:12.

                          Comment


                          • #43
                            Thanks for clarifying - that makes sense.
                            You don't show the code that doesn't work
                            My apologies. I attempted:
                            Code:
                            fabplot (scatter totasset_ecpc agegrp) (lfit totasset_ecpc agegrp), by(wave)
                            and
                            Code:
                            fabplot scatter totasset_ecpc agegrp || lfit totasset_ecpc agegrp, by(wave)
                            Yes you are correct the code in #42 does "work". but not as I'd hoped - which is to run a 'line of best fit' through the annual data in each graph. Thanks anyway.
                            Last edited by Chris Boulis; 01 May 2021, 09:47.

                            Comment


                            • #44
                              Sorry, but that goes way beyond what the syntax allows. You can fit the regressions in advance and then save the predictions to a new variable; and then use fabplot line.

                              Comment


                              • #45
                                I will do as you suggested. Thank you for your advice Nick Cox.

                                Comment

                                Working...
                                X