Announcement

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

  • Different results in "Mixed" and "ANOVA"

    Hello

    I would be most grateful if you could help with a problem I am experiencing using Stata.
    Essentially I am obtaining substantially different results when using mixed effects model as compared with repeated measures ANOVA and I am not sure why this is happening.

    Experiment:
    - Two groups of subjects (healthy subjects – HC; diseased subjects – DS) performed an experimental task.
    - There is one dependent variable “DV”.
    - Each subject performed four different experimental conditions, defined by a combination of 2 independent variables:
    • Difficulty (easy 0, difficult 1)
    • Distraction (without distraction 0, with distraction 1)
    - The four conditions were: Easy without distraction; Easy with distraction; Difficult without distraction; Difficult with distraction

    I am interested in measuring the effect of “group”, “difficulty” and “distraction” along with their respective interactions on the dependent variable (DV).

    I previously used mixed effects model ("mixed command") but in the field I am working reviewers prefer to see ANOVA instead of mixed effects model.

    Problem:
    groupXdistraction is significant when using mixed but now when using anova, and this makes a BIG difference in terms of result interpretation
    do you think I am misusing ANOVA command? do you see any obvious reason for this to happen?


    I am using the following commands:

    Code:
    mixed dv i.group##i.difficult##i.distraction ||id2:, stddev covar(unstr)


    Code:
    anova dv i.group / id2|i.group i.difficult i.distraction i.group#i.difficult i.group#i.distraction i.difficult#i.distraction i.group#i.difficult#i.distraction, repeated(difficult distraction)



    Please see output below:

    Code:
     mixed dv i.group i.difficult i.distraction i.group#i.difficult i.group#i.distraction i.difficult#i.distraction i.group#i.difficult#i
    > .distraction ||id2:, stddev covar(unstr)
    Note: single-variable random-effects specification in id2 equation; covariance structure set to identity
    
    Performing EM optimization:
    
    Performing gradient-based optimization:
    
    Iteration 0:   log likelihood = -707.02709  
    Iteration 1:   log likelihood = -707.02709  
    
    Computing standard errors:
    
    Mixed-effects ML regression                     Number of obs      =       168
    Group variable: id2                             Number of groups   =        42
    
                                                    Obs per group: min =         4
                                                                   avg =       4.0
                                                                   max =         4
    
    
                                                    Wald chi2(7)       =     22.57
    Log likelihood = -707.02709                     Prob > chi2        =    0.0020
    
    ---------------------------------------------------------------------------------------------
                             dv |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ----------------------------+----------------------------------------------------------------
                        1.group |   2.708238   7.587663     0.36   0.721    -12.16331    17.57978
                    1.difficult |   1.608696   3.428798     0.47   0.639    -5.111626    8.329017
                  1.distraction |  -3.217391   3.428798    -0.94   0.348    -9.937713     3.50293
                                |
                group#difficult |
                           1 1  |   8.812357   5.097882     1.73   0.084    -1.179309    18.80402
                                |
              group#distraction |
                           1 1  |   11.08581   5.097882     2.17   0.030     1.094147    21.07748
                                |
          difficult#distraction |
                           1 1  |   7.173913   4.849053     1.48   0.139    -2.330057    16.67788
                                |
    group#difficult#distraction |
                         1 1 1  |  -12.12128   7.209494    -1.68   0.093    -26.25163    2.009068
                                |
                          _cons |   47.73913   5.103407     9.35   0.000     37.73664    57.74162
    ---------------------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
      Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    id2: Identity                |
                       sd(_cons) |   21.53666   2.523021      17.11828    27.09547
    -----------------------------+------------------------------------------------
                    sd(Residual) |   11.62762   .7324712      10.27709    13.15563
    ------------------------------------------------------------------------------
    LR test vs. linear regression: chibar2(01) =   137.12 Prob >= chibar2 = 0.0000
    
    .
    end of do-file
    
    . do "C:\Users\TIAGOT~1\AppData\Local\Temp\STD00000000.tmp"
    
    . anova dv i.group / id2|i.group i.difficult i.distraction i.group#i.difficult i.group#i.distraction i.difficult#i.distraction i.group
    > #i.difficult#i.distraction, repeated(difficult distraction)
    
                               Number of obs =     168     R-squared     =  0.8412
                               Root MSE      = 11.9148     Adj R-squared =  0.7790
    
                      Source |  Partial SS    df       MS           F     Prob > F
       ----------------------+----------------------------------------------------
                       Model |  90247.9303    47  1920.16873      13.53     0.0000
                             |
                       group |  3857.21892     1  3857.21892       1.85     0.1819
                   id2|group |  83601.4894    40  2090.03724   
       ----------------------+----------------------------------------------------
                   difficult |  1797.30807     1  1797.30807      12.66     0.0005
                 distraction |  345.720878     1  345.720878       2.44     0.1213
             group#difficult |  78.7842568     1  78.7842568       0.55     0.4578
           group#distraction |  262.744688     1  262.744688       1.85     0.1762
       difficult#distraction |  12.8954043     1  12.8954043       0.09     0.7636
            group#difficult# |
                 distraction |  382.181119     1  382.181119       2.69     0.1035
                             |
                    Residual |   17035.403   120  141.961692   
       ----------------------+----------------------------------------------------
                       Total |  107283.333   167   642.41517   
    
    
    Between-subjects error term:  id2|group
                         Levels:  42        (40 df)
         Lowest b.s.e. variable:  id2
         Covariance pooled over:  group     (for repeated variables)
    
    Repeated variable: difficult
                                              Huynh-Feldt epsilon        =  1.0256
                                              *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
       ----------------------+----------------------------------------------------
                   difficult |      1    12.66   0.0005   0.0005   0.0005   0.0005
             group#difficult |      1     0.55   0.4578   0.4578   0.4578   0.4578
                    Residual |    120
       ---------------------------------------------------------------------------
    
    Repeated variable: distraction
                                              Huynh-Feldt epsilon        =  1.0256
                                              *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
       ----------------------+----------------------------------------------------
                 distraction |      1     2.44   0.1213   0.1213   0.1213   0.1213
           group#distraction |      1     1.85   0.1762   0.1762   0.1762   0.1762
                    Residual |    120
       ---------------------------------------------------------------------------
    
    Repeated variables: difficult#distraction
                                              Huynh-Feldt epsilon        =  1.0256
                                              *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
       ----------------------+----------------------------------------------------
       difficult#distraction |      1     0.09   0.7636   0.7636   0.7636   0.7636
            group#difficult# |
                 distraction |      1     2.69   0.1035   0.1035   0.1035   0.1035
                    Residual |    120
       ---------------------------------------------------------------------------


    Many thanks

    Jaime


  • #2
    You're going to want to use different error terms for your ANOVA model's higher-level interaction terms. Something maybe like the following.
    Code:
    #delimit ;
    anova dv
        group / id2|group
        difficult group#difficult / id2|group#difficult
        distraction group#distraction / id2|group#distraction
            difficult#distraction group#difficult#distraction;
    #delimit cr
    (Because you have only two levels of each of the intervention factors, you don't need the repeated() option.)

    You have only 42 people in your experiment. You could probably get closer correspondence between the results of your iterative maximum likelihood (mixed) model and those of your least-squares ANOVA model if you used finite denominator degrees-of-freedom approximations in the former. See the section for the dfmethod() option in the help file or user's manual entry for mixed. Also, use contrast for the p-values of your factors and their higher-level interactions after mixed in order to get closer correspondence with anova.

    Comment


    • #3
      Many thanks Joseph. I can now see that the problem was with the error terms.

      I wonder whether anyone could help with another (related) problem(s) I just stumbled with doing an ANOVA in the same experiment.

      The dependent variable is now rt (reaction time) and the independent variables are the same for the non adjusted analysis. I also added a few additional covariates for the adjusted analysis.

      I just start with the unadjusted analysis to give some context and help highlighting the inconsistencies in the adjusted analysis.

      1. Unadjusted analysis:

      Code:
       anova rt group / id2|group difficult group#difficult / id2|group#difficult distraction group#distraction / id2|group#distraction dif
      > ficult#distraction group#difficult#distraction
      
                                 Number of obs =     168     R-squared     =  0.9824
                                 Root MSE      = 32.2231     Adj R-squared =  0.9265
      
                        Source |  Partial SS    df       MS           F     Prob > F
         ----------------------+----------------------------------------------------
                         Model |   2316426.3   127  18239.5772      17.57     0.0000
                               |
                         group |  164910.115     1  164910.115       3.83     0.0573
                     id2|group |  1722282.79    40  43057.0697  
         ----------------------+----------------------------------------------------
                     difficult |    189775.6     1    189775.6      57.83     0.0000
               group#difficult |  596.571919     1  596.571919       0.18     0.6721
           id2|group#difficult |  131255.071    40  3281.37677  
         ----------------------+----------------------------------------------------
                   distraction |  37151.7742     1  37151.7742      25.27     0.0000
             group#distraction |  8230.83148     1  8230.83148       5.60     0.0229
         id2|group#distraction |  58813.9542    40  1470.34886  
         ----------------------+----------------------------------------------------
         difficult#distraction |   1332.2995     1   1332.2995       1.28     0.2641
              group#difficult# |
                   distraction |  1578.18045     1  1578.18045       1.52     0.2248
                               |
                      Residual |  41533.1053    40  1038.32763  
         ----------------------+----------------------------------------------------
                         Total |   2357959.4   167  14119.5174  
      
      . margins, within(group distraction)
      
      Predictive margins                                Number of obs   =        168
      
      Expression   : Linear prediction, predict()
      within       : group distraction
      Empty cells  : reweight
      
      -----------------------------------------------------------------------------------
                        |            Delta-method
                        |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
      ------------------+----------------------------------------------------------------
      group#distraction |
                   0 0  |   688.1739   4.751036   144.85   0.000     678.5717    697.7761
                   0 1  |   672.3261   4.751036   141.51   0.000     662.7239    681.9283
                   1 0  |   765.1842   5.227276   146.38   0.000     754.6195    775.7489
                   1 1  |   721.2105   5.227276   137.97   0.000     710.6458    731.7752
      -----------------------------------------------------------------------------------
      
      . margins, within(group distraction) pwcompare(effects)
      
      Pairwise comparisons of predictive margins
      
      Expression   : Linear prediction, predict()
      within       : group distraction
      Empty cells  : reweight
      
      -----------------------------------------------------------------------------------
                        |            Delta-method    Unadjusted           Unadjusted
                        |   Contrast   Std. Err.      t    P>|t|     [95% Conf. Interval]
      ------------------+----------------------------------------------------------------
      group#distraction |
        (0 1) vs (0 0)  |  -15.84783   6.718979    -2.36   0.023    -29.42739   -2.268263
        (1 0) vs (0 0)  |    77.0103   7.063763    10.90   0.000      62.7339     91.2867
        (1 1) vs (0 0)  |   33.03661   7.063763     4.68   0.000     18.76022    47.31301
        (1 0) vs (0 1)  |   92.85812   7.063763    13.15   0.000     78.58173    107.1345
        (1 1) vs (0 1)  |   48.88444   7.063763     6.92   0.000     34.60804    63.16084
        (1 1) vs (1 0)  |  -43.97368   7.392484    -5.95   0.000    -58.91445   -29.03292
      -----------------------------------------------------------------------------------
      The margins correspond to the means calculated as follows:

      Code:
      by group distraction, sort: summarize rt, detail
      
      --------------------------------------------------------------------------------------------------------------------------------------
      -> group = 0, distraction = 0
      
                                   rt
      -------------------------------------------------------------
            Percentiles      Smallest
       1%          508            508
       5%          515            509
      10%          527            515       Obs                  46
      25%          622            523       Sum of Wgt.          46
      
      50%        674.5                      Mean           688.1739
                              Largest       Std. Dev.      111.5523
      75%          758            849
      90%          836            856       Variance       12443.92
      95%          856            913       Skewness       .4191264
      99%          986            986       Kurtosis       2.790502
      
      --------------------------------------------------------------------------------------------------------------------------------------
      -> group = 0, distraction = 1
      
                                   rt
      -------------------------------------------------------------
            Percentiles      Smallest
       1%          463            463
       5%          518            498
      10%          546            518       Obs                  46
      25%          591            545       Sum of Wgt.          46
      
      50%          666                      Mean           672.3261
                              Largest       Std. Dev.      101.3208
      75%          746            828
      90%          802            850       Variance       10265.91
      95%          850            857       Skewness       .0892665
      99%          881            881       Kurtosis       2.270214
      
      --------------------------------------------------------------------------------------------------------------------------------------
      -> group = 1, distraction = 0
      
                                   rt
      -------------------------------------------------------------
            Percentiles      Smallest
       1%          547            547
       5%          552            552
      10%          573            561       Obs                  38
      25%          680            573       Sum of Wgt.          38
      
      50%        765.5                      Mean           765.1842
                              Largest       Std. Dev.      130.5392
      75%          886            953
      90%          953            967       Variance       17040.48
      95%          982            982       Skewness       .0387798
      99%          991            991       Kurtosis       1.953949
      
      --------------------------------------------------------------------------------------------------------------------------------------
      -> group = 1, distraction = 1
      
                                   rt
      -------------------------------------------------------------
            Percentiles      Smallest
       1%          511            511
       5%          553            553
      10%          566            557       Obs                  38
      25%          635            566       Sum of Wgt.          38
      
      50%          731                      Mean           721.2105
                              Largest       Std. Dev.      116.0257
      75%          829            857
      90%          857            861       Variance       13461.95
      95%          931            931       Skewness       .1795146
      99%          997            997       Kurtosis       2.346136

      2. Adjusted analysis:

      Code:
      anova rt group / id2|group difficult group#difficult / id2|group#difficult distraction group#distraction / id2|group#distraction dif
      > ficult#distraction group#difficult#distraction c.education c.cfs c.pain c.gad c.phq c.jss c.sdq c.oci
      
                                 Number of obs =     160     R-squared     =  0.9841
                                 Root MSE      = 29.9511     Adj R-squared =  0.9334
      
                        Source |  Partial SS    df       MS           F     Prob > F
         ----------------------+----------------------------------------------------
                         Model |  2108601.34   121  17426.4574      19.43     0.0000
                               |
                         group |  30107.0519     1  30107.0519       0.66     0.4238
                     id2|group |  1373281.22    30  45776.0407  
         ----------------------+----------------------------------------------------
                     difficult |  204674.566     1  204674.566      67.53     0.0000
               group#difficult |  40.7163683     1  40.7163683       0.01     0.9083
           id2|group#difficult |  115178.884    38  3031.02325  
         ----------------------+----------------------------------------------------
                   distraction |  37442.1195     1  37442.1195      25.17     0.0000
             group#distraction |  8973.87526     1  8973.87526       6.03     0.0187
         id2|group#distraction |  56538.5997    38  1487.85789  
         ----------------------+----------------------------------------------------
         difficult#distraction |  589.341176     1  589.341176       0.66     0.4227
              group#difficult# |
                   distraction |  750.916176     1  750.916176       0.84     0.3660
                     education |  11933.3729     1  11933.3729      13.30     0.0008
                           cfs |   6807.1789     1   6807.1789       7.59     0.0090
                          pain |  6336.95163     1  6336.95163       7.06     0.0114
                           gad |  34115.5225     1  34115.5225      38.03     0.0000
                           phq |  36483.5112     1  36483.5112      40.67     0.0000
                           jss |  4119.55124     1  4119.55124       4.59     0.0386
                           sdq |  6570.61999     1  6570.61999       7.32     0.0101
                           oci |  23926.6335     1  23926.6335      26.67     0.0000
                               |
                      Residual |  34088.5588    38  897.067337  
         ----------------------+----------------------------------------------------
                         Total |   2142689.9   159  13476.0371  
      
      . margins, within(group distraction)
      
      Predictive margins                                Number of obs   =        160
      
      Expression   : Linear prediction, predict()
      within       : group distraction
      Empty cells  : reweight
      
      -----------------------------------------------------------------------------------
                        |            Delta-method
                        |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
      ------------------+----------------------------------------------------------------
      group#distraction |
                   0 0  |   688.1739   4.416046   155.83   0.000     679.2341    697.1137
                   0 1  |   672.3261   4.416046   152.25   0.000     663.3863    681.2659
                   1 0  |   759.7353   5.136568   147.91   0.000     749.3369    770.1337
                   1 1  |   713.5882   5.136568   138.92   0.000     703.1898    723.9867
      -----------------------------------------------------------------------------------
      
      . margins, within(group distraction) pwcompare(effects)
      
      Pairwise comparisons of predictive margins
      
      Expression   : Linear prediction, predict()
      within       : group distraction
      Empty cells  : reweight
      
      -----------------------------------------------------------------------------------
                        |            Delta-method    Unadjusted           Unadjusted
                        |   Contrast   Std. Err.      t    P>|t|     [95% Conf. Interval]
      ------------------+----------------------------------------------------------------
      group#distraction |
        (0 1) vs (0 0)  |  -15.84783   6.245232    -2.54   0.015    -28.49064   -3.205014
        (1 0) vs (0 0)  |   71.56138   6.773906    10.56   0.000     57.84833    85.27444
        (1 1) vs (0 0)  |   25.41432   6.773906     3.75   0.001     11.70127    39.12738
        (1 0) vs (0 1)  |   87.40921   6.773906    12.90   0.000     73.69615    101.1223
        (1 1) vs (0 1)  |   41.26215   6.773906     6.09   0.000     27.54909     54.9752
        (1 1) vs (1 0)  |  -46.14706   7.264204    -6.35   0.000    -60.85267   -31.44145
      -----------------------------------------------------------------------------------
      
      .

      In the adjusted analysis the effect of group loses significance. The diseased subjetcs - group 1 - have "much more" of any of the covariates as compared with the healthy controls - group 0.

      However, there are two strange things now happening:
      1. The margins for group 1 are now different from the means obtained by summarise and also different from the margins obtained in the unadjusted analysis BUT the margins for group 0 stay exactly the same!
      2. Although the effect of group has lost significance in the adjusted analysis, the pairwise comparison performed to explore the significant interaction between groupxdistraction reveals highly significant differences between each of the subgoups of group 1 and each subgroups of group 0 - this does not make any sense to me... if 1 0 and 1 1 are both significantly different from 00 and 01, I would expect to find a group effect...

      Am I doing something wrong in the way I am writing the anova command to add covariates? Or is there something else going on?

      Truly grateful for any help

      Jaime
      Last edited by Jaime Prata; 31 Jul 2020, 08:34.

      Comment

      Working...
      X