Announcement

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

  • Collect Prefix Command and Ttest results

    Hi all,

    In Stata 17 I've been trying to work with the collect command to produce some Latex tables! Currently I use the collect prefix command on the ttest command (paired ttest). Then I use
    Code:
     return list
    to view the stored scalars from the ttest command. I notice that some scalars of interest are not stored. In particular, the table reports the difference between the two sample means, but this difference is not stored. Is there a way to access this scalar so that I can then include it in the collect table, or is there a way I can manually add this scalar to the collect table? I've included the exact code I have, but it is only a couple of lines:

    Code:
    collect: ttest median_family_income, by(diff)
    return list
    collect layout (colname) (result[mu_1 mu_2])

    Thanks!
    -- Ethan

  • #2
    Ethan:
    welcome to this forum.
    Surely off-target here, but -ttest- is conceived for detecting difference between two means, not medians.
    See -qreg- instead.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,

      Thank you for the warm welcome. The variable name is likely confusing as it is the median family income a census tract. I use the ttest to test the difference between the average median family income in census tracts that are in group 1 vs. group 2.

      -- Ethan

      Comment


      • #4
        You can store the value in a local.

        Code:
        local diff= r(mu_1)-r(mu_2)
        di `diff'

        Comment


        • #5
          Code:
           collect get r() diff = r(mu_1)-r(mu_2) : ttest price , by(foreign)
          Code:
          .   collect levelsof result
          
          Collection: default
           Dimension: result
              Levels: N_1 N_2 df_t diff level mu_1 mu_2 p p_l p_u sd sd_1 sd_2 se t

          Comment


          • #6
            Thanks both Bjarte and Andrew! I went with Bjarte's method.

            Comment

            Working...
            X