Announcement

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

  • help with t tests and summary statistics

    I suspect I am asking something quite simple, however after reviewing the ttest help file I am still quite stuck
    I have a hospital dataset with episode level records for 19 procedures before and after an intervention: Int1 (a binary variable before and after intervention)
    I am attempting to undertake a ttest to compare mean age, gender, IMD, charlson, by Int1, and produce a summary table showing confidence intervals and p values.
    I currently do not know any other way of doing this apart from running: ttest age if procedure=="procedure1", by(Int1) 76 times for different combinations of procedure, and patient characteristics
    I would be very grateful for any advice regarding a quick way to do this, including exporting results using eststo/etstab, which I have so far found unsatisfactory for this purpose
    Thank you in advance, I find the advice on this forum extremely useful.

  • #2
    Use -levelsof- to extract the unique procedures, and the loop through it.

    Code:
    levelsof procedure, local(proc)
    
    foreach x of local proc{
        ttest age if procedure == "`x'", by(Int1)
    }
    No input on the esttab given that little information provided (how many, how to group/lay out the table, how many files, etc.). You may have to figure that out. However, theoretically, you can incorporate esttab command inside the loop.

    I also have some additional comments that are not Stata-related. gender is usually not recorded as a continuous variable so t-test is perhaps not a good choice. Not sure what IMD is but also check Charlson, which works like a weighted count variable and based on your subject make-up it can be rather right-skewed due to extreme values; t-test may work if sample is large enough, but if not, cross-check your conclusion with some other tests for non-parametric statistics or counts as well.

    Comment

    Working...
    X