Announcement

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

  • #16
    In my example, vlist is populated from the levels of the var dimension. The list of variables from which the count, mean, and sd values are computed by table. See help for collect levelsof.

    There is an entire manual devoted to collect, including examples using table; e.g. [Tables] Example 3 Table of comparative summary statistics.

    However, I would start with the "Classic Table 1" examples in [R] table summary.

    Comment


    • #17

      OK, if I had the data with variables dem and HIEF (and I
      assume scalar threshold) I would be able to verify if the
      following works.
      Code:
      * NOTICE: I'm changing the values and their labels to line up with the
      * original hand-written example
      label define fractionality ///
          1 "Highly Fractionalised" ///
          2 "Less Fractionalised" ///
          3 "Reference (Autocracy)"
      generate byte fractionality:fractionality ///
          = cond(dem, cond(HIEF>threshold, 1, 2), 3)
      
      tab fractionality
      
      table (var) (fractionality), ///
          statistic(count *_gdp) ///
          statistic(mean *_gdp) ///
          statistic(sd *_gdp) ///
          sformat("(%s)" sd) ///
          nformat(%3.2f mean sd) ///
          nototals
      
      * modify some result labels
      collect label levels result ///
          count "Obs" ///
          sd "(Std)" ///
          , modify
      
      * hide the title for fractionality
      collect style header fractionality, title(hide)
      
      * put the results in the columns
      collect layout (var) (fractionality#result)

      Comment


      • #18
        So, we need a slightly more complicated way of creating the variable fractionality.

        Code:
        label define fractionality      0       "Less Fractionalised"   ///
                1       "Highly Fractionalised" ///
                2        "Autocracy (Reference)"
        
        assert high_frac_dem == !low_frac_dem if dem == 1
        
        gen byte fractionality:fractionality = 1.high_frac_dem
        replace fractionality = 2 if dem == 0
        
        label var fractionality "Degree of Fractionalization"

        Comment

        Working...
        X