Announcement

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

  • How to generate a standard biplot from correspondence analysis

    Greetings. I want to generate a biplot for correspondence analysis, as described by Greenacre in Chapter 13, "Biplots in Correspondence Analysis," of his book "The Practice of Correspondence Analysis" (2008). The Stata manual only explains how to create biplots with the counts in a contingency table, but this is far from a biplot for correspondence analysis.

  • #2
    Could you tell us more about the distinction you're making?

    ca allows weights -- which is the way that I've used it to include not just row and column categories but also measures of abundance of various kinds.

    Biplots I usually find complicated and confusing, which may be chicken and egg with needing some experience in knowing how to read them.

    I'd rather shuffle row and column categories to a better order.

    Comment


    • #3
      Click image for larger version

Name:	biplot.jpg
Views:	1
Size:	22.0 KB
ID:	1782092


      In the image, the columns have been converted to vector arrows so that the rows can be referenced relative to their position on each vector arrow. The example is from Greenacre, pages 97-104. http://ndl.ethernet.edu.et/bitstream...nacre_2007.pdf

      Comment


      • #4
        The book in question is (note the different title as compared with #1):

        Greenacre, M. Correspondence Analysis in Practice.

        1993. London: Academic Press.
        2007. Boca Raton, FL: Chapman & Hall/CRC,
        2017. Boca Raton, FL: CRC Press.

        Any edition will do for the data example. It would have helped us if you listed the data, but I will do that now.

        I am still puzzled, because the data are in effect a contingency table, and it's easy enough to get an equivalent of the display you copy in #2

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input float area byte category float(freq total)
         1 1  3  85
         1 2 19  85
         1 3 39  85
         1 4 14  85
         1 5 10  85
         2 1  1  29
         2 2  2  29
         2 3 13  29
         2 4  1  29
         2 5 12  29
         3 1  6 130
         3 2 25 130
         3 3 49 130
         3 4 21 130
         3 5 29 130
         4 1  3 120
         4 2 15 120
         4 3 41 120
         4 4 35 120
         4 5 26 120
         5 1 10 114
         5 2 22 114
         5 3 47 114
         5 4  9 114
         5 5 26 114
         6 1  3  88
         6 2 11  88
         6 3 25  88
         6 4 15  88
         6 5 34  88
         7 1  1  37
         7 2  6  37
         7 3 14  37
         7 4  5  37
         7 5 11  37
         8 1  0  86
         8 2 12  86
         8 3 34  86
         8 4 17  86
         8 5 23  86
         9 1  2  29
         9 2  5  29
         9 3 11  29
         9 4  4  29
         9 5  7  29
        10 1  2  75
        10 2 11  75
        10 3 37  75
        10 4  5  75
        10 5 20  75
        end
        label values area order
        label def order 1 "Geology", modify
        label def order 2 "Biochemistry", modify
        label def order 3 "Chemistry", modify
        label def order 4 "Zoology", modify
        label def order 5 "Physics", modify
        label def order 6 "Engineering", modify
        label def order 7 "Microbiology", modify
        label def order 8 "Botany", modify
        label def order 9 "Statistics", modify
        label def order 10 "Mathematics", modify
        label values category category
        label def category 1 "A", modify
        label def category 2 "B", modify
        label def category 3 "C", modify
        label def category 4 "D", modify
        label def category 5 "E", modify
        Code:
         
        . ca area category [fw=freq]
        
        Correspondence analysis                       Number of obs      =        793
                                                      Pearson chi2(36)   =      69.31
                                                      Prob > chi2        =     0.0007
                                                      Total inertia      =     0.0874
            10 active rows                            Number of dim.     =          2
            5 active columns                          Expl. inertia (%)  =      83.64
        
                        |   Singular   Principal                              Cumul.
              Dimension |      value     inertia           chi2    Percent   percent
            ------------+-----------------------------------------------------------
                  Dim 1 |   .2056337    .0422852          33.53      48.38     48.38
                  Dim 2 |   .1755732     .030826          24.44      35.27     83.64
                  Dim 3 |   .1089875    .0118783           9.42      13.59     97.23
                  Dim 4 |   .0491726    .0024179           1.92       2.77    100.00
            ------------+-----------------------------------------------------------
                  Total |               .0874074          69.31        100
        
        Statistics for row and column categories in symmetric normalization
        
                         |          Overall          |        Dimension_1        
              Categories |    Mass  Quality   %inert |   Coord   Sqcorr  Contrib 
            -------------+---------------------------+---------------------------
            area         |                           |                           
                 Geology |   0.107    0.908    0.130 |   0.084    0.014    0.004 
            Biochemistry |   0.037    0.911    0.112 |   0.523    0.211    0.049 
               Chemistry |   0.164    0.646    0.020 |   0.039    0.029    0.001 
                 Zoology |   0.151    0.950    0.233 |  -0.775    0.917    0.442 
                 Physics |   0.144    0.837    0.181 |   0.651    0.792    0.296 
             Engineering |   0.111    0.861    0.144 |  -0.215    0.084    0.025 
            Microbiology |   0.047    0.703    0.009 |   0.047    0.027    0.000 
                  Botany |   0.108    0.630    0.066 |  -0.379    0.559    0.076 
              Statistics |   0.037    0.465    0.011 |   0.235    0.421    0.010 
             Mathematics |   0.095    0.570    0.094 |   0.460    0.500    0.097 
            -------------+---------------------------+---------------------------
            category     |                           |                           
                       A |   0.039    0.512    0.176 |   0.938    0.458    0.167 
                       B |   0.161    0.822    0.103 |   0.224    0.185    0.039 
                       C |   0.391    0.505    0.098 |   0.200    0.376    0.076 
                       D |   0.159    0.981    0.373 |  -0.963    0.930    0.717 
                       E |   0.250    0.985    0.249 |   0.008    0.000    0.000 
            ---------------------------------------------------------------------
        
                         |        Dimension_2        
              Categories |   Coord   Sqcorr  Contrib 
            -------------+---------------------------
            area         |                           
                 Geology |   0.735    0.894    0.330 
            Biochemistry |  -1.033    0.701    0.222 
               Chemistry |   0.193    0.617    0.035 
                 Zoology |   0.161    0.034    0.022 
                 Physics |   0.167    0.045    0.023 
             Engineering |  -0.709    0.777    0.318 
            Microbiology |  -0.254    0.677    0.017 
                  Botany |  -0.147    0.072    0.013 
              Statistics |   0.083    0.045    0.001 
             Mathematics |  -0.185    0.069    0.018 
            -------------+---------------------------
            category     |                           
                       A |   0.348    0.054    0.027 
                       B |   0.449    0.636    0.186 
                       C |   0.127    0.129    0.036 
                       D |   0.246    0.052    0.055 
                       E |  -0.700    0.985    0.697 
            -----------------------------------------
        
        . cabiplot
        Click image for larger version

Name:	cabiplot.png
Views:	1
Size:	53.1 KB
ID:	1782111

        (The signs of scores are reversed on one dimension, but as usual with the kind of eigen calculation involved, signs of scores are arbitrary.)

        The data show numbers of researchers in various areas (disciplines) in different funding categories. A B C D E are an ordered scale, A means most funded and E being not funded at all.

        The ordering of areas from Geology to Mathematics has no rationale obvious to me, so one way forward is to score A to E as 1 to 5 and re-order categories on say the resulting means: Low means imply well funded and high means imply poorly funded.

        I used myaxis and tabplot from the Stata Journal.

        Code:
        . expand freq
        (1 zero count ignored; observation not deleted)
        (744 observations created)
        
        . myaxis area2=area, sort(mean category)
        
        . tabplot category area2 , percent(area2) showval xla(, labsize(vsmall)) subtitle(% in area)
        Click image for larger version

Name:	catabplot.png
Views:	1
Size:	59.3 KB
ID:	1782112


        I don't see enormous differences between subject areas. But either way, what does the biplot show you that the bar chart doesn't?

        Comment


        • #5
          The first example in https://www.statalist.org/forums/for...updated-on-ssc
          also took a dataset from Greenacre's book.

          tabplot was written up at https://journals.sagepub.com/doi/pdf...867X1601600214

          Comment


          • #6
            Thank you very much. I wasn't familiar with TabPlot. I'll start using it.

            Comment


            • #7
              A small warning for Stata novices who may run into this thread: Stata is case-sensitive, so while tabplot as referenced in #5 will work (after installation), typing TabPlot as referenced in #6 will not.

              Comment

              Working...
              X