Announcement

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

  • Help with the collect command

    I hope someone can help me with the new-ish collect command. I think it is what I want to use to construct a table, but find the syntax beyond me.

    The situation

    I have agents of three agent_types: high, med and low. I wish to do a t-test of the variable, rmse_mean, for each agent_type against the other two.

    My goal is a table that looks like this.


    Code:
    Pairwise T-Test Results:
    Mean_RMSE by Agent Type
    
    | Comparison    | T-Statistic | P-Value |
    |---------------|-------------|---------|
    | High vs Med   | 3.25        | 0.009   |
    | High vs Low   | 5.80        | < 0.001 |
    | Med vs Low    | 2.10        | 0.041   |
    
    Note: P-values < 0.05 indicate statistical significance.


    I've run the t-tests with the
    Code:
    collect
    prefix (shown below, although I perhaps needed to be adding more syntax).

    After this, I'm totally stumped.

    Can anyone help?

    Thanks

    Code:
    collect:  ttest rmse_mean if agent_type == "high" | agent_type == "med", by(agent_type) unequal
    
    collect:  ttest rmse_mean if agent_type == "med" | agent_type == "low", by(agent_type) unequal
    
    collect:  ttest rmse_mean if agent_type == "high" | agent_type == "low", by(agent_type) unequal
    _______________________________________

    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
    Code:
    sysuse census, clear
    collect clear
    collect: ttest medage if region==1 | region==2, by(region)
    collect: ttest medage if region==1 | region==3, by(region)
    collect: ttest medage if region==1 | region==4, by(region)
    
    collect label levels cmdset 1 "NE vs N Ctrl" 2 "NE vs South" 3 "NE vs Central"
    collect style autolevels result t p
    collect label levels result t "T-statistic" p "P-value", modify
    collect style cell, nformat(%7.2f)
    collect notes 1: "P-values < 0.05 indicate statistical significance."
    collect layout (cmdset) (result)
    Res.:

    Code:
    . collect layout (cmdset) (result)
    
    Collection: default
          Rows: cmdset
       Columns: result
       Table 1: 3 x 2
    
    -----------------------------------
                  | T-statistic P-value
    --------------+--------------------
    NE vs N Ctrl  |        4.55    0.00
    NE vs South   |        2.60    0.02
    NE vs Central |        4.47    0.00
    -----------------------------------
    P-values < 0.05 indicate statistical significance.
    
    .

    Comment


    • #3
      Thank you, Andrew. That is perfect. Compliments to the Stata team for the power of collect. It's super powerful, even if some of us struggle to capture the power!
      _______________________________________

      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