Announcement

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

  • Exporting results after t-test, posthandle

    Hi All,

    I have data which resembles the following:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(group value) str1 action str7 group_description str9 country
    1  23 "x" "Group A" "Country X"
    1 322 "x" "Group A" "Country X"
    1   3 "y" "Group A" "Country X"
    1  12 "y" "Group A" "Country X"
    2  32 "x" "Group B" "Country Y"
    2  12 "x" "Group B" "Country Y"
    2  32 "y" "Group B" "Country Y"
    2  12 "y" "Group B" "Country Y"
    end
    Here, I have information on variable value, by group for different actions x and y. Moreover, in addition to the numeric group identifier, I have two further variables which vary only across groups (group_description and country). I wish to run a t-test (unequal variances) of equality of values by action within group and then save the results in a separate dta file. The command for the test would be:

    Code:
    by group, sort: ttest value, by(action) unequal
    The postfile class of commands is apt to then export this data. Not only do I wish to export the t-test and the associated p-value, I also want to describe the group, group_description and the country pertaining to that t-test (I have hundreds of such tests)


    Code:
    postfile handle str7 (group_description) str9 (country) double group float(t_stat p_value) using ttest_results, replace
    by group, sort: ttest value, by(action) unequal
    post handle ("country") ("group_description")  ("group")  (`r(t)') (`r(p)')
    postclose handle
    Unfortunately, a) the syntax returns an error and b) even with some contrivance when I get output, it is simply for the first group only. Any guidance on this is much appreciated!!


    Best,
    ​​​​​​​CS
Working...
X