Announcement

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

  • Paired t-test with interaction term

    Hi,

    I am hoping to do a paired t-test to look at pre- and post-intervention activity levels, with an interaction term for the season when activity was measured (as season may affect most pre and post levels).
    The code would be this without season in.
    ttest week1activitylevel==week4activitylevel
    If week1season is variable for season in which week 1 activity took place, and week4season is season in which week 4 activity took place, could I just do
    ttest week1activitylevel==week4activitylevel i.week1season i.week4season

  • #2
    No. This t test is about comparison of means for an outcome between two groups. Nothing else.

    Otherwise put, this command is illegal in Stata. Extra predictors are irrelevant to the test.

    But the idea doesn't make much sense statistically so far as I can see. Usually a particular week is entirely within one season, so season doesn't add any information. It is like saying "the second week of December" and adding "that is within the Southern Hemisphere summer". But that that is not extra information, and season is constant for that group any way.
    Last edited by Nick Cox; 13 Dec 2023, 11:06.

    Comment


    • #3
      Dharani:
      as an aside to NIck's helpful advice, I think you have to consider -regress- (provided that -season- shows some variations).
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Hello dharani yerrakalva . Is Season also a repeated measures factor? I.e., are the same subjects measured in both seasons? If so, one option would be a two-factor ANOVA model with repeated measures on both factors. The interaction term in that model would test the null hypothesis that the Week 1 vs Week 4 difference does not depend on Season.

        But getting Stata to perform an old-school repeated measures ANOVA is not quite as straightforward as it might be--at least that's what I find (in comparison with SPSS, for example). But another option is to use the -mixed- command. I think that something like the following example might do the trick.

        Code:
        * Use the example found here:
        * https://www.stata.com/support/faqs/statistics/repeated-measures-anova/#half713
        use http://www.stata-press.com/data/r14/t713, clear
        * Drop rows to make it a 2x2 RM design
        keep if period < 3 & dial < 3 & noise < 2
        drop noise // not needed for this example
        * Rename variables to make them match Dharani's variable names
        rename (subject period dial ) (id week season)
        list, clean
        * Notice the long file format
        mixed score week##season || id:, reml dfmethod(repeated)
        margins week#season
        marginsplot
        * Get simple main effects of week for each season
        contrast week@season
        I hope this helps.
        --
        Bruce Weaver
        Email: [email protected]
        Version: Stata/MP 18.5 (Windows)

        Comment


        • #5
          Thanks all! Nick Cox. The intervention is walking-in summer in UK, weather is better and therefore for greater walking time is more likely The intervention was started at different time points in the year on a rolling basis, so season would have been different for Week 1 between individuals and potentially the follow-up week as well. This is more pertinent for comparison to a later follow-up week e.g. difference between week 1 mean and week 24 mean for each individual (e.g If week 1 was in Summer and week 24 winter for one individual, and vice versa for another). I hope clarifies why I want to take season into account.
          Carlo Lazzaro yes I was thinking that, thank you. Bruce Weaver I will try this, yes season is a repeated measure.

          Comment


          • #6
            Wanting a more elaborate model is fine. I don't follow what your model would be; it's just not one that you can reduce to a call to the ttest command.

            Comment

            Working...
            X