Announcement

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

  • Repeated measures ANCOVA

    I have a study in which we evaluated the effects of a drug and pH of the culture medium upon the twitch rate (TR) of tissue in vitro. We hypothesise that TR is affected by both drug and pH, so tissues were incubated for one hour in varying concentrations of drug and different pH. TR and pH were measured at the start (TR0, pH0) and end (TR1, pH1) of culture. pH0 was fixed as much as possible, but varied within each nominal group, and changed slightly over the incubation period (it's a bicarbonate-buffered medium).

    So, I have an ordinal independent variable, CONC, a nominally ordinal independent variable, pH0 (which is in effect more continuous than ordinal), and repeated measures of interest (TR0, TR1).

    I thought that repeated-measures ANOVA or ANCOVA might help here. I can use the former if I block or bin pH0 and use that as a independent ordinal variable in the model. Or I could use it as a continuous variable. But since pH changes, and can influence TR, ideally I would use it as a repeated measures covariate. Is this even possible? It doesn't seem so from the menu dialogue box.
    Stata 14.2MP
    OS X

  • #2
    make sure your data are in long format (one observation per time point); then "xtset" the data and you whatever regression model is appropriate for "twitch rate" (I have never heard of this and can't help further); e.g., if TR is quantitative, use "mixed"

    Comment


    • #3
      Unfortunately, you didn't give full details about the sample size and the patterns of distribution of the variables. That said, it seems - mixed - can do the trick. Also, as an alternative, since you have measurements only twice (baseline "start" plus "end"), you might use just the differences in pH as well as TR, or a percentage of change.
      Best regards,

      Marcos

      Comment


      • #4
        just to be clear; the reason I suggested "mixed" instead of a pre-post, change score type analysis, was because the OP said, "since pH changes, and can influence TR, ideally I would use it as a repeated measures covariate." you could, of course, use the change in pH as a covariate but that would not be my choice

        Comment


        • #5
          Yes, you can fit a repeated-mesures ANCOVA model to your data using Stata's anova command. See here for an example (use the second example there, the one labeled "distinct covariate value for each observation").

          Note that the syntax has changed since then, with the advent of factor variables in Stata.
          Code:
          anova y c.x_sum a / individual#a c.x b a#b, repeated(b) bse(individual#a)

          Comment


          • #6
            Thank you all for your enlightening replies. Yes, I did need to convert the table from wide to long, that sorted out the variable problem that I mentioned. Sorry that it's taken so long to reply, and thank you, I got bogged down in the limitations of IC and had to upgrade Stata!

            Anyhow, to recap, I have fixed concentration (CONC_bin) and starting pH (pH_bin, multiplied by 10 so it can be a factor variable), and each tissue (ID) is nested within both of those independent variables. pH and TR are measured at two values of HOUR. So I have a nested, two-factor ANCOVA:
            Code:
            . anova TR CONC_bin pH_bin10 CONC_bin#pH_bin10 HOUR c.pH / ID|CONC_bin#pH_bin10, repeated(HOUR) dropemptycells
            I get this output:
            Code:
                                     Number of obs =        382    R-squared     =  0.7133
                                     Root MSE      =    49.2905    Adj R-squared =  0.4221
            
                              Source | Partial SS         df         MS        F    Prob>F
                ---------------------+----------------------------------------------------
                               Model |  1142499.6        192   5950.5185      2.45  0.0000
                                     |
                            CONC_bin |  128307.13          5   25661.426     12.11  0.0000
                            pH_bin10 |  293577.69          5   58715.537     27.71  0.0000
                   CONC_bin#pH_bin10 |  31754.423          6   5292.4038      2.50  0.0242
                                HOUR |  85443.146          1   85443.146     40.32  0.0000
                                  pH |  223602.51          1   223602.51    105.52  0.0000
                ID|CONC_bin#pH_bin10 |  368717.59        174   2119.0666
                ---------------------+----------------------------------------------------
                                     |
                            Residual |  459186.27        189    2429.557
                ---------------------+----------------------------------------------------
                               Total |  1601685.8        381   4203.8998
            
            
            Between-subjects error term:  ID|CONC_bin#pH_bin10
                                 Levels:  191       (174 df)
                 Lowest b.s.e. variable:  ID
                 Covariance pooled over:  CONC_bin#pH_bin10  (for repeated variable)
            
            Repeated variable: HOUR
                                                      Huynh-Feldt epsilon        =  1.0925
                                                      *Huynh-Feldt epsilon reset to 1.0000
                                                      Greenhouse-Geisser epsilon =  1.0000
                                                      Box's conservative epsilon =  1.0000
            
                                                        ------------ Prob > F ------------
                              Source |     df      F    Regular    H-F      G-G      Box
                ---------------------+----------------------------------------------------
                                HOUR |      1    40.32   0.0000   0.0000   0.0000   0.0000
                ID|CONC_bin#pH_bin10 |    174
                --------------------------------------------------------------------------
            But that residual is pretty huge, isn't it? Do I need to consider refining the model?
            Stata 14.2MP
            OS X

            Comment


            • #7
              Hello, I wanted to follow up on this thread as I fit a repeated measures ANCOVA to my model. My data includes a sample of 200 participants receiving 2 types of treatment, performance prior to treatment (covariate that is used as a baseline/control), and performance at 5 different time points following treatment. I'm running my work in Stata 12. While I followed Joseph Coveney's syntax closely, I've noticed that the output for my covariate does not match what I have found when I run the same model in JMP and R. I've found an abundance of information regarding repeated measures anova using Stata online (e.g. http://www.ats.ucla.edu/stat/stata/s...ysis_stata.htm) but the information for adding in a covariate or running repeated measures ANCOVA has been difficult to find. My overall output looks correct for my other variables in the model, except for the covariate, which drastically differs from what I get using JMP and R. Any insight would be greatly appreciated!

              Code:
              anova y c.x a / individual#a c.x b a#b, repeated(b) bse(individual#a)

              Comment


              • #8
                It seems as if you have a single covariate value for each participant. Try changing the syntax from
                Code:
                anova y c.x a / individual#a c.x b a#b, repeated(b) bse(individual#a)
                to
                Code:
                anova y c.x a / individual#a /* c.x */ b a#b, repeated(b) bse(individual#a)
                in line with the first example—Table 10.34 on Page 829 (single covariate for all observations)—in the cited post.

                Comment


                • #9
                  Thank you so much for your helpful reply, Joseph Coveney! You are correct that there is a single covariate value for every participant (baseline performance prior to treatment). However, I tried the modified code you suggested but it seems that the output for the covariate is still the same and incorrect. I've modeled after the codes in the cited post and both the first and second example did not work for me. Could this possibly be an issue with the version of Stata that I'm running (13.0) that uses slightly different syntax? The p-value for the covariate is p<0.05 in JMP and R but p>0.89 in Stata so the difference is non-negligible. Thank you for any insight!
                  Last edited by Nancy Tsai; 18 Oct 2016, 12:28.

                  Comment


                  • #10
                    Well, here: I've attached a do-file, its log file and dataset for the single-covariate-for-all-observations worked example from Winer, Brown & Michels that is shown in the post cited above.

                    The dataset is in comma-separated-value format, and so should be readily usable by both R and JMP.

                    Why don't you fit the repeated-measures ANCOVA model with both R and JMP using the syntax that you have been using, and post the log files here (both what's typed in and what's returned) so that we can take a look at what might be responsible for any differences.
                    Attached Files

                    Comment


                    • #11
                      Thank you so much, Joseph Coveney. I will take a stab at this and post everything. I appreciate your attention on this!

                      Comment


                      • #12
                        So, I reran everything using Stata, R(lme4 & lmer test packages), and JMP (pro12). For Stata, the output is the same as what you've posted in your log file but for JMP and R, there is a difference in the F and P values for x (baseline) but the same for all the other output. Thus, the problem is consistent with what I described above. The output is attached below.
                        Attached Files

                        Comment


                        • #13
                          Okay, you're using their analogues of Stata's
                          Code:
                          mixed y c.x i.a##i.b || individual: , reml dfmethod(satterthwaite)
                          and not of anova. I suspect that if you use their least-squares ANOVA function or procedure, you'd get the same ANOVA table as what Stata gives.

                          Anyway, if you're interested in a test of whether the regression coefficient is different from zero, use what R and JMP (and Stata's mixed , reml dfmethod(satterthwaite) or even xtreg y c.x i.a##i.b, i(individual) be) all show, and not what you get for anova. Winer, Brown and Michels (full citation in the post linked to earlier) don't even bother to show the continuous covariate information in their ANCOVA tables, just the adjusted test statistics for the categorical factors.

                          Comment


                          • #14
                            Originally posted by Joseph Coveney View Post
                            I suspect that if you use their least-squares ANOVA function or procedure, you'd get the same ANOVA table as what Stata gives.
                            That might not be the case. There's at least one other software package that computes correct sum of squares and test statistics for the continuous covariate in repeated-measures ANCOVA of this dataset: BMDP 2V. The printout is an appendix to a university technical report, which can be downloaded from here. The pertinent results (ANOVA table) are on Page 32 of the report.

                            It seems that Stata has a peculiar way of handling repeated-measures ANOVA and this has been commented on before on Statalist, "What SPSS still maintains over Stata is better ANOVA routines, particularly Repeated-Measures fixed-factor designs. Stata treats RM designs a bit strangely, I believe because it seems to "wrap" ANOVA code around Regression methods. It's non-intuitive and can provide results that aren't typical of RM ANOVA . . .."

                            Comment


                            • #15
                              Hi There,

                              I have a question despite all the help that has been provided here - I am trying to run a 2 x 2 (trt x week) RM ANCOVA. I want to control for one continuous (age) and one categorical variable (sex) at baseline. I have tried a few codes, but as I'm a bit of a Stata novice, I'm not exactly sure what the syntax I'm using means. I have been able to control for age using c.age, but the results vary depending on where I put it in the model.

                              I would like to know the effect of Vit D supplementation vs placebo (trt) on outcome y at 52 weeks compared to baseline (week = 0 or 52)

                              The syntax below gives me the same unadjusted results as someone (who is now AWOL) got in SPSS:
                              anova y trt/pid|trt week trt#week,rep(week)

                              Putting age here:
                              anova y c.age trt/pid|trt week trt#week,rep(week)
                              Or here:
                              anova y trt/pid|trt week trt#week c.age,rep(week)
                              ...yields different results - neither the same as the results from SPSS

                              I managed to get sex in the model by doing this:
                              anova y trt c.age / pid#age i.sex/pid#i.sex trt week trt#week, repeated(week) bse(pid#age)
                              ...but I don't actually know what it means...and the results are still inconsistent with the ones from SPSS.

                              Please help!

                              Thanks,
                              Charlotte

                              Comment

                              Working...
                              X