Announcement

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

  • ca (correspondence analysis) reports error when plot under Stata 16

    Dear Stata users,

    I use Stata 16 now. When I run ca command (correpondence analysis), Stata reports an error that option span not allowed. Below are details. I set trace on and find a piece of bug code which I posted behind.

    Code:
    . webuse ca_smoking
    
    . ca rank smoking, plot
    
    Correspondence analysis                       Number of obs      =        193
                                                  Pearson chi2(12)   =      16.44
                                                  Prob > chi2        =     0.1718
                                                  Total inertia      =     0.0852
        5 active rows                             Number of dim.     =          2
        4 active columns                          Expl. inertia (%)  =      99.51
    
                    |   singular    principal                             cumul  
          Dimension |    value       inertia           chi2    percent   percent 
        ------------+------------------------------------------------------------
              dim 1 |   .2734211    .0747591          14.43      87.76     87.76
              dim 2 |   .1000859    .0100172           1.93      11.76     99.51
              dim 3 |   .0203365    .0004136           0.08       0.49    100.00
        ------------+------------------------------------------------------------
              total |               .0851899          16.44     100
    
    Statistics for row and column categories in symmetric normalization
    
                     |          overall          |        dimension_1        |        dimension_2        
          Categories |    mass  quality   %inert |   coord   sqcorr  contrib |   coord   sqcorr  contrib 
        -------------+---------------------------+---------------------------+---------------------------
        rank         |                           |                           |                           
         senior mngr |   0.057    0.893    0.031 |   0.126    0.092    0.003 |   0.612    0.800    0.214 
         junior mngr |   0.093    0.991    0.139 |  -0.495    0.526    0.084 |   0.769    0.465    0.551 
         senior empl |   0.264    1.000    0.450 |   0.728    0.999    0.512 |   0.034    0.001    0.003 
         junior empl |   0.456    1.000    0.308 |  -0.446    0.942    0.331 |  -0.183    0.058    0.152 
           secretary |   0.130    0.999    0.071 |   0.385    0.865    0.070 |  -0.249    0.133    0.081 
        -------------+---------------------------+---------------------------+---------------------------
        smoking      |                           |                           |                           
                none |   0.316    1.000    0.577 |   0.752    0.994    0.654 |   0.096    0.006    0.029 
               light |   0.233    0.984    0.083 |  -0.190    0.327    0.031 |  -0.446    0.657    0.463 
              medium |   0.321    0.983    0.148 |  -0.375    0.982    0.166 |  -0.023    0.001    0.002 
               heavy |   0.130    0.995    0.192 |  -0.562    0.684    0.150 |   0.625    0.310    0.506 
        -------------------------------------------------------------------------------------------------
    option span not allowed
    r(198);
    Code:
                      -------------------------------------------------------------------- end grid._declare_view ---
                    - local view `r(name)'
                    = local view legend
                    - .`cell'.minrow = `row'
                    = .cells.legend.minrow = 2
                    - .`cell'.maxrow = `row'
                    = .cells.legend.maxrow = 2
                    - .`cell'.mincol = `col'
                    = .cells.legend.mincol = 2
                    - .`cell'.maxcol = `col'
                    = .cells.legend.maxcol = 2
                    - .`cell'._prse_set_span `view' `.maxrow' `.maxcol' `"`options'"'
                    = .cells.legend._prse_set_span legend 3 3 `" , ring(0) span"'
                      ----------------------------------------------------------------- begin cell._prse_set_span ---
                      - version 8
                      - args view maxrow maxcol options
                      - local 0 `options'
                      = local 0  , ring(0) span
                      - syntax [ , RING(real -1) SPANRows(string) SPANCols(string) SPANFit(string) ]
    option span not allowed
                      ------------------------------------------------------------------- end cell._prse_set_span ---
                    -------------------------------------------------------------------------- end grid._add_view ---
                    exit
                    }

  • #2
    I check the cabiplot.ado and guess the problem is caused by the legend option. I delete the "span" in the sentence I marked in red, and now the command works.

    Code:
    // row and column points
    
        if "`row'" != "norow" & "`column'" != "nocolumn" {
            local ij = 1
            local legend label(`ij++' `rn')
            if `nr_supp' {
                local legend `legend' label(`ij++' Supplementary `rn')
            }
    
            local legend `legend' label(`ij++' `cn')
            if `nc_supp' {
                local legend `legend' label(`ij++' Supplementary `cn')
            }
    
            local legend legend(`legend' span) //delete "span" and now the cabiplot command works.
            twoway `Rscatter' `Cscatter',         ///
                `s(scales)' `aspect' `legend' `titles' `gopt' `origin'
        }

    Comment


    • #3
      Just to report that these commands work fine under Stata 18.

      Comment

      Working...
      X