Announcement

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

  • Export power analysis results as table

    Dear all,
    I am running into an issue with exporting output from my power analysis. I ran the analysis based on results from a pretest and I would now like to export the results for the preregistration site of the project. So far I have tried the tabout, eststo/esttab/estpost commands, the outreg2, and putexcel. The former three do not work, and with the latter the only way I can see it working based on what I've read, is to manually write a command for each part of information I'd like to include from the information in return list (i.e. putexcel B1 = `r(beta)' ).

    This is my power analysis. It returns the information below, which I would like to export in an efficient way.
    Code:
     power twomeans 2.952941 2.55814, sd1(1.318344) sd2(1.164218) n1(750) n2(750) table
    return list
    Code:
    Estimated power for a two-sample means test
    Satterthwaite's t test assuming unequal variances
    H0: m2 = m1  versus  Ha: m2 != m1
    
      +---------------------------------------------------------------------------------+
      |   alpha   power       N      N1      N2   delta      m1      m2     sd1     sd2 |
      |---------------------------------------------------------------------------------|
      |     .05       1   1,500     750     750  -.3948   2.953   2.558   1.318   1.164 |
      +---------------------------------------------------------------------------------+
    Is there a way to export this information into a table (into word or excel), as a whole with all the values from this table?

    Thank you in advance.

  • #2
    r class commands store results in r(). So you can append the stored matrices after each command and then export or export one at a time. The following uses estout from SSC.

    Code:
    power twomeans 2.952941 2.55814, sd1(1.318344) sd2(1.164218) n1(750) n2(750) table
    return list
    mat l  r(pss_table)
    Res.:

    Code:
    . power twomeans 2.952941 2.55814, sd1(1.318344) sd2(1.164218) n1(750) n2(750) table
    
    Estimated power for a two-sample means test
    Satterthwaite's t test assuming unequal variances
    Ho: m2 = m1  versus  Ha: m2 != m1
    
      +---------------------------------------------------------------------------------+
      |   alpha   power       N      N1      N2   delta      m1      m2     sd1     sd2 |
      |---------------------------------------------------------------------------------|
      |     .05       1   1,500     750     750  -.3948   2.953   2.558   1.318   1.164 |
      +---------------------------------------------------------------------------------+
    
    .
    . mat l  r(pss_table)
    
    r(pss_table)[1,10]
            alpha      power          N         N1         N2      delta         m1         m2        sd1        sd2
    r1        .05  .99998564       1500        750        750   -.394801   2.952941    2.55814   1.318344   1.164218
    suggests

    Code:
    matrix clear
    *ESTIMATION 1
    power twomeans 2.952941 2.55814, sd1(1.318344) sd2(1.164218) n1(750) n2(750) table
    mat res= nullmat(res)\r(pss_table)
    *ESTIMATION 2
    power twomeans 3 4, sd1(1) sd2(1.5) n1(750) n2(750) table
    mat res= nullmat(res)\r(pss_table)
    *EXPORT AS CSV THEN OPEN IN EXCEL
    esttab mat(res) using myfile.csv
    Click image for larger version

Name:	RES.png
Views:	1
Size:	15.8 KB
ID:	1687731

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      r class commands store results in r(). So you can append the stored matrices after each command and then export or export one at a time. The following uses estout from SSC.

      Code:
      power twomeans 2.952941 2.55814, sd1(1.318344) sd2(1.164218) n1(750) n2(750) table
      return list
      mat l r(pss_table)
      Res.:

      Code:
      . power twomeans 2.952941 2.55814, sd1(1.318344) sd2(1.164218) n1(750) n2(750) table
      
      Estimated power for a two-sample means test
      Satterthwaite's t test assuming unequal variances
      Ho: m2 = m1 versus Ha: m2 != m1
      
      +---------------------------------------------------------------------------------+
      | alpha power N N1 N2 delta m1 m2 sd1 sd2 |
      |---------------------------------------------------------------------------------|
      | .05 1 1,500 750 750 -.3948 2.953 2.558 1.318 1.164 |
      +---------------------------------------------------------------------------------+
      
      .
      . mat l r(pss_table)
      
      r(pss_table)[1,10]
      alpha power N N1 N2 delta m1 m2 sd1 sd2
      r1 .05 .99998564 1500 750 750 -.394801 2.952941 2.55814 1.318344 1.164218
      suggests

      Code:
      matrix clear
      *ESTIMATION 1
      power twomeans 2.952941 2.55814, sd1(1.318344) sd2(1.164218) n1(750) n2(750) table
      mat res= nullmat(res)\r(pss_table)
      *ESTIMATION 2
      power twomeans 3 4, sd1(1) sd2(1.5) n1(750) n2(750) table
      mat res= nullmat(res)\r(pss_table)
      *EXPORT AS CSV THEN OPEN IN EXCEL
      esttab mat(res) using myfile.csv
      [ATTACH=CONFIG]n1687731[/ATTACH]
      Thank you so much!

      Comment

      Working...
      X