Announcement

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

  • A new SSC package -bap- to generate Bland-Altman plots


    Thanks to Kit Baum, there is a new package -bap- at the SSC.

    It is yet another command for doing a classical Bland-Altman plot.

    The -bap- is simple to use and yet flexible to add -twoway- options.

    Further, the -bap- returns relevant measures for validity in a matrix.

    Get example data:
    Code:
    . infile using "https://www-users.york.ac.uk/~mb55/datasets/pefr.dct", clear
    . label variable wright1 "PEFR 1, Wright (l/min)
    . label variable wright2 "PEFR 2, Wright (l/min)
    . label variable mini1 "PEFR 1, mini Wright (l/min)
    . label variable mini2 "PEFR 2, mini Wright (l/min)
    Example from the help file:
    Code:
    . . bap mini1 mini2
    
                                  | Measurements                               | Bias                            | Agreement | LOA                  
                                  |         n       mean       [95%        CI] |      diff       [95%        CI] |       SEM |    [lower     upper] 
    ------------------------------+--------------------------------------------+---------------------------------+-----------+---------------------
      PEFR 1, mini Wright (l/min) |        17   452.4706   394.3122    510.629 | -2.882353  -17.72713   11.96242 |   4.95156 | -59.47104   53.70634 
      PEFR 2, mini Wright (l/min) |        17   455.3529   398.1149   512.5909 |         .          .          . |         . |         .          .
    Click image for larger version

Name:	bap.png
Views:	1
Size:	29.0 KB
ID:	1752125
    Kind regards

    nhb

  • #2
    Dear Henrik,

    Again, another very useful contribution to our box of analytical tools. Thank you for that!

    Did you have a look at the earlier work of Paul Seed, GKT School of Medicine, King's London, UK?
    Code:
    net describe sbe33, from(http://www.stata.com/stb/stb55)
    If not, I suggest to download his files and examples.
    Possibly useful as a source of inspiration is his command bamat to calculate and create Multiple Bland-Altman plots, like:
    Code:
    use tan_part, clear
    bamat pct_*
    
    /* Results in:
    
    Reference ranges for differences between two methods
    
    
    Method 1 Method 2  Mean      [95% Reference Range]   Minimum   Maximum
    ----------------------------------------------------------------------
    pct_2    pct_1     13.331    -50.777   77.438      -31.678   88.525
    pct_3    pct_1     16.280    -100.401  132.960     -42.994   195.588
    pct_3    pct_2      2.949    -100.526  106.424     -44.137   162.944
    pct_4    pct_1     -4.234    -47.425   38.956      -46.533   41.237
    pct_4    pct_2     -17.565   -84.648   49.518      -98.993    5.375
    pct_4    pct_3     -20.514   -126.212  85.184      -184.780  26.829
    pct_5    pct_1      4.481    -32.680   41.643      -31.142   37.500
    pct_5    pct_2     -8.849    -64.287   46.589      -71.822   21.817
    pct_5    pct_3     -11.798   -115.825  92.229      -182.932  35.720
    pct_5    pct_4      8.716    -15.297   32.729      -4.839    27.171
    ----------------------------------------------------------------------
    
    Range of x values is -6.546 to    139, range of y values is -195.6 to  195.6
    */
    Which also renders the following plot:
    Click image for larger version

Name:	Tutorial_bamat_pct.png
Views:	1
Size:	58.5 KB
ID:	1752202


    Your command will only allow the comparison of two variables.

    So, maybe you can think of something to add to bap like the functionality of bamat.
    http://publicationslist.org/eric.melse

    Comment


    • #3
      I would suggest looking at the rmloa package as well (downloadable from SSC). It computes the usual limits of agreement as well as limits of agreement for repeated measures. It also allows the use of "by", so you can produce estimates of subgroups.


      Comment


      • #4
        Dear ericmelse and Ariel Linden,
        That is some fine suggestions, which I will look into.
        Thank you very much for helping -bap- become better.
        Kind regards

        nhb

        Comment


        • #5
          What's in a name? Stas Kolenikov once joked something like this: in econometrics every technique is named after two economists who made a fuss about it, regardless of who first discovered or invented it. At this point, some will recall Stigler's Law of Eponymy.

          Here, Martin Bland and the late Douglas Altman, fine medical statisticians and long-term Stata users both, have been honoured by others for their vigorous advocacy and exposition of plotting difference versus mean. The idea is, according to taste, either a variant on or a special case of residual plots, meaning plotting residual versus fitted. (In my usage, which isn't universal, talking about first versus second means that first goes on the vertical axis. Find more on that tiny point at https://stats.stackexchange.com/ques...-data-analysis if it interests you.)

          In rummaging around, I have found plots of difference versus mean in the biostatistics or medical statistics literature in the work of Peter Oldham, Chester I. Bliss and Michael Hills in the 1960s and 1970s. In a conversation I had with Douglas Altman he was clear that he and Martin Bland knew they were pushing a long-standard idea. And John Tukey was certainly pushing the idea in the early 1960s if not earlier. Neyman and friends used the idea in statistical astronomy in the 1950s.

          I have read that residual plots were used by Thiele in the 19th century, so perhaps we come full circle here: the idea is really Danish after all.
          Last edited by Nick Cox; 04 May 2024, 05:43.

          Comment


          • #6
            Nick Cox
            It is a recurring theme in history that individuals often don’t receive recognition for their work. In my view, any significant achievement typically involves at least two parties: the creators of the work and those who bring it to the forefront. Thile may have been the pioneer in utilizing the difference/mean plot. However, Bland and Altman’s publication garnered widespread citations and uses.
            Perhaps Bland and Altman truly deserved their recognition.

            I apologize for the incorrect use of the term “versus”. I’ve grown accustomed to interpreting “versus” as “minus” when reviewing standard output from Stata commands like -margins-. While I can certainly use the term “minus”, I’m open to any alternative suggestions you might have.
            Kind regards

            nhb

            Comment


            • #7
              I am very happy that Bland and Altman get enormous credit for what they did. The difficulty is not over personal credit, but that people need to find out what the X and Y plot does.

              I don't think there is a correct use of versus. I was surprised to find people who use it the other way round from me, and perhaps vice versa, but surprise is not an argument.

              I guess I should mention concord, which despite its focus on concordance correlation, also offers these plots and many more.

              I heard about concordance correlation from Thomas J. Steichen who I met once in between many email-based exchanges on Statalist and off it. He was first author on a series from 1998 to 2010. He's retired twice and gave me carte blanche to do what I like with the whole thing, and what I would like to do is one paper bringing it all together with reference to what's been published in the last 25 years. I will stress that a single measure, concordance correlation, is only ever a detail in the overall task of looking at the structure of similarity and difference.

              Code:
              SJ-10-4 st0015_6  . . . . . . . . . . . . . . . .  Software update for concord
                      (help concord if installed) . . . . . . . T. J. Steichen and N. J. Cox
                      Q4/10   SJ 10(4):691
                      update explicitly supporting plot() and addplot() and
                      allowing systematic control of the reference line
              
              SJ-8-4  st0015_5  . . . . . . . . . . . . . . . .  Software update for concord
                      (help concord if installed) . . . . . . . T. J. Steichen and N. J. Cox
                      Q4/08   SJ 8(4):594
                      dialog box modified to correct visual layout problems
              
              SJ-7-3  st0015_4  . . . . . . . . . . . . . . . .  Software update for concord
                      (help concord if installed) . . . . . . . T. J. Steichen and N. J. Cox
                      Q3/07   SJ 7(3):444
                      now compatible with Stata 10; help file updated
              
              SJ-6-2  st0015_3  . . . . . . . . . . . . . . . .  Software update for concord
                      (help concord if installed) . . . . . . . T. J. Steichen and N. J. Cox
                      Q2/06   SJ 6(2):284
                      updated for compatibility with Stata 9 by() option
              
              SJ-5-3  st0015_2  . . . . . . . . . . . . . . . .  Software update for concord
                      (help concord if installed) . . . . . . . T. J. Steichen and N. J. Cox
                      Q3/05   SJ 5(3):470
                      minor bug fix for concord
              
              SJ-4-4  st0015_1  . . . . . . . . . . . . . . . .  Software update for concord
                      (help concord if installed) . . . . . . . T. J. Steichen and N. J. Cox
                      Q4/04   SJ 4(4):491
                      rewritten to provide dialog, Stata 8 graphs, and two
                      new tests
              
              SJ-2-2  st0015  . . . . . .  A note on the concordance correlation coefficient
                      (help concord if installed) . . . . . . . T. J. Steichen and N. J. Cox
                      Q2/02   SJ 2(2):183--189
                      correction based on an erratum for Lin's concordance
                      correlation coefficient, and assessment of the impact of
                      the change
              
              STB-58  sg84.3  . . . . Concordance correlation coefficient: minor corrections
                      (help concord if installed) . . . . . . . T. J. Steichen and N. J. Cox
                      11/00   p.9; STB Reprints Vol 10, p.137
                      small bug fixes affecting user control through the connect(),
                      symbol(), and pen() options
              
              STB-54  sg84.2  . . .  Concordance correlation coefficient: update for Stata 6
                      (help concord if installed) . . . . . . . T. J. Steichen and N. J. Cox
                      3/00    pp.25--26; STB Reprints Vol 9, pp.169--170
                      updated to version 6 with corrections and new option for
                      saving the standard normal plot
              
              STB-45  sg84.1  . . . . . . . . Concordance correlation coefficient, revisited
                      (help concord if installed) . . . . . . . .  T. Steichen and N. J. Cox
                      9/98    pp.21--23; STB Reprints Vol 8, pp.143--145
                      improvements to the concord command
              
              STB-43  sg84  . . . . . . . . . . . . . .  Concordance correlation coefficient
                      (help concord if installed) . . . . . . . .  T. Steichen and N. J. Cox
                      5/98    pp.35--39; STB Reprints Vol 8, pp.137--143
                      computes Lin's (1989) concordance correlation coefficient for
                      agreement on a continuous measure obtained by two persons or
                      methods

              Comment

              Working...
              X