Announcement

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

  • Stumped by collect/table for adding results of estat esize to result for ANOVA

    This seems like it should be simple, but it stumps me. I run an ANOVA, followed by "estat esize". I'd like to add a column with the eta2 from estat esize to a table of the ANOVA results.

    I can get the ANOVA tale, but am stumped how to add the column for the eta2. Can anyone help me out? Thanks.

    Code:
    collect: anova techs_chosen_150  i.exp_level##i.opt_level
    collect: estat esize
    
    collect layout (term[Model 1.exp_level 1.opt_level 1.exp_level#1.opt_level Residual]) (result[SS df ms F ] )
    To clarify, adding eta2 to the result[SS...] does not work, even though it shows up in "collect levelsof result". Same with esize.
    Last edited by ghoetker; 18 Oct 2025, 20:40.
    _______________________________________

    Glenn Hoetker
    Professor in Business Strategy

    Melbourne Business School, University of Melbourne
    200 Leicester Street, Carlton, Victoria 3053, Australia
    Email: [email protected]

    I acknowledge the Traditional Owners of the land on which I work, the Wurundjeri people of the Kulin Nations, and pay my respects to their Elders, past and present.

  • #2
    The essential problem is that the rows identifier for anova is in the dimension term, while the equivalent for estat esize is in rowname . We need to add the relevant tags.

    Consider this example:
    Code:
    collect clear
    sysuse auto, clear
    
    collect: anova price foreign##rep78
    collect: estat esize
    
    local lvls  Model 0.foreign 1.rep78 0.foreign#1.rep78 Residual
    local labels Model foreign rep78 foreign#rep78 Residual
    local num_lvls: list sizeof lvls
    forval l = 1/`num_lvls' {
        local lvl: word `l' of `lvls'
        local lbl: word `l' of `labels'
        collect addtags term[`lvl'], fortags(rowname[`lvl'])
        collect label levels term `lvl' "`lbl'", modify
    }
    
    collect style header result[esize], title(hide) level(hide)
    collect style header colname, title(hide)
    collect style cell result[SS], nformat(%13.1fc)
    collect style cell result[F] colname[eta2 lb_eta2 ub_eta2], nformat(%5.4f)
    collect layout (term) (result[SS df ms F] colname[eta2 lb_eta2 ub_eta2]#result[esize] )
    which produces:
    Code:
    . collect preview
    -------------------------------------------------------------------
                  |            SS df F statistic   eta2 lb_eta2 ub_eta2
    --------------+----------------------------------------------------
    Model         |  24,684,607.0  7      0.3896 0.0428       .  0.0519
    foreign       |     395,125.9  1      0.0437 0.0007       .  0.0573
    rep78         |   6,609,429.0  4      0.1826 0.0118       .  0.0256
    foreign#rep78 |  16,312,125.7  2      0.9011 0.0287       .  0.1277
    Residual      | 552,112,351.8 61                                  
    Total         | 576,796,958.9 68                                  
    -------------------------------------------------------------------

    Comment


    • #3
      Thank you again, Hemanshu.

      Sometimes I worry that the question I ask has a blindingly obvious answer that I've just missed...I don't think this is one of those times.

      The new-ish collect/etable/dtable/table approach is really powerful and flexible. I'm just finding myself slow to get my head around it.
      _______________________________________

      Glenn Hoetker
      Professor in Business Strategy

      Melbourne Business School, University of Melbourne
      200 Leicester Street, Carlton, Victoria 3053, Australia
      Email: [email protected]

      I acknowledge the Traditional Owners of the land on which I work, the Wurundjeri people of the Kulin Nations, and pay my respects to their Elders, past and present.

      Comment

      Working...
      X