Announcement

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

  • power analysis after ttest

    I'm trying to import the means and stds from a two sample ttest into power twosample, but the power command seems to accept only typed-in numbers and not r() style pointers to numbers. Am I doing something wrong or is the power command?

    Here is what I tried:

    run the ttest
    . ttest s_wellbeing if gysj_inexper , by (gysj_yn)
    ... output deleted

    confirm that I can retrieve means and standard deviations using r() notation
    . dis r(mu_1) " " r(mu_2) " " r(sd_1) " " r(sd_2)
    3.3537638 3.4037035 1.0217724 .9781072

    power returns an error when I use the results from ttest in r() form
    power twomeans r(mu_1)r(mu_2), sd1(r(sd_1)) sd2(r(sd_2))
    means must contain numbers
    r(198);


    But it works fine if I type in the numbers directly
    power twomeans 3.3537638 3.4037035, sd1(1.0217724) sd2(.9781072)

    Performing iteration ...
    ... results deleted

  • #2
    You need to wrap your macro results in single quotes, as below, so that Stata can de-reference the macros before executing the power command.

    Code:
    power twomeans `r(mu_1)' `r(mu_2)', sd1(`r(sd_1)') sd2(`r(sd_2)')
    You may find it helpful to read the following documentation: -help quotes- and -help macro-.

    Comment


    • #3
      Thank you very much. That solved my problem. rek

      Comment

      Working...
      X