You are on page 1of 9

Postgraduate course: Anova and Repeated measurements Day 4

Summarizing homework and exercises:


Postgraduate course
in

Exercise 3: weight and height


Exercise 5, 6 and 8: CRP

ANOVA and Repeated Measurements

Exercise 9: smoke

Day 4
Summarizing homework exercises.
Mogens Erlandsen
Deptartment of Biostatistics
Aarhus University

70 80 90
Inverse Normal

100

120
Weight (kg)
80
100
40

60

70

80 90 100 110
Inverse Normal

2 20

60

70
80
90
Inverse Normal

100

150

160 170
180
Inverse Normal

190

220

60

220

50

G3

60

Weight (kg)
80
100
40

40

0.9745

G2

60

60

correlation

150 160 170 180 190 200


Inverse Normal

We will focus on comparing group 1 and 3!

Height (cm)
180
200
160
140

140

160

0.9266

160

Height (cm)
180
200

Height (cm)
180
200

0.9763

1 40

group |
weight
height
-------+-------------------1 |
25
25
|
76.024
171.32
| 12.93478
13.8916
-------+-------------------2 |
25
25
|
83.14
179.2
| 12.47624
14.5545
-------+-------------------3 |
25
25
|
78.5
170.16
| 9.852623 11.33093
-------+--------------------

G1

Weight (kg)
80
100

Summary statistics: N, mean, sd (and correlation added)

120

Exercise 3: weight and height


120

Exercise 3: weight and height

140

160
180
200
Inverse Normal

Normal probability plots are OK!


3

Mogens Erlandsen, Deptartment of Biostatistics, Aarhus University, May 2011

Postgraduate course: Anova and Repeated measurements Day 4

Exercise 3: weight and height

Exercise 3: weight and height


Group 2

P-values (only) for comparing standard deviations (sdtest)


and means (ttest) for both variables (group 1 vs group 3)

We ight (kg)
80
100

120

Weight (kg)
70 80 90 10 0

Group 1

50

60

60

Variable

140

160
180
Height (cm)

200

140

160

180
Height (cm)

200

220

sdtest

ttest

Weight

0.19

0.45

height

0.32

0.75

10 0

Group 3

Weight (kg)
70
80
90

Apparently no difference between group 1 and 3, so we are


finished?!

60

Should we use Bonferroni correction when testing on 2


variables measured on the same subjects??? But that would
not affect the conclusion since both ps > 5%. What about
the high correlation between weight and height?

150

160

170
180
Height (cm)

190

Scatter plot as expected due to the high correlations


5

Exercise 3: weight and height

Exercise 3: weight and height


Simultaneous confidence limits for weight and height in each
group. Large overlap for each variable, but not together!

Multivariate analysis using Hotellings t-test:


The standard deviations on Weight and Height and their
correlation are equal in the two groups, p=0.27 (mvtest: test
for homogeneity).

Confidence ellipse
85

Means centered

p-value
(t-test)
0.45

Height (cm)

1.16 (-6.05; 8.27)

0.75

70

Group 1 3
Weight (kg)

Difference
(95% - CI)
-2.48 (-9.01; 4.06)

Weight (kg)
75
80

Hotellings t-test for equality of means on Weight and Height in


the two groups gives p=0.0032. This is in contrast to the
individual t-tests on Weight and Height:

165

170

175

180

Height (cm)
1
wmean

Note: wide confidence intervals!

boundary constant = .2857

Mogens Erlandsen, Deptartment of Biostatistics, Aarhus University, May 2011

Postgraduate course: Anova and Repeated measurements Day 4

Exercise 5, 6 and 8: CRP

Exercise 5, 6 and 8: CRP

22 neonatal pigs randomised to two groups:

Compare the development over time in the two groups, i.e.:


Test for parallel curves - compute successive differences (or
differences with respect to baseline) and test for equality of
these differences.

1. Sternotomy and CardioPulmonary Bypass (CPB, n=12)


2. Sternotomy alone (Sham, n=10)
Measured 4 times:

Test for equal level (assuming the curves are parallel)

1. Baseline, immediately after anaesthesia

Test for constant curves

2. 5 min after weaning off CPB


3. 2 hours post CPB

Choice of repeated measurement model

4. 4 hours post CPB

Model validation
Presenting the results
9

Exercise 5, 6 and 8:

Exercise 5, 6 and 8:

CRP

10

CRP
Variability increase
with time?

creac_p

10

15

15

Sham

20

CPB

10

3
time

time
Graphs by Group

mean CPB

m ean Sham

ln(CRP)

Sham

2.5

CPB

CRP
The distance between
curves increase with
time?

1.5

ln(CRP)
Constant distance, i.e.
parallel curves?

.5

lcreac_p

ln(CRP)
Variability more
homogeneous?
1

time

time
Graphs by Group

mean CPB

m ean Sham

11

Mogens Erlandsen, Deptartment of Biostatistics, Aarhus University, May 2011

12

Postgraduate course: Anova and Repeated measurements Day 4

Exercise 5, 6 and 8: sd vs mean for each group and time point

Note:

ln(CRP)

1.the baseline levels in the two groups can be different due to


unlucky randomisation.

.7

.8

CRP

Exercise 5, 6 and 8: CRP

Let us first examine whether the differences can be described by


a multivariate normal distribution in each group.

.5

(sd) lcre ac_p


.6

(sd) creac_p

2.the pairwise differences could in principle show a more


constant variability than the raw data

.4

And if accepted, then test whether the sds and corrs in each
group are equal (homogeneity/heterogeneity)

6
8
(mean) creac_p

(sd) creac_p

10

12

.5

(sd) creac_p

1.5
2
(mean) lcreac_p

(sd) lcreac_p

2.5

(sd) lcreac_p

13

CRP

Group 2

Group 1

-2
-1
Inverse Normal

-.8

-4

-2
0
Inverse Normal

-1

d34
-5
-3

-2
-1
Inverse No rmal

-.4
-.2
Inverse Normal

0
Inverse Normal

.5

-.6
- .4
Inverse Normal

-.2

.2

-.8

lnd23
- 1 - .5 0 .5 1
-6

-10

d34
-5
- 10
-4

-.6

-.5

lnd34
- 2- 1.5- 1 - .5 0 .5

-1
0
Inverse No rmal

lnd12
-1 -.5 0

-8

-6

-4
Inverse Normal

-2

-1

-.6

-.4
-.2
Inverse Normal

lnd23
-1 -.5 0 .5 1

-3

-2

-3

.5

.5
lnd12
- 1 - .5 0
-4

-1

-.5

0
Inverse Normal

.5

-1.5

-1

-.5
Inverse Normal

.5

lnd34
-2-1.5-1 -.5 0 .5

d23
-8 -6 -4 -2 0 2

-1
0
Inverse No rmal

d23
-8 -6 -4 -2 0 2

-2

Group 2
ln(CRP)

d12
-4 -3 -2 -1 0 1

d12
- 4 -3 - 2 - 1 0 1

Group 1

14

-.8

15

Mogens Erlandsen, Deptartment of Biostatistics, Aarhus University, May 2011

16

Postgraduate course: Anova and Repeated measurements Day 4

Exercise 5, 6 and 8: CRP vs ln(CRP)

Exercise 5, 6 and 8: CRP, Summary


The statistical analysis was performed on the natural logarithm to CRP.

Differences
in each group
Prob. Plots
Homogeneity of
sds and corrs
between groups
Parallel curves

CRP

ln(CRP)

OK
p=0.035

OK
p=0.31

On the log-scale homogeneity between the two groups with respect to the
standard deviations on and the correlations between the four time points was
accepted, p=0.31.
Furthermore, a test for parallel curves was accepted, p=0.72 (Hotellings t-test
on the successive differences between time points).
A test for equal curves (distance = 0) was rejected, p=0.003.

p=0.019

In each group a test for a constant curve was rejected (G1: p=0.006 and G2:
p=0.007).

p=0.72

The constant distance (CPB-Sham) between the two time curves (ln-scale) was
estimated to : -0.58 ( -0.93; -0.22).
Bback-transforming with exponential function the median level in the CPBgroup was 56% (39%; 80%) lower than in the sham group.

Note: also present at time 0, - due to randomisation?


17

18

Exercise 5, 6 and 8: CRP, ln-transformed

Exercise 5, 6 and 8: CRP, ln-transformed

Can we use the anova-approach on ln-data?

anova lcreac_p group/id|group time time*group, repeated(time)


Parts of the output:

Test the assumption with equal sds and equal corrs in each
group (compound symmetry):

Between-subjects error term:

mvtest cov lcreac_p1 lcreac_p2 lcreac_p3 lcreac_p4 if group==1, compound

id|group

Levels:

22

Lowest b.s.e. variable:

id

Covariance pooled over:

group

(20 df)

(for repeated variable)

Repeated variable: time

Test that covariance matrix is compound symmetric

Huynh-Feldt epsilon

Adjusted LR chi2(8) =

6.66

Prob > chi2 =

0.5734

Accept!
Source |

Test that covariance matrix is compound symmetric


12.25

Prob > chi2 =

0.1403

1.0708

Greenhouse-Geisser epsilon =

0.8759

Box's conservative epsilon =

0.3333

------------ Prob > F ------------

mvtest cov lcreac_p1 lcreac_p2 lcreac_p3 lcreac_p4 if group==2, compound

Adjusted LR chi2(8) =

*Huynh-Feldt epsilon reset to 1.0000

df

Regular

H-F

G-G

Box

-----------+---------------------------------------------------time |

26.02

0.0000

0.0000

0.0000

0.0001

time*group |

0.56

0.6406

0.6406

0.6184

0.4612

Residual |

60

No significant difference between the groups with respect to


changes over time (parallel curves) , p=0.64.

Now, try the univariate Repeated Measurements ANOVA:


19

Mogens Erlandsen, Deptartment of Biostatistics, Aarhus University, May 2011

20

Postgraduate course: Anova and Repeated measurements Day 4

Exercise 5, 6 and 8: CRP, ln-transformed

Exercise 5, 6 and 8: CRP, ln-transformed

Output continued

Output continued
Prob > F

time |

-----------+----------------------------------------------------

Source |

Model |

Partial SS

28.7046272

df

MS

24

1.19602613

10.50

0.0000

Residual |

8.91097139

2.9703238

7.17326304

63

.113861318

26.09

0.0000

-----------+----------------------------------------------------

group |

7.24130137

7.24130137

id|group |

12.5523544

20

.627617722

11.54

0.0029

Total |

35.8778902

87

.412389543

-----------+--------------------------------------------------------------- Prob > F -----------Source |

Significant distance between the parallel curves, p=0.003.

df

Regular

H-F

G-G

Box

-----------+---------------------------------------------------time |

Residual |

63

26.09

0.0000

0.0000

0.0000

0.0000

Significant changes over time, p<0.001. (curve not constant)


21

.6

Checking the model ( anova): ln-transformed data

Exercise 5, 6 and 8: CRP, ln-transformed


Standard deviations (within, between and total) and
correlations (on repeated measurements) are useful in
the planning new studies:

.4

1
Residuals
-.5
0
.5

-.2

Residuals
0
.2

residual probability-plot

ln(CRP)

-1

-.4

22

.5

1.5
2
Linear prediction

2.5

-.5

0
Inverse Normal

.5

sW

sB

sT

Correlation

0.3079

0.2973

0.4280

0.4823

0.3775

0.4196

0.5644

0.5527

0.3410

0.3575

0.4941

0.5237

combined

Standard deviations on the lnscale can be transformed to


CVs on the original scale
using the formula:

-1

-1

-.5

Residuals
-.5
0
.5

Residuals
0
.5

residual probability-plot

group

.5

1.5
2
Linear prediction

2.5

-.5

0
Inverse Normal

.5

Not too bad!

CV = exp( 2 ) 1

23

Mogens Erlandsen, Deptartment of Biostatistics, Aarhus University, May 2011

24

Postgraduate course: Anova and Repeated measurements Day 4

Exercise 5, 6 and 8: CRP, ln-transformed

Exercise 5, 6 and 8: CRP, ln-transformed

Random coefficient model (part of output):

Random coefficient model with common slope

---------------------------------------------------------------------------

-------------------------------------------------------------------------

lcreac_p |

Coef.

Std. Err.

P>|z|

lcreac_p |

[95% Conf. Interval]

Coef.

Std. Err.

P>|z|

[95% Conf. Interval]

-----------+------------------------------------------------------------

-------------+------------------------------------------------------------_Igroup_2 | .4552144

.1915084

2.38

0.017

.0798649

.8305639

_Igroup_2 | .5522262

.1706731

3.24

0.001

.217713

.8867394

time1 | .2336667

.0483935

4.83

0.000

.1388172

.3285161

time1 | .2702991

.0358923

7.53

0.000

.1999515

.3406468

_cons | .763155

.1229118

6.21

0.000

.5222524

1.004058

_IgroXtime~2 | .0805914

.0717791

1.12

0.262

-.0600931

.2212759

_cons | .8072513

.1291149

6.25

0.000

.5541907

1.060312

-------------------------------------------------------------------------

---------------------------------------------------------------------------

Statistical significant difference between levels of the two


groups (distance between regression lines), p=0.001.

No statistical significant difference between slopes of the two


groups, p=0.26.

Note: Estimated distance similar to previous analysis (-0.58).


Sign has changed in xtmixed since group 1 is reference.

.6

1
Residuals
0
.5

Exercise 9: Smoke
Complicated design: cross-over experiment with 3 treatments.
5 factors to consider:

G1
OK

Day: 3 experimental days


Order: 3 treatments can be arranged in 3!=3x2x1=6 different
ways (carry-over effect?)

-1

-.4

-.5

-.2

Resid uals
0
.2 .4

Checking the model (xtmixed): ln-transformed data

0
Inverse Normal

.5

Conc: 3 treatments (doses)


G2
OK?

Time: 5 repeated measurements over time


Sub: 12 subjects (2 randomised to each order)

-1

-1

-.5

-.5

-.5

Re siduals
0
.5

1.6

1
1.2
1.4
Linear predicti on, fixed portion

Resid ua ls
0
.5

.8

1.4

1.6
1.8
2
Linear predicti on, fixed portion

2.2

-1

-.5

0
Inverse Normal

.5

27

Mogens Erlandsen, Deptartment of Biostatistics, Aarhus University, May 2011

28

Postgraduate course: Anova and Repeated measurements Day 4

Exercise 9: Smoke

Exercise 9: Smoke

Which factors are of primary interest?

200 0 ug/m3

0 ug/m3

Conc and Time (and their interaction Conc x Time)


2

Which factors should be treated as random?


FEV1 (l)

Sub
Sub x Day

Subject variation within days 

Residual

Similar developements.

More comments:
Order is nested within Sub
Conc is nested within Sub x Day

Individual time courses


for each dose.

Subject variation between days

400 ug/m3
6

Between Subjects variation

Or what contribute to the random variation?

Time
Graphs by Smoke concentration

29

Exercise 9: Smoke

4.5

Exercise day 3: Smoke mean curve for each dose

30

Stata command (univariate ANOVA with repeated meas.):

anova fev1 order/sub day conc/sub#day time conc#time, ///

(mean) fev1
3
3.5

bse(sub#day) repeated(time)

2.5

Note the ordering of the terms is significant:

2
Time
0 My-g/m 3
400 My-g/m3

1. Order/Sub

Sub is the highest level

2. Day Conc/Sub#Day

Sub#Day is next level

3. Time Conc#Time

Residual is lowest level

200 My-g/m3

31

Mogens Erlandsen, Deptartment of Biostatistics, Aarhus University, May 2011

32

Postgraduate course: Anova and Repeated measurements Day 4

Exercise 9: Smoke (part of output)


Number of obs =

180

R-squared
Root MSE

Source |

Exercise 9: Smoke

0.7883

= .545361

Partial SS

df

Adj R-squared =
MS

The ordering of doses is not significant, p=0.81

0.7130
Prob > F

There is no systematic differences between days, p=0.14


(could otherwise be caused by hay fever season?)

-----------+---------------------------------------------------Model |

146.22137

47

3.11109298

10.46

0.0000

0.44

0.8054

|
order |

11.2357365

2.24714731

sub |

30.4588088

5.07646813

The interaction between conc and time is highly significant


(p<0001) implying that the curves are not parallel

-----------+---------------------------------------------------day |

2.10456305

1.05228152

2.15

0.1428

conc |

6.31116623

3.15558312

6.44

0.0069

sub#day |

9.79468626

20

.489734313

-----------+---------------------------------------------------time |

38.7599307

9.68998269

32.58

0.0000

conc#time |

26.3799861

3.29749827

11.09

0.0000

39.2593241

132

.297419122

|
Residual |

-----------+---------------------------------------------------Total |

185.480694

179

1.036205

33

Exercise 9: Smoke - Checking the assumptions

Exercise 9: Smoke
Is FEV1 back to normal after 6 hours?

Residuals
0
-.5

Treat each conc separately, since curves are not parallel.


Use lincom on the conc#time estimates (se do-file for details)

3.5
4
4.5
Linear prediction

2
3
4
Linear prediction

1.5

1.5
1

Estimated differences between 0 and after 6 hours.

----------------------------------------------------------------fev1 |
Coef.
Std. Err.
t
P>|t|
[95% Conf. Interval]
------+---------------------------------------------------------(1) | -.01583
.22264
-0.07
0.943
-.45624
.42457
-----------------------------------------------------------------

Residuals
0
.5

Residuals
0
.5

(2) | -.08250
.22264
-0.37
0.712
-.52291
.35791
-----------------------------------------------------------------

-1

-.5

-.5
-1
-.5
0
.5
Inverse Normal

2
4
Linear prediction

residual probability-plot

residual probability-plot

1.5
Residuals
0
.5
-.5
-1
-1

bse(sub#day) repeated(time)
0

residual probability-plot

anova fev1 order/sub day/sub#day conc#time, ///

-1

-1

-1

- .5

.5

1.5
Residuals
0
.5
-.5

Conc 400

Conc 200

Residu als
0
.5

Conc 0

-1

-.5
0
.5
Inverse Normal

34

-1

-.5
0
.5
Inverse Normal

(3) |
.98917
.22264
4.44
0.000
.54876
1.4296
-----------------------------------------------------------------

35

Mogens Erlandsen, Deptartment of Biostatistics, Aarhus University, May 2011

36

You might also like