Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: RE: rmanova or anova with repeated command, what to use?


From   "Hoffman, George" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: RE: RE: rmanova or anova with repeated command, what to use?
Date   Sun, 9 Oct 2011 14:52:18 -0500

Pieter -
I think you want:
anova y subject group/subject|group##condition time, rep(time) bse(subject)

I also suggest inspecting your data graphically.
I suggest 'grby'
grby y group time, mean ci(95) 
this will help you decide if the statistics pass the smell test.


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Pieter-Jan
Sent: Sunday, October 09, 2011 4:05 AM
To: [email protected]
Subject: st: RE: RE: rmanova or anova with repeated command, what to use?

Hello George,

As you suggested i split 'group' into treatment group (air =1, oxygen=2) and
condition (normobaric=1, hyperbaric=2). Furthermore, I transformed time
started with 0h and ending 25h.
When I used the command anova y group##condition, rep(time) I got error
message: term not in model r 147.
So I changed the command to anova y group##condition time, rep(time) which
lead to the error message: could not determine between-subject basic unit;
use bseunit() option r(422). When using either group or condition in the
rep() term still got this r422 message.

Finally I used anova y subject group##condition time, rep(subject time) and
that lead to: 


                           Number of obs =     198     R-squared     =
0.8626
                           Root MSE      = 2.65175     Adj R-squared =
0.8496

                  Source |  Partial SS    df       MS           F     Prob >
F
 
--------------------+----------------------------------------------------
                   Model |  7945.33764    17  467.372802      66.47
0.0000
                         |
                 Subject |    7766.101    10    776.6101     110.44
0.0000
                   group |  15.1777131     1  15.1777131       2.16
0.1435
               condition |   93.324133     1   93.324133      13.27
0.0004
         group#condition |           0     0
                    time |  84.7484617     5  16.9496923       2.41
0.0382
                         |
                Residual |   1265.7239   180  7.03179944   
 
--------------------+----------------------------------------------------
                   Total |  9211.06154   197  46.7566576   


Between-subjects error term:  group#condition
                     Levels:  3         (0 df)
     Lowest b.s.e. variable:  group
     Covariance pooled over:  condition  (for repeated variables)

Repeated variable: subject
                                          Huynh-Feldt epsilon        =    .
                                          Greenhouse-Geisser epsilon =
0.1000
                                          Box's conservative epsilon =
0.1000

                                            ------------ Prob > F
------------
                  Source |     df      F    Regular    H-F      G-G      Box
 
--------------------+----------------------------------------------------
                 subject |     10   110.44   0.0000     .      0.0000
0.0000
                Residual |    180
 
-------------------------------------------------------------------------

Repeated variable: time
                                          Huynh-Feldt epsilon        =    .
                                          Greenhouse-Geisser epsilon =    .
                                          Box's conservative epsilon =
0.2000

                                            ------------ Prob > F
------------
                  Source |     df      F    Regular    H-F      G-G      Box
 
--------------------+----------------------------------------------------
                    time |      5     2.41   0.0382     .        .
0.1293
                Residual |    180
 
-------------------------------------------------------------------------

If I interpreted this right there is no significant difference between
treatment groups but there is between conditions. Time itself has also no
significant effect. But before I am going to use these results can you tell
me if I used the right command as you suggested or should I use another
format to look for treatment effect.

Once again many thanks

Sincerely Yours,

Pieter-Jan van Ooij

-----Oorspronkelijk bericht-----
Van: [email protected]
[mailto:[email protected]] Namens Hoffman, George
Verzonden: 5 oktober 2011 12:35
Aan: [email protected]
Onderwerp: st: RE: rmanova or anova with repeated command, what to use?

You might think about, and then organize, the dataset a little differently.
You want to compare the effects of two treatments on lung function, measured
repeatedly over time, before and after initiation of treatment. 
You have two treatment groups (air, O2) and two (or three) 'conditions'
(baseline, active day 2, active day 3).

(question: is day 2 hyperbaric, and day 3 normobaric? Or are both under the
same conditions, in which case you experiment would have only two
conditions)

In either case, you need to split your 'group' variable into two variables
that identify the treatment group (air, O2) and condition (baseline,
active).

ID		group		condition	hour
1,2...13	1,2		1,2 (3)	0,2,....22

This would allow you to use anova y group##cond, rep(hour) to look at
treatment effects.

Alternatively, you could code time as sequential hours form 0-72, then
xtdes, i(id) t(hour) and use the xt functions.

I hope this helps a little.
rmanova and anova should give similar results set up this way.

George Hoffman

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Pieter-Jan
Sent: Tuesday, October 04, 2011 2:58 PM
To: [email protected]
Subject: st: rmanova or anova with repeated command, what to use?

Dear statalisters,

Some time ago we performed a randomized crossover study in which we
monitored the lung function of a group of volunteers  during three days. Day
1 was used to determine baseline lung function whereas day 2 and 3 were used
to monitor lung function after inhaling either placebo (air) or active gas
(oxygen) under hyperbaric  condition. During each measurement day lung
function was measured 6 times. All variables and observations were put in a
dataset which initially had the following format:

ID           Group      Time                     Result1 etc
1             0          0                             6.19
2             0          0                             5.97
.             .          .                              .
.             .          .                              .
13            2          22                           5.33
Etc

ID exist of 13 persons (nr 1-13)
Group: 0 (baseline), 1 (placebo), 2 (active)
Time: pre, 0, 2, 4, 8, 12, 22 hours after exposure

We want to perform a repeated measures anova as all subject performed all
three test days which makes the groups not independent. The format we had in
mind was to search for differences between the groups at a specific time
point and to look for a correlation between Result1, etc and variable time.
I found two possibilities of doing a repeated measures anova using Stata
9.2:

1.	Using Ado rmanova written by George Hoffman
2.	Using anova with command repeated.

I tried both commands but they gave some contradictory results. To gave an
example I put in the log results of one test:

. rmanova FEF50 id time group
ANOVA for var FEF50 by subject ID
n=198 df=32 R2=.90011879

between effect: group

                  Source |  Partial SS    df       MS           F     Prob >
F
 
-------------+----------------------------------------------------
                   group |   94.488177     2  47.2440885       0.17
0.8420
             id*group |  8196.56138    30  273.218713   

within effect: time

                  Source |  Partial SS    df       MS           F     Prob >
F
 
-----------+----------------------------------------------------
                    Time |   218.17681    17    12.83393       1.78
0.0343
                Residual |  1226.78373   170  7.21637487   



. anova FEF50 id group time, repeated(group time)

                           Number of obs =     198     R-squared     =
0.8668
                           Root MSE      = 2.68633     Adj R-squared =
0.8457

                  Source |  Partial SS    df       MS           F     Prob >
F
 
-----------+----------------------------------------------------
                   Model |  7984.27781    27  295.713993      40.98
0.0000
                         |
                    Id   |    7766.101    10    776.6101     107.62
0.0000
                   group |  45.8076387     2  22.9038193       3.17
0.0443
                    time |  123.688633    15  8.24590887       1.14
0.3222
                         |
                Residual |  1226.78373   170  7.21637487   
 
-----------+----------------------------------------------------
                   Total |  9211.06154   197  46.7566576   


Between-subjects error term:  id
                     Levels:  11        (10 df)
     Lowest b.s.e. variable:  id

Repeated variable: group
                                          Huynh-Feldt epsilon        =
0.6682
                                          Greenhouse-Geisser epsilon =
0.6227
                                          Box's conservative epsilon =
0.5000

                                            ------------ Prob > F
------------
                  Source |     df      F    Regular    H-F      G-G      Box
 
-----------+----------------------------------------------------
                   group |      2     3.17   0.0443   0.0651   0.0685
0.0784
                Residual |    170
 
-----------+----------------------------------------------------

Repeated variable: time
                                          Huynh-Feldt epsilon        =
0.4478
                                          Greenhouse-Geisser epsilon =
0.2469
                                          Box's conservative epsilon =
0.0667

                                            ------------ Prob > F
------------
                  Source |     df      F    Regular    H-F      G-G      Box
 
-----------+----------------------------------------------------
                    Time |     15     1.14   0.3222   0.3460   0.3482
0.3073
                Residual |    170
 
-----------+----------------------------------------------------

. log close

In rmanova there is a significant correlation with FEF50 and time
(p=0.0343), while in the anova with repeated command test there is none such
correlation. Can anyone advise us which option we should use: rmanova or
anova with the repeated command? Many thanks.

Sincerely Yours,

Pieter-Jan van Ooij

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index