60
Random effects & Repeated measurements Bo Markussen [email protected] Department of Mathematical Sciences December 18, 2019 DSL (MATH) AS / SmB Day 5 1 / 60

Bo Markussen [email protected]/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen [email protected] Department of

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Random effects & Repeated measurements

Bo [email protected]

Department of Mathematical Sciences

December 18, 2019

DSL (MATH) AS / SmB Day 5 1 / 60

Page 2: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Lecture outline

Why is it called ANOVA?

Experimental design and random effects.I Hypothetical data example: Comparison of two treatments.

Data example 1: Color of pork meat.I Random effects in models with continuous response.

Data example 2: Germination of Orobanche seeds.I Overdispersion in logistic regression.

Data example 3: Growth of Baobab trees.I Repeated measurements.I General concepts about analysis of repeated measurements. We will

also briefly talk about analysis using summary measures.

DSL (MATH) AS / SmB Day 5 2 / 60

Page 3: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

ANalysis Of VAriance: Why this name?

Growth of rats example:vitamin

antibio 0 50 1.30, 1.19, 1.08 1.26, 1.21, 1.19

40 1.05, 1.00, 1.05 1.52, 1.56, 1.55

> anova(lm(growth~antibio+vitamin+antibio:vitamin,data=rats))

Analysis of Variance Table

Response: growth

Df Sum Sq Mean Sq F value Pr(>F)

antibio 1 0.020833 0.020833 5.6818 0.044292 *

vitamin 1 0.218700 0.218700 59.6455 5.622e-05 ***

antibio:vitamin 1 0.172800 0.172800 47.1273 0.000129 ***

Residuals 8 0.029333 0.003667

The total variation in the response is decomposed using the righthand side of ∼ from left to right(!):

SStotal =N∑i=1

(growthi − µgrowth

)2

= SSantibio + SSvitamin + SSantibio:vitamin + SSerror

DSL (MATH) AS / SmB Day 5 3 / 60

Page 4: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Sum-of-Squares and Mean-Sum-of-SquaresF-test: Is the systematic variation large relative to the random variation?

111

antibio12 vitamin1

2

antibio:vitamin14

[I]812

SSantibio, SSvitamin, SSantibio:vitamin,SSerror visualized by area of the greencircles.

0.04435.62e−05

0.000129

111

antibio12 vitamin1

2

antibio:vitamin14

[I]812

Variance estimates MSS = SS/dfvisualized by area of the blue circles.

DSL (MATH) AS / SmB Day 5 4 / 60

Page 5: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

What does drop1() do for linear normal models?The same tests, but obeying to the hierarchical principle!

> anova(lm(growth~antibio+vitamin+antibio:vitamin,data=rats))

Analysis of Variance Table

Response: growth

Df Sum Sq Mean Sq F value Pr(>F)

antibio 1 0.020833 0.020833 5.6818 0.044292 *

vitamin 1 0.218700 0.218700 59.6455 5.622e-05 ***

antibio:vitamin 1 0.172800 0.172800 47.1273 0.000129 ***

Residuals 8 0.029333 0.003667

> drop1(lm(growth~antibio*vitamin,data=rats),test="F")

Single term deletions

Model:

growth ~ antibio * vitamin

Df Sum of Sq RSS AIC F value Pr(>F)

<none> 0.029333 -64.167

antibio:vitamin 1 0.1728 0.202133 -43.005 47.127 0.000129 ***

DSL (MATH) AS / SmB Day 5 5 / 60

Page 6: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Questions?

Analysis-of-variance for linear normal models:

The total variation around the common mean is decomposed intothe parts explained by the used fixed effects and the error term.

Dividing by the corresponding degrees-of-freedom yields estimatesfor the variation “between groups” (the fixed effects) and “withingroups” (the error term).

Test for null hypothesis of no effect is done on the ratio

between group variation

within group variation=

MSSeffect

MSSerror

Thus comparing systematic variation to random variation, just as forthe T-tests!

DSL (MATH) AS / SmB Day 5 6 / 60

Page 7: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Random effects

Every linear normal model has at least one random effect, namely theerror term, which captures non-modelled biological variation, e.g.

soni = α + β ∗ fatheri + errori︸ ︷︷ ︸∼N (0,σ2)

Additional random effects may be used to capture commonnon-modelled biological variation, e.g.

soni = α + β ∗ fatheri + A(familyi )︸ ︷︷ ︸∼N (0,σ2

family)

+ errori︸ ︷︷ ︸∼N (0,σ2)

sonj = α + β ∗ fatherj + A(familyj)︸ ︷︷ ︸∼N (0,σ2

family)

+ errorj︸ ︷︷ ︸∼N (0,σ2)

If familyi = familyj = Markussen, say, the two sons (e.g. the lecturerand his brother) share the common unobserved componentA(Markussen). Quiz: What could that be?

DSL (MATH) AS / SmB Day 5 7 / 60

Page 8: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Hypothetical data example: 1-way ANOVAComparison of two treatments. Five animals per treatment

treat Observations Mean1 13.8 14.2 11.2 11.4 13.9 12.902 13.1 12.3 11.0 14.0 10.7 12.22

> anova(lm(y~treat,data=rep1))

Analysis of Variance Table

Response: y

Df Sum Sq Mean Sq F value Pr(>F)

treat 1 1.156 1.1560 0.5643 0.474

Residuals 8 16.388 2.04853.07e−09

0.474

111

treat12

[I]810

The F-test compares variation between treatments relative to variationwithin treatments. Here treatment is non-significant (p=0.474).

DSL (MATH) AS / SmB Day 5 8 / 60

Page 9: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Now measure each animal twiceAlmost the same observations repeated!

treat Observations Mean1 13.8 14.2 11.2 11.4 13.9 12.90

13.7 14.3 11.1 11.3 14.12 13.1 12.3 11.0 14.0 10.7 12.22

13.2 12.1 11.0 14.1 10.7

> anova(lm(y~treat+animal,data=rbind(rep1,rep2)))

Analysis of Variance Table

Response: y

Df Sum Sq Mean Sq F value Pr(>F)

treat 1 2.312 2.3120 330.29 5.461e-09 ***

animal 8 34.466 4.3082 615.46 1.906e-12 ***

Residuals 10 0.070 0.0070

0

5.46e−09

1.91e−12

111

treat12

animal810

[I]1020

How can double measurements on the same animals suddenly changesignificance from (NS) to (***) ??

DSL (MATH) AS / SmB Day 5 9 / 60

Page 10: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

What went wrong?

In the first analysis residual variation (mainly) represents variationbetween animals.

In the second analysis residual variation represents measurement error.

Treatments are compared by comparing different animals. Thereforethe relevant variation for comparing treatments is variation betweenanimals.

Conclusion: First analysis is OK. Second analysis shows that the twogroups of animals are different, but not necessarily that they are moredifferent than animals are in general.

DSL (MATH) AS / SmB Day 5 10 / 60

Page 11: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Factors with random effect

The factor “animal” is not reproducible.

The specific animals areI of no interest beyond the present experiment,I representatives of a population.

These statements characterize factors which we want to include asrandom effects in the model.

Estimates describe properties of the population, typically the standarddeviation in the scale of the response.

Typical factors with random effects: field, litter, replication, day, herd,and block factors in general.

I But possibly(!) also: strain, species, and other factors of no particularinterest in a given experiment.

DSL (MATH) AS / SmB Day 5 11 / 60

Page 12: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Factors with fixed (also called “systematic”) effect

The factor “treatment” is reproducible.

The specific treatments areI of interest beyond the present experiment — that is why we made it!I or other reproducible effects.I they only represent themselves.

These statements are typical for factors which we want to include asfixed effects in the model.

Estimates describe properties of the individual “treatments”, typicallythe mean of the response.

DSL (MATH) AS / SmB Day 5 12 / 60

Page 13: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Fixed effects vs. Random effects

Fixed effects:I Estimated mean for each level of the factor.I Use many degrees of freedom (which is a bad thing).

Random effects:I Estimated standard deviation between the levels.I Use only 1 degree of freedom (which is a good thing).I Requires iterative search for parameter estimates (which is a bad thing,

although it really doesn’t pose an actual problem).

Rough rule of thumb

A block factor with 4 or fewer levels is often used with fixed effect (weavoid estimating variation from few points as well as normality assumptionon random effect, and we don’t lose many degrees of freedom anyway).

DSL (MATH) AS / SmB Day 5 13 / 60

Page 14: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Three models for the dataset on slide 9

(A) Yi = α(treatmenti ) + errori

I α(1), α(2) are constants (fixed effects).I Wrong: Effect of animal is ignored.

(B) Yi = α(treatmenti ) + β(animali ) + errori

I α(1), α(2) and β(1),. . . , β(10) are constants (fixed effects).I Wrong: Meaningless model for testing treatment effect.

(C) Yi = α(treatmenti ) + A(animali ) + errori

I α(1), α(2) constants (fixed effects).I A(1),. . . , A(10) independent N (0, σ2

A) distributed random variables.I Recommended: Model with random effect of animal.

DSL (MATH) AS / SmB Day 5 14 / 60

Page 15: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Design diagrams for the two last modelsRandom factors are designated by square brackets

(B) Yi = α(treatmenti ) + β(animali ) + errori has diagram

111 treatment

21

ooanimal

108

oo [I]2010

oo

Remark: treatment can not be tested, since animal is nested withinit.

(C) Yi = α(treatmenti ) + A(animali ) + errori has diagram

111 treatment

21

oo [animal]108

oo [I]2010

oo

Remark: treatment is tested against the random factor animal.

Rule of thumb

When testing the effect of a factor (here treatment) any factors nestedwithin it (here animal) should usually be modelled with random effect.

DSL (MATH) AS / SmB Day 5 15 / 60

Page 16: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Random effects using R

Two packages (developed by Bates et al) available: nlme and lme4I nlme also analyses repeated measurements and non-linear models.I However, lme4 is maintained by the developers, allow for non-nested

random effects, and may also be used for categorical responses.I For models without repeated measurements I recommend the

lme4-package.

A methodological challenge is that random effects models forcontinuous responses may be estimated by two different methods.

I ML (maximum likelihood) is needed if you want to do likelihood-ratiotests (which we will do).

I REML (restricted maximum likelihood) is recommended for estimationof effects.

I Luckily lme4 and drop1() automatically take care of this!

Model validation: Needed both for fixed and random effects.

DSL (MATH) AS / SmB Day 5 16 / 60

Page 17: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Questions?

And then a break!

After the break we see how to use a random effect in a so-calledsplit-plot design. This example also exemplifies “Where is theeffects?”, and show how to estimate random effects models in R.

DSL (MATH) AS / SmB Day 5 17 / 60

Page 18: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Data example 1: Color of pork meat

2 breeds

{old: 10 pigs

new: 10 pigs

After slaughter: 6 pork chops from each pig.

Storage in light or darkness for 1, 4 or 6 days.

Response=redness of meat (continuous measurement)

Storage 1 days 4 days 6 days

Dark chop 1 chop 2 chop 3Light chop 4 chop 5 chop 6

In total 2*10*6=120 pork chops.

DSL (MATH) AS / SmB Day 5 18 / 60

Page 19: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Data example 1: Table of Variables

Variable Type Range Usagebreed nominal old, new fixed effectpig nominal 1, . . . , 20 random effectstorage nominal dark, light fixed effecttime ordinal 1 < 4 < 6 (days) fixed effectredness continuous [1.606; 14.123] response

pig is nested within breed

(breed is the “nest” and pigs are the “eggs”).

breed is a between-pig factor.

storage and time are within-pig factors.

Use full factorial design for the fixed effects.

DSL (MATH) AS / SmB Day 5 19 / 60

Page 20: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Example is a typical split-plot experimentTwo types of experimental units:

I Pigs (“whole-plots”) with the “whole-plot factor” breed.I Chops (“sub-plots”) with the “sub-plot factors” storage and time.

Design diagram:

[pig]2018

&&

[I]12090

33

''

breed:storage41

//

&&

breed21

""breed:storage:time

122

66

//

((

breed:time62

88

&&

storage21

// 111

storage:time62

//

88

time32

<<

DSL (MATH) AS / SmB Day 5 20 / 60

Page 21: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

R code: Validation of random effects modelrednessi = α(breedi , storagei , timei ) + A(pigi ) + εi , where A(j) ∼ N (0, σ2

A) andεi ∼ N (0, σ2)

# Read dataset: Recode some variables as factors

redness <- read.delim("redness.txt")

redness$pig <- factor(redness$pig)

redness$time <- factor(redness$time)

# Fit random effects model

m0 <- lmer(redness~breed*storage*time+(1|pig),data=redness)

# Residual plot

plot(m0)

# Normal quantile plots

qqnorm(residuals(m0))

qqnorm(ranef(m0)$pig[,1])

DSL (MATH) AS / SmB Day 5 21 / 60

Page 22: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Two of the three validation plotsNormal quantile plot for residuals not shown

fitted(.)

resi

d(.,

type

= "

pear

son"

)

−2

0

2

4

6

3 4 5 6 7 8

−2 −1 0 1 2

−0.

50.

00.

51.

0

Normal Q−Q Plot

Theoretical Quantiles

Sam

ple

Qua

ntile

s

Residual plot (mean zero?, variance homogeneity?): Standardisedresiduals vs. predicted values (including random effects).

I Observation no. 44 appears to be an outlier.

Normal quantile plot for predicted random effects.I Note that we only have 20 points, one for each pig.

DSL (MATH) AS / SmB Day 5 22 / 60

Page 23: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

R code: Backward model reductionIn the example using AIC, but we have also asked for p-values

# Refit model without obs. no. 44

m1 <- lmer(y~breed*storage*time+(1|pig),data=redness[-44,])

# Backward model reduction:

# Here with dense code using update()

drop1(m1,test="Chisq")

drop1(m2 <- update(m1,.~.-breed:storage:time),test="Chisq")

drop1(m3 <- update(m2,.~.-breed:time),test="Chisq")

drop1(m4 <- update(m3,.~.-breed:storage),test="Chisq")

Syntax for lmer():I Random effects specified in terms (1|·).I Other things done as for lm().

Technicality: Tests done as chi-squared test on likelihood ratio.

Automated backward model selection using p-values via step()

function in lmerTest-package.

DSL (MATH) AS / SmB Day 5 23 / 60

Page 24: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Results for the final modelrednessi = α(breedi ) + β(storagei , timei ) + A(pigi ) + εi , where A(j) ∼ N (0, σ2

A) andεi ∼ N (0, σ2)

Likelihood ratio test in model m4:

p(breed, df=1)=0.0141, p(storage:time,df=2)=0.0001

The old breed has more redness that the new breed:

emmean(old)-emmean(new)=0.8116 (95% CI: 0.1317 ; 1.4915)

Estimated marginal means for combination of storage (D, L) and time(1, 4, 6) are found and displayed (see next slide) using the R code:

plot(emmeans(m4,~time|storage),int.adjust="tukey",horizontal=FALSE) +

ylab("Redness of meat") +

ggtitle("95pct simultaneous confidence intervals within storage")

DSL (MATH) AS / SmB Day 5 24 / 60

Page 25: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Meat fade over time (when stored in light)

storage: D storage: L

1 4 6 1 4 6

4

5

6

7

time

Red

ness

of m

eat

95pct simultaneous confidence intervals within storage

DSL (MATH) AS / SmB Day 5 25 / 60

Page 26: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Quantification of sources of variationIn some analyses this quantification is the main objective

> summary(m4)

Linear mixed model fit by REML

Formula: y ~ breed + storage*time + (1 | pig)

...

Random effects:

Groups Name Variance Std.Dev.

pig (Intercept) 0.200 0.4473

Residual 1.923 1.3866

Number of obs: 119, groups: pig, 20

...

Total variance = 0.200+1.923 = 2.123.I Of this 9% is due to variation between pigs (random effect of pig).I And 91% comes from other sources (residual).

DSL (MATH) AS / SmB Day 5 26 / 60

Page 27: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Questions?

And then a break!

After the break we discuss how to estimate categorical regressionswith random effects.

DSL (MATH) AS / SmB Day 5 27 / 60

Page 28: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Data example 2: Binary dataNumber of Orobanche seeds germinating (yes/no) in extracts of bean and cucumberroots. In total 21 batches of two different orobanche varieties as shown below.

O. 75 O. 73Bean Cucumber Bean Cucumber

yes no yes no yes no yes no

10 29 5 1 8 8 3 923 39 53 21 10 20 22 1923 58 55 17 8 20 15 1526 25 32 19 23 22 32 1917 22 46 33 0 4 3 4

10 3Orobanche purpurea (Yarrow Broomrape),

picture from Wikipedia

Thus, the first batch consisted of 39 seeds of variety O.75 grown in beanroots, out of which 10 seeds germinated.

DSL (MATH) AS / SmB Day 5 28 / 60

Page 29: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Data example 2: Germination of Orobanche seeds

Variable Type Range Usagevariety nominal O.75, O.73 fixed effectroot nominal bean, cucumber fixed effectbatch nominal 1, . . . , 21 random effectgermination binary yes, no response

Interest on the effect of variety and root on germination of the seeds. Theparticular batches are not of interest, but representatives of a population.

variety21

""[I ]831

810// [batch]21

17// variety:root4

1

88

&&

111

root21

<<

DSL (MATH) AS / SmB Day 5 29 / 60

Page 30: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Logistic regression with random effects

Logistic regression models probability of germination via

log(odds for germination of i’th seed) = α(varietyi , rooti )

But what if the batches are different?

A solution is to include batch as a random effect. Thus, forindependent B(1), . . . ,B(21) ∼ N (0, σ2

B) we have

log(odds for germination of i’th seed) = α(varietyi , rooti ) + B(batchi )

The additional variability induced by the random factor is calledoverdispersion.

Alternatives to random effects models:I Correct for overdispersion by rescaling the standard errors: done using

quasibinomial-family in glm().I Estimate empirical correlation using the gee-approach.

DSL (MATH) AS / SmB Day 5 30 / 60

Page 31: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Data example 2 continuedComparison with other approaches to overdispersion

Test ofLogistic regression model variety:root OverdispersionGLMM (what we did) p=0.0413 modelledGEE p=0.0374 scale=1.8618quasibinomial p=0.0636 scale=1.8618Plain p=0.0114 not modelled

In this example plain logistic regression is questionable, and p=0.0114is not trustworthy.

In practice all the 3 other methods can be used.I Although they disagree on the significance in this situation. This is not

a paradox, but simply different tests for the same hypothesis.I If valid, then I recommend the GLMM. But this is a matter of taste.

To see if you have overdispersion check whether the scale parameterin the quasibinomial analysis is (significantly) larger than 1.

I Alternatively, make hypothesis test on the random effect in the GLMM.

DSL (MATH) AS / SmB Day 5 31 / 60

Page 32: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Summary of random effects

A factor should be used as a random effect if it is. . .I non reproducible,I of no interest beyond the present experiment,I representatives of a population.

Often block factors are used with random effects.

Rule of thumb: To test a fixed effect any factor nested within itshould usually be modelled as a random effect.

In these lectures we only discussed models with random intercepts.However, we may also have models with random slopes of somecontinuous covariate. E.g., if redness$time is continuous:

lmer(y~breed*storage*time+(1+time|pig),data=redness)

Random effects also possible for categorical regression models:I Related to overdispersion.I GLMM (generalized linear mixed effects models) used in these lectures.

DSL (MATH) AS / SmB Day 5 32 / 60

Page 33: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Questions?

And then a break!

After the break we discuss models for repeated measurements.

DSL (MATH) AS / SmB Day 5 33 / 60

Page 34: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Repeated measurements models: Why?Data example 1: Color of pork meat.10 pigs from both old and new breed: 7 chops from each pig.

TimeStorage 0 days 1 days 4 days 6 days

Dark chop 1: data chop 2 chop 3 chop 4Light not used chop 5 chop 6 chop 7

Random effect model for chops 2 to 7 (in total 2*10*6=120 observations):

rednessi = α(storagei , timei , breedi ) + A(pigi )︸ ︷︷ ︸∼N (0,σ2

A)

+ εi︸︷︷︸∼N (0,σ2)

But what if the experimental design has been like this?

TimeStorage 0 days 1 days 4 days 6 days

Dark chop 1 chop 1 chop 1 chop 1

Light chop 2 chop 2 chop 2 chop 2

DSL (MATH) AS / SmB Day 5 34 / 60

Page 35: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

example continued. . .Alternative design has 4 measurements for each pork chop

TimeStorage 0 days 1 days 4 days 6 days

Dark chop 1 chop 1 chop 1 chop 1

Light chop 2 chop 2 chop 2 chop 2

Random effect model for the alternative design:

rednessi = α(storagei , timei , breedi ) + A(pigi )︸ ︷︷ ︸∼N (0,σ2

A)

+B(pigi , chopi )︸ ︷︷ ︸∼N (0,σ2

B)

+ εi︸︷︷︸∼N (0,σ2)

Here the 4 measurements on the same pork chop (from the same pig)share an additional random effect B(pig,chop).

But perhaps measurements taken close in time are more correlatedthan measurements taken fare apart in time! How to model that?

DSL (MATH) AS / SmB Day 5 35 / 60

Page 36: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

General remarks on repeated measurements

Repeated measurements originate from study designs where theexperimental units have been measured several times (typically atdifferent time points or at different spatial positions):

I “Economic” necessity, e.g. when experimental units are expensive.I Experimental units may serve as their own controls.I Response profile (i.e. response over time) is of scientific interest.I Repeated measurements are analysed either to gain power or to

investigate the response profile.

A summary measure is a single number capturing the importantfeature of the response profile.

I Examples: AUC (area under the curve), mean, maximum, minimum,range between max and min, time under a pre-specified level, slope,curvature, halving time, slope after the minimum, . . .

I Summary measure preferably suggested from the scientific study, notfrom the statistical analysis.

I Summary measures reduce the repeated measurements to a singleobservation =⇒ statistical analysis without repeated measurements.

DSL (MATH) AS / SmB Day 5 36 / 60

Page 37: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Which method to use?Summary measures vs. Random effects vs. Repeated measurements

Summary measures is always an option.I Unless you have particular interest in the response profile I recommend

analysis of summary measures (if it has sufficient power).

With few repeated measurements per subject, say 4 or less, it doesnot make sense to estimate the serial correlation structure.

I Simply use a random effect model.

With many repeated measurements per subject, say 5 or more, youhave enough information to estimate the serial correlation structure.

I This is necessary to have trustworthy p-values and confidence intervals.I However, sometimes it is possible to model serial correlation via random

slopes. But we will not investigate this further in the this lecture.

DSL (MATH) AS / SmB Day 5 37 / 60

Page 38: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Case study: Growth of Baobab trees under water stressData kindly provided by Henri-Noel Bouda

Baobab seeds from 3 countries and 7 provenances sown in thebeginning of 2009.

Plants grown under 3 water regimes (100%, 75% and 50% fieldcapacity).

Diameter and height of plants measured monthly.

To measure root weight etc. some plants were harvested in August2009, some plants in February 2010.

Purpose of experiment:I How does water drought effect growth of trees.I Is there an interaction with country and/or provenance?

DSL (MATH) AS / SmB Day 5 38 / 60

Page 39: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Individual response profiles (subject profiles)For the 362 baobab trees that survived until harvest

A good plot to make. Gives overview of the data and provides animpression of the “typical” time-response relationship.

Burkina Mali Tanzanie

2 4 6 8 10 12 2 4 6 8 10 12 2 4 6 8 10 12

2.5

5.0

7.5

10.0

age

heig

ht^(

1/2)

Burkina Mali Tanzanie

2 4 6 8 10 12 2 4 6 8 10 12 2 4 6 8 10 12

2

4

6

8

age

diam

eter

^(2/

3)

Here the power transformations height height1/2 anddiameter diameter2/3 were chosen from a Box-Cox analysis.

DSL (MATH) AS / SmB Day 5 39 / 60

Page 40: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Average response profilesA good plot to make. Gives overview of the treatment effects.

Burkina Mali Tanzanie

2 4 6 8 10 12 2 4 6 8 10 12 2 4 6 8 10 12

2

4

6

age

diam

eter

^(2/

3) Treatment

1

2

3

Diameter response profiles averaged within the 9combinations of treatments and countries

DSL (MATH) AS / SmB Day 5 40 / 60

Page 41: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Data organization in Excel sheetWide form (also called “horizontal organization”) of responses: diameter, height

Variable Levels DescriptionCountry 3 (Burkina,Mali,Tanzanie) CountryProvenance 7 (Kolangal,. . . ,Same) 3 provenances from Burkina,

3 from Mali, 1 from TanzaniePlant 362 (BKol-04,. . . ,TNku-76) Plant idBlock 3 (1,2,3) Field blocksTreatment 3 (1,2,3) Water regimeHarvestDate 3 (aug-09,feb-10,missing) Day of harvestDia0209 continuous (or missing) Diameter, February 2009...

......

Dia0110 continuous (or missing) Diameter, January 2010Hei0209 continuous (or missing) Height, February 2009...

......

Hei0110 continuous (or missing) Height, January 2010

DSL (MATH) AS / SmB Day 5 41 / 60

Page 42: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Long form: diameter, height for each monthThe “long form” is also referred to as the “vertical organization”

Variable Levels DescriptionCountry 3 (Burkina,Mali,Tanzanie) CountryProvenance 7 (Kolangal,. . . ,Same) 3 provenances from Burkina,

3 from Mali, 1 from TanzaniePlant 362 (BKol-04,. . . ,TNku-76) Plant idBlock 3 (1,2,3) Field blocksTreatment 3 (1,2,3) Water regimeHarvestDate 3 (aug-09,feb-10,missing) Day of harvestmonth 12 (2,. . . ,12,1) Month of yearyear 2 (09,10) Yeardiameter continuous Diameterheight continuous Heightage continuous (1 to 12) Months since January’09

DSL (MATH) AS / SmB Day 5 42 / 60

Page 43: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Long form as needed for the statistical analysis

Country Provenance Plant Block Treatment HarvestDate month year diameter height age

<chr> <chr> <fct> <fct> <fct> <dttm> <chr> <chr> <dbl> <dbl> <dbl>

1 Burkina Kolangal BKol-11 1 1 2009-08-01 02 09 4.33 33 1

2 Burkina Kolangal BKol-11 1 1 2009-08-01 03 09 4.33 33 2

3 Burkina Kolangal BKol-11 1 1 2009-08-01 04 09 5.62 40 3

4 Burkina Kolangal BKol-11 1 1 2009-08-01 05 09 5.65 42 4

5 Burkina Kolangal BKol-11 1 1 2009-08-01 06 09 7.1 52 5

6 Burkina Kolangal BKol-11 1 1 2009-08-01 07 09 10 54 6

7 Burkina Kolangal BKol-11 1 1 2009-08-01 08 09 13.4 69 7

8 Burkina Kolangal BKol-78 1 1 2009-08-01 02 09 4.65 39 1

9 Burkina Kolangal BKol-78 1 1 2009-08-01 03 09 4.65 39 2

10 Burkina Kolangal BKol-78 1 1 2009-08-01 04 09 6.43 39 3

11 Burkina Kolangal BKol-78 1 1 2009-08-01 05 09 6.5 43 4

12 Burkina Kolangal BKol-78 1 1 2009-08-01 06 09 8 49 5

13 Burkina Kolangal BKol-78 1 1 2009-08-01 07 09 8.6 62 6

14 Burkina Kolangal BKol-78 1 1 2009-08-01 08 09 13.7 75 7

15 Burkina Kolangal BKol-86 1 1 2009-08-01 02 09 6.25 29 1

16 Burkina Kolangal BKol-86 1 1 2009-08-01 03 09 6.25 29 2

17 Burkina Kolangal BKol-86 1 1 2009-08-01 04 09 8.57 31 3

18 Burkina Kolangal BKol-86 1 1 2009-08-01 05 09 8.61 35 4

19 Burkina Kolangal BKol-86 1 1 2009-08-01 06 09 9.1 43 5

...

...

...

DSL (MATH) AS / SmB Day 5 43 / 60

Page 44: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Table of variables

Variable Type Range UsageCountry nominal Burkina, Mali, Tanzania fixed effectProvenance nominal Kolangal,. . . ,Same fixed effect

Remark: nested in CountryPlant nominal BKol-04,. . . ,TNku-76 random effect

subject idBlock nominal 1,2,3 fixed effectTreatment ordinal 1 < 2 < 3 fixed effectage nominal 1,2,. . . ,12 fixed effect

continuous [1;12] correlation effectdiameter continuous [0; 23.7] responseheight continuous [0; 142] response

The two responses (diameter, height) analysed separately.R code via lme() in nlme-package:

I fixed effects are specified in model formula.I random effects are specified in random option.I correlations are specified in corr option.

DSL (MATH) AS / SmB Day 5 44 / 60

Page 45: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Diagram of fixed and random factorsNot all details included in the diagram, that otherwise would be too complex

[plant]362335

//

((

treat*block94

//

&&

block32

""[I]

34122819

88 33

&&

treat*provenance2112

//

&&

treat32

// 111

treat*age*provenance252132

66

//

((

treat*age3622

88

&&

provenance76

<<

age*provenance8466

88

// age1211

EE

In the model reduction provenance is nested within country.

Are the residuals εi , i = 1, . . . , 3407, independent?

DSL (MATH) AS / SmB Day 5 45 / 60

Page 46: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Repeated measurements model

diameteri = α(treati , agei , provenancei , blocki )

+ A(planti )︸ ︷︷ ︸∼N (0,σ2

A)

+B(planti , agei )︸ ︷︷ ︸∼N (0,σ2

B)

+ εi︸︷︷︸∼N (0,σ2)︸ ︷︷ ︸

[I]-term in the design diagram

Random effect A: Some plants are bigger than others.

Correlated effect B: Correlated within plants (∼ subject id).Correlation typically decreases with increasing time distance.Uncorrelated between plants.

I Possible interpretation is variation between time position of growthperiod.

Error term ε: Possible interpretation is measurement error.

DSL (MATH) AS / SmB Day 5 46 / 60

Page 47: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Three examples of correlation structures for Bdiameteri = α(treati , agei , provenancei , blocki ) + A(planti ) + B(planti , agei ) + εi

(A) The model without the serial correlated effect B.I In this case we have a random effect model. This model is also referred

to as the random intercept model or the compound symmetry model.

(B) Var(B(plant, agei ),B(plant, agej)

)= σ2

B exp(− |agei−agej |

d

)I Correlation has exponential decrease.

(C) Var(B(plant, agei ),B(plant, agej)

)= σ2

B exp(− |agei−agej |

2

ρ2

)I Correlation has Gaussian decrease.I When a random effect A and an error term ε are present, this model is

sometimes referred to as the Diggle model after Peter Diggle.

DSL (MATH) AS / SmB Day 5 47 / 60

Page 48: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

R code

# Transformation of wide-format into long-format

baobab %>%

pivot_longer(cols=Dia0209:Hei0110,

names_to = c(".value","month","year"),

names_sep = c(3,5),

values_drop_na = TRUE) %>%

mutate(age=as.numeric(month)-1+12*(as.numeric(year)-9)) %>%

mutate(Treatment=factor(Treatment)) %>%

rename(diameter=Dia,height=Hei) ->

long

# Diggle model: two other models in R script

mGauss <-lme(diameter~Treatment*Block+

Treatment*factor(age)*Provenance,

random=~1|Plant,

corr=corGaus(form=~age|Plant,nugget=TRUE),

data=long)DSL (MATH) AS / SmB Day 5 48 / 60

Page 49: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Which repeated measurements model to use?There exists many other models than those listed on slide 47

Is the model valid?I Residual plot: Non-random scatter suggests that the explanatory

variables have not been used appropriately, e.g. an interaction or aquadratic term might be missing.

I Normal quantile plots: Residuals not on a straight line suggests thatthe response variable perhaps should be transformed.

I Semi-variogram: Compares empirical correlation structure (the dots) tothe fitted theoretical correlation structure (the line).

Interpretation?I Random effects have a simple interpretation, which speak in favour of

the compound symmetry model. The exponential decrease and theDiggle model have similar interpretations.

Akaike Information Criterion (AIC): “The smaller the better”.I For the Baobab dataset the compound symmetry model is clearly

rejected by the AIC.

DSL (MATH) AS / SmB Day 5 49 / 60

Page 50: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Exponential vs. Gaussian decrease: Residual plot

Exponential decrease model

Fitted values

Sta

ndar

dize

d re

sidu

als

−4

−2

0

2

4

2 3 4 5 6

●● ●

● ●

●●

●●

● ●

●●

●●

●● ●●

●●●●●●

●●●

●●

●●●

●●●

●● ● ●

●● ●

●●●●●

●●

●●●

●● ●●●●

●●●●●

●● ●●●

●●●●●●

●●

●●●

●●

●●●●●

●●●●

●●●●●

●●●●

● ●●

●●●●●

●●●● ●●

●●

●●●●●

●●

●●● ●●●●●●●●●

●●● ●

●●●●●●

●●

● ● ●

●●

●●●

●●

●● ●●

●●

●●

● ●●

●●

●● ●● ●

●●●●●●

●● ●●

● ●

●●●●●●

●●

●●●● ●

●●●●●

●●●

●●●● ●

●● ●●● ●

●●●●●●

●●

●●●

● ●●●●●

●● ●●● ●

● ●●●●●

●●●●

●●

●●●●

●●

●●● ●

●●

●●● ●●

●●

●●●●

●● ●●●●

●●●●●●

●● ●

●●●

●●●●●●

●●

●●●●

●●●●●●

●●● ●

●●

●●●

●●● ●

●●

● ●

●● ●

●● ●

●●●●●●

●●●

●●

●●●●

●●

●●

●●

●●●●●●●●

●●● ●

●●

●●● ●

●●●

●●●●

●●

●●●●

●● ●●● ●

●●●●●●

●●

●●● ●

●●

●●●●

●●

●●

● ●

● ●●●●●

●●

●●● ●

●●●

●●● ●

●●● ●●● ●

●●

●●●●

●●●●●●

●●

●●● ●

●●●●●●

●● ●●● ●

●●●●●●

●● ●●● ●

●●●●●●

●●●

●●

●●

●● ●●

●● ●

●● ●●

● ●

●● ●●

●●●

●●●

●●●

● ●●●●●

●● ●●

●●●●●

●●

●●

●●●

●●●

●●●●●

● ●●●

●●●●

●●

●●

●●

●●

●●●●●●

●● ●●

●●●●●●

●●

●●●●

●●

●●●●●

●●● ● ●

●●

●●●

●●

●●●●

●●

●●●●

●●

●●● ●

●●●●●●

●●

●●● ●●●●●●●

●●

● ●

●●●●

●● ●

●● ●

●● ●

●●●●●●

●●●

●●

●●●●●●

●● ● ●

●●

● ●●●●●

●●

●●●

●●

●●●●

●●

●●● ●

●●

●●●●

●●●●●●

●● ●●●

●●●●●●

●●

●●●

●●●●●●

●●●

●●●●●●

●●●●●

● ●

●●

●●● ●●

●●

●●●● ●

●●●●●

●●●●●●

●●

●●● ●

●●●●●●

●●●

●●

●●

● ●

●● ●●

●●●●

●● ●

● ●

●●●●●●

● ●

●●

●●●●●

●● ●●

● ●●●●●

●● ●●●●

●●●

●●

●● ●●●

●●●

●●

●● ●●●

●●●

●●●

●● ●●● ● ●●●●●●

●●●●● ●

●●●●●●

●●

●●● ● ●

●● ●●● ●

●● ●●●●

●●

●●●●

●●●●●●

●●●●●

●●●●●●

●●

●●● ●

●●●●●●

●● ●●● ●

●●●●●●●●

● ●

●●●

●●

● ●●

●●

●●

●●●●●

●●●

●●

●●●●●●

●● ●●

●●●●●

●●

● ●

● ●●

●●●●●

●●

●●●●

●● ●●● ●

●●

●●●

●●●●●●

●●●●● ●

●●●

●●●

●●

●●●●

●●●

●●

●●

●●●● ●

●●●●● ●

●● ●●

●●

●●

●●●

●●●●●

●●●●●●

●●

●●● ●

●●●●●

●●

●●● ●●●●●●●

●● ● ●●

●●● ● ●

● ●●

●● ●●

● ● ●

●●

●●

●●

●● ●

●●●●●

●●●

●●

● ●●●●●

●●● ● ● ● ● ●●

●●●●●

●●● ●

●●

●●● ●●

●●●●●

●●● ●●● ●

●●●●●●

●●●●● ●

●●●●●●

●● ●●● ● ●●●●●●

●● ●●● ●

●● ●●●●

●●●

●●●●

●●

●●●●

●●●●●●

●●●●●

●●●●●●

●●●●●

●●●●●●

●● ● ●

●● ●

●●

●●

●●

●● ●

●● ● ●

●●

●●●●●

●●

● ●

●●

●●●●●

●●

●● ●

●●●●●●

●● ●●● ●

●●●●●

● ●●●●●● ●

●●● ●●

● ●

●●●●●

●●●●●●

●●●●● ●

●●●●●●

●●

●●● ●

●●●●●●

●● ●●● ●●●● ●●●

●● ●●●●

●●●

●●●●

●●●●●●

●● ●●●

●●●●●●●

●●●●● ●

●●●

●●●

●● ●●● ●

●●●●●●

●● ● ●

● ●

●●● ●

● ● ●

●●

●●

●●●●●●

●●●

● ●

●●●●●●

●●

●●

● ● ●●●●●

●●●

● ●●●●●

●●

●●●

●● ●●● ●

●●●

●●● ●

●●● ●●●

●●●

●●●

●●●●

●●

●●●●

●●

●●

●●● ●

●●●●●

●●

●●●●

●●

●●●●

●●●●●

●●

●●●●

●●

●●●●

●●●●●●

●●

●●●●

●●●●●●

●●

●●●●

●●●●●

●● ● ● ●

●●● ● ●

●●

● ●●

●● ●

● ●●

●●

●●

●●

●●●●●●

●● ●● ●

● ● ●●●●●

●●●●●

●●

●●●●

●●●●

●●●●

●●●●●

●●●●●

●●

●●● ●

●●●●●

●●●

●●

●●

●●●●●●

●● ●●●●

●●

●●●●

●●●●●●

●● ●●●

●●●●●●

●●●●●●

●●●●●●

●●●●●

●●●●●●

●●●

●●

●●●

● ●

●●

● ●●

● ●●●●●●●

●● ●

● ●●●●●

●● ●●

● ●●●●●●

●●●

●●

●●●

●●

●●●

●●●

●●●

●● ●●● ●

●●

●●●●

●● ●●●

●●●●●

●●●●● ●

●●●

●●●

●●●●●

● ●

●●

●●●●

●● ●●●●

●● ●●●●

●●●●●●

●●

●●●●

●●●●●●●●

●●

●●●●

●●

●●●

● ●●●●●

●● ●●●

● ●●●●●

●●●●

●●●

●●●

●●

●●

●●

●●

●● ●● ●

●●

●●

●● ●●

●●

●●●

●●●

●●●●

● ●

● ●●●●●

●●

●●●●

●●

●●●● ●●● ●●●●

●●● ●●●

● ●●●●●

●●

● ●

●●●

●●●

●●

●●●●

●●

● ●

●●

●●

● ●

●●●

● ●

●●

●●●●

●●

● ●

●●●

●●

●●

●●●●●

●●

●●

●●

●●●●

●● ●●●

●● ●●●

●●●●● ●

●●●●●

● ●

● ●●●●●

●●●●●

●●

●●●

●●●

●●●●●

●●● ● ●●●

●●●●

●●

●●●● ●

●●

●●●

●● ●●●

● ●●●●●

●●

●●● ● ● ●●●●●

●●

●●●

● ●●●●●

●●●

●●

● ●

●●●

●● ● ● ●

●●

● ●

●●●

● ●

●●

●●●

●●

●●

● ●

●●

●●●●●●

● ● ●●

●●●●

●●

●●●●

●●

●●● ●

●●

●●●

●● ●●●●

●●●●●

●●●●

●●

● ●

●●●●

●●●●●

●●●●●

●●●

●●●

●●

●●●●●●●●●

●●

●●●● ●

●●

●●●

●●●

●●●

● ●

●●●●●

●●●●● ●

● ●●●●●

●●●●

●●

● ●●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

● ●

● ●●●

●●●

●●●●

●● ●●●

●●●●

●●●

●● ●

●● ●

●●

●●

●●●

● ●●●●●

●●

●●● ●

● ●●●●

●●

●●●

●●●●●●●●

●●●●

●●

●●

●●

●●● ●

●● ●●●

● ●●●●●

●●

●●●

● ●

●●●●●

●●

●●

●● ●●●●

●●●●●

●● ●

●●

●●

●●

●●

●●

●●

●●●

● ●●

●●●●

●● ●

●●

●●

●●●●●

●●●

● ●

●●●●●●●

●●

●●●

●●●

●●

●●●

●●

●●

●●●

●●

●●●●

●●●●

● ●

●●●●●

●● ●●●●

●●●●●

●● ●●

● ●

●●●●●

●●●●●

●●

●●●●

●●● ●●●

●●●

●●●

●● ●●● ●

●●●●●

●●●●●

●●●●●●●●

●●●

●●●●●

●●●

●●

●●

●●

●● ●

●● ●

● ● ●

●●

●● ●

●● ● ●

● ●●

●●●●●

●● ● ●

● ●●●●●

●●●

●●

● ● ●●●●●

●●

●●●

●●

●● ●

●●

●●●●●

●●

●●● ● ● ●●●●●●●

●●●

●●●●●

●●

●●●●

●●●●●

●● ●●

●●●●●

●●●●

●●●●●

●●

●●●

●●●●●

●●●●●●

●●

●●●●

●●●

●●●

●●

●●●

●●

●●●●●

● ●●

●●●

● ●

●●● ●

●●

●● ●●

● ●

●●●●●●

●●●

●●●●●●

●●●

●●

●●●●●●

●●●●● ●

●● ●●●

●●

●●

●●●

●●

●●● ● ●

●●

●●●

●●●●●

●● ●●●

●●●●●●

●● ●●●

●●●●●

●●

●●●

●●

●●

●●●

● ●

●●

●●●

●●●● ●●●

●●●●●●

●● ●●●●

●●●●●●

●●

●●●

●●●●●●

●●

●●●

●●●●●●

Diggle model

Fitted values

Sta

ndar

dize

d re

sidu

als

−4

−2

0

2

4

1 2 3 4 5 6 7

●●●

● ●

●●

●●

● ●

●●●

●●

●●●

●●

●●

●●●

●●●

●●

●●● ●

●●

●●●●●

●●

●●●

●●●●

●●●●●

●● ●●

●●●●●

●●

●●●

●●

●●●●●

●●

●●

●●●●●

●●●●●●

●●●●●

●●

●● ●●

●●●●

●●

●●●●●●●●●●

●●

●●●●

●●●●●

●●

● ● ●

●●●

●●

●● ●

●●

●●●

● ●●

●● ●

● ●

●●●

●●●

●● ●●

●●

●●

●●●●

●●

●●●

● ●●●

●●●

●●

●●●

● ●●●●●

● ●

●●●●●

●●

●●●

● ●●●●●

●● ●●●

● ●●●●●

●●●●

●●●●●

●●

●●●●

●●

●●●●

●●●

●●●

●● ●●●

●●●●●●

●● ●

●●

●●●●●

●●

●●●

●●●●●●

●●

● ●

●●●

●●●

●●

●●

●● ●

●●

●●●●●●

●●●

●●

●●●

●●●

●●

●●

●●●●●●

●●

●●● ●

●●

●●● ●

●●

●●●

●●

●●●

●●●●

● ●

●●●●●

●●

●●● ●

●●

●●●●●●

●●

● ●

●●

●●●●

●●

●●●

●●

●●●●

●●●●●

●●

●●●

●●●●●

●●

●●●●

●●●●●

●●● ●●●●

●●●●●●

●● ●●●●

●●●●●●

●●

●●● ●

●●

●●●

● ●

●●●

●●

●●●

●●

●●

●●

●●●●

●● ●

●●●●●

●●

●●

●●

●●●

●●●●●

● ●●●

●●●

●●

●●

●●

●●

●●●●●

●●●●

●●●

●●●

●●●●

●●

●●●●●

●●●●●

●●

●●●

●●

●●●

●●

●●●●

●●

●●●

●●●●●

●●

●●●●

●●●●●

●●

●●

●●●

●●

●●●

● ●

●● ●

●●

●●●

●●

●●

●●●●

●● ● ●

●●

● ●●●●●●●

●●●

●●

●●●

●●

●●●

●●

●●●

●●●

●●

●● ●●●

●●●●●●

●●

●●●

●●●

●●

●●

●●●

●●●●

●●●●●

● ●

●●

●●●●

●●

●●●● ●

●●●●●

●●●●

●●

●●

●●●●

●●●

●●

●●●

●●

●●

● ●

●● ●●

●●●

●● ●

● ●

●●●●

●●● ●

●●●●●

●● ●●

●●

●●●●

●● ●●●

●●

●●

●● ●●●

●●

●●●●

●●●

●●●

●● ●●● ● ●●

●●●●

●●

●●● ●

●●●●●●

●●

●●●● ●●● ●●●●

●● ●●●●

●●

●●●●

●●●●●

●●●●●●

●●●●●

●●

●●●●

●●●●●

●● ●●●●

●●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●●●

●●

●●●●●●●●

●●

●●●●

●●

●●

● ●

●●●●

●●

●●

●●●●

●●●●●

●●

●●●

●●●●●●

●●●●●

●●●●

●●

●●

●●●●

●●●

●●

●●

●●●

●●

●●

●●●●

●● ●●

●●●

●●●

●●●

●●●●●●

●●

●●● ●

●●●●●

●●

●●● ●●●●●●

●●●

●●

●●●

●●

●●

●●●

● ●●●●

●●

●● ●

●●●●●

●●

●●

●●

●●●●●●●●

●● ● ● ●●●

●●●

●●

●●●●

●●

●●●●

●●

●●●●

●● ●●●

●●●●●

●●

●●●●●●●●●●

●● ●●●● ●●●

●●●

●●●●● ●

●●●●●

●●●●●

●●

●●●●

●●●●●●

●●●●●

●●●

●●●

●●

●●●

●●

●●●●

●● ●●

● ●

●●

●●

●●●

●●● ●

●●●●●

●●

●●

●●●

●●●

●●

●● ●

●●●●●●

●● ●●●●

●●●

●●●●

●●●●●●

●●● ●●

●●

●●●●●

●●●●●●

●●●●●●

●●●

●●●

●●

●●●●

●●

●●●●

●● ●●● ●

●● ●●●

●● ●●●●

●●●●●

●●●●●●●●

●●●

●●●●●●

●●

●●●●

●●●

●●●

●●●●●

●●●

●●●

●● ●●

● ●

●● ●

● ● ●

●●

●●

●●●●●

●●

●●

●●●●●●●

●●●●

●●●●●

●●●

●●●

●●

●●●

●●●●● ●

●●

●●●

●●● ●●●

●●

●●

●●●

●●●●

●●

●●

●●●

●●●

●●

●●●●

●●

●●●●

●●

●●●

●●

●●●●

●●

●●●●

●●●●

●●

●●

●●

●●●●

●●

●●●

●●●●

●● ●● ●

●●

● ● ●

●●

●●

●● ●

● ●

●●

●●

●●●●●●

●●●

● ●● ●●●

●●●

●●●●

●●

●●

●●●

●●

●●

●●●

●●●●●

●●●

●●

●●

●●●●

●● ●●

●●

●●

●●●●

●●

●● ●●●●

●●

●●●●

●●●●●●

●●●●●

●●●●●

●●●

●●●●

●●●

●●

●●●●●

●●●

●●●

●●

●●

●●

● ●

●●

● ●

●●●●●●

●●

● ●

●●●●

●●

●●●

●●

● ●●●●●

●●●

●●

●●●

●●

●●●

●●

●●●

●●●●

● ●

●●

●●

●●

●● ●

●●

●●●

●●

●●

●●●●

●●

●●

●●●●●

●●

●●

●●●●

●●●●●●

●● ●●●●

●●●●●

●●

●●●●

●●●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●●

●● ●●

●●●

●●●

●●

●●●

●●

●●●

●●

●●

●●●● ●

●●

●●●●

●●●

●●●

●●

●●

● ●

●●●●●●

●●

●●●●

●●

●●●● ●

●● ●●●●

●●● ●●●

●●●●●●

●●

● ●

●●

●●●●

●●●●

●●

● ●

●●

● ●

●●

● ●

●●●

●●

●●

●●●

●●

●●

●●●●

●●

●●

●●●●

●● ●●●

●●●●●

●●●

●●● ●

●●●

●●

● ●

●●

●●●

●●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●●

● ●

●●

●●●

●● ●●●

● ●●●●●

●●

●●●

●● ●

●●●●

●●

●●●

●●

●●●●

●●

● ●●●

●●

●●● ● ●

●●

●●●●

●●

● ●

●●

●●●

●●

●●

● ●

●●

●●●●

●●

●● ●

●●●●

●●

●●●

●●

●●● ●

●●

●●●

●● ●●●

●●●●

●●●

●●

●●

●●●

●●

●●●

● ●●●●

●●

●●●

●●●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●●

● ●

●●●●●

●●●●● ●

● ●●●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●● ●

●●

●●

●●●

●●●●

●● ●●●

●●●●

●●●

●● ●

●●●

●●

●●

●●●

● ●●●

●●

●●

●●● ●

● ●●●●

●●

●●●

●●●●●

●●

●●●

●●

●●

●●

●●●

●●●●

● ●●●●●

●●

●●●

● ●

●●●●●

●●

●●

●●●●●

●●●●●●● ●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●●●●

●●

●●●●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●

●●

●●●

●●

●●● ●

●●●●●

●● ●●●

●●

●●●

●●●●

●●

●●●●●

●●

●●●

●●

●●●

●●● ●●●

●●

●●●

●● ●●● ●

●●●●

●●●●●

●●●●

●●

●●

●●●

●●●●

●●●

●●

●●● ●

● ● ●

●●

●●

●● ● ●

●●

●●●●

●●

●● ● ●

●●●●●●

●●

●●

●●

●●●●●●

●●

●●●

●● ●

●●

●●

●●●

●●

●●● ●● ●●●●

●●

●●●

●●●●●

●●

●●●●

●●●●●

●● ●●

●●●●●

●●●

●●

●●●

●●

●●●

●●

●●●

●●●●●

●●●

●●●

●●●

●●

●●

●●●

●●

●●●●

● ●●

●●

● ●

●●

●●

●● ●●

● ●

●●●●●

●●

●●●●●●●

●●●●●●

●●●●●

●● ●●●

●●

●●

●●●

●●

●●● ● ●

●●

●●●

●●●●●

●●●●●

●●●●●

●● ●●●

●●●●●

●●

●●●

●●

●●

●●●

●●●●

●●●

●●

●● ●●●

●●●●●

●● ●●●

●●●●●

●●

●●●

●●●●●

●●

●●●

●●●●●

plot(mExp,main="Exponential decrease model")

plot(mGauss,main="Diggle model")

DSL (MATH) AS / SmB Day 5 50 / 60

Page 51: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Exponential vs. Gaussian decrease: Normal quantile plot

●●●

●●

●●

●●

●●

●●

●●

●●●●

●●●●

●●●●

●●

●●●

●●●

●●●●

●●

●●●●●

●●

●●●

●●●●●

●●●●●

●●●●●

●●●●●●

●●

●●●

●●

●●●●●

●●●●

●●●●●

●●●●

●●●

●●●●●

●●●●●●

●●

●●●●●

●●

●●●●●●●●●●●●

●●●●

●●

●●●●

●●

●●●

●●

●●●

●●

●●●●

●●

●●

●●●

●●

●●●●●

●●●●●●

●●●●

●●

●●●●●●

●●

●●●●●

●●●●●

●●●

●●●

●●

●●●●●●

●●●●●●

●●

●●●

●●●●●●

●●●●●●

●●●●●●●●

●●●

●●

●●●●

●●

●●●●

●●

●●●●●

●●

●●●●

●●●●●●

●●●●●●

●●●

●●●

●●●●●●

●●

●●●●

●●●●

●●

●●●●

●●

●●●

●●●●

●●

●●

●●●

●●●

●●●●●●

●●●

●●

●●●●●●

●●

●●

●●●●●●

●●

●●●●

●●

●●●●

●●●

●●●●

●●

●●●●

●●●●●●

●●●●●●

●●

●●●●

●●

●●●●

●●

●●

●●

●●●●●●

●●

●●●●

●●●

●●●●

●●●●●●●

●●

●●●●

●●●●●●

●●

●●●●

●●●●●●

●●●●●●

●●●●●●

●●●●●●

●●●●●●

●●●

●●

●●

●●●●

●●

●●●●

●●

●●●●

●●

●●●

●●●

●●●●●●

●●●●

●●●●●

●●

●●

●●●

●●●

●●●●●

●●●●

●●●●

●●

●●

●●

●●

●●●

●●●

●●●●

●●●●●

●●

●●●●

●●

●●●●●

●●●●●

●●

●●●

●●

●●●●

●●

●●●●

●●

●●●●

●●●●●●

●●

●●●●●●●●●●

●●

●●

●●●●

●●●

●●●

●●●

●●●●●●

●●●

●●●●●●

●●●●

●●

●●●●●●

●●

●●●

●●

●●●●

●●

●●●●

●●

●●●

●●●●

●●

●●●●●

●●●●●●

●●

●●●

●●●

●●●

●●●

●●●●●

●●●●●

●●

●●

●●●●●

●●

●●●●●

●●●●●

●●●●

●●

●●

●●●●

●●●●●●

●●●

●●

●●

●●

●●●●

●●●●

●●●

●●

●●●●

●●●●

●●

●●●●●

●●●●

●●●●●●

●●●●●●

●●●

●●

●●●●●

●●●

●●

●●●●●

●●

●●●

●●●●●●●●●●●●

●●●●●●

●●●●●●

●●

●●●●●

●●●●●●

●●●●●●

●●

●●●●

●●●●●●

●●●●

●●

●●●●●●

●●

●●●●

●●●●●●

●●●●●●

●●●●●●●●

●●

●●●

●●

●●●

●●

●●

●●●●●●

●●

●●

●●●●●●

●●●●

●●

●●●

●●

●●

●●●

●●●●●

●●

●●●●

●●●●●●

●●

●●●

●●●●●●

●●●●●●

●●●

●●●

●●

●●●●

●●●

●●

●●

●●●●●

●●●●●●

●●●●

●●

●●●

●●●●●

●●●●●●

●●

●●●●

●●●

●●

●●

●●●●●●●●●●

●●●●●

●●●●●

●●●

●●●●

●●●

●●

●●

●●

●●●

●●●●●

●●●

●●

●●●●●●

●●●●●●●●●

●●●●●

●●●●

●●

●●●●●

●●●●●

●●●●●●●

●●●●●●

●●●●●●

●●●●●●

●●●●●●●●●●●●

●●●●●●

●●●●●●

●●●

●●●●

●●

●●●●

●●●●

●●

●●●●●

●●●●●●

●●●●●

●●●●●●

●●●●

●●●

●●

●●

●●

●●●

●●●●

●●

●●●●●

●●

●●

●●

●●●●●

●●

●●●

●●●●●●

●●●●●●

●●●●●

●●●●●●●●

●●●●●●●

●●●●●

●●●●●●

●●●●●●

●●●●●●

●●

●●●●

●●●●●●

●●●●●●●●●●●●

●●●●●●

●●●

●●●●

●●●●●●

●●●●●

●●●●●●●

●●

●●●●

●●●

●●●

●●●●●●

●●●●●●

●●●●

●●

●●●●

●●●

●●

●●

●●●●●●

●●

●●

●●●●●●

●●

●●

●●●●●●●

●●●

●●●

●●●

●●

●●●

●●●●●●

●●●

●●●●

●●●●●●

●●●

●●●

●●●●

●●

●●●●●●

●●

●●●●

●●●●●●

●●

●●●●

●●

●●●●

●●●●●

●●

●●●●

●●

●●●●

●●●●

●●

●●

●●●●

●●●●●●

●●

●●●●

●●●●●●

●●●●●

●●

●●●

●●

●●●

●●●

●●●

●●

●●

●●

●●●●●●

●●●

●●●●●●●●●

●●●●●

●●

●●●●

●●●●

●●●●

●●●●●

●●●●●

●●

●●●●

●●●●●

●●●

●●

●●

●●●●●

●●●●●●

●●

●●●●

●●●●●●

●●●●●

●●●●●●●●

●●●●

●●

●●●●●●

●●●●

●●●●●

●●●

●●

●●●

●●

●●

●●●

●●●●●●●●

●●●

●●●●●●

●●●●

●●●●●●●

●●●

●●

●●●

●●

●●●

●●●

●●●

●●●●●●

●●

●●●●

●●●●

●●●●●

●●●●●●

●●●

●●●

●●●●●

●●

●●

●●●●

●●●●●●

●●●●●●

●●●●●●

●●

●●●●

●●●●●●●●

●●

●●●●

●●

●●●

●●●●●●

●●●●●

●●●●●●

●●●●

●●●

●●●

●●

●●

●●

●●●●●

●●

●●

●●●●

●●

●●●

●●●

●●●●

●●

●●●●●●

●●

●●●●

●●

●●●●●●●●●●●

●●●●●●

●●●●●●

●●

●●

●●●

●●●

●●

●●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●●

●●

●●

● ●●

●●

●●

●●●●

●●

●●

●●

●●●●

●●●●●

●●●●●

●●●●●●

●●●●●

●●

●●●●●●

●●●●●

●●

●●●

●●●

●●●●●

●●●●●

●●

●●●●

●●

●●●

●●

●●

●●●

●●●●●

●●●●●●

●●

●●●●●●●●●●

●●

●●●

●●●●●●

●●●

●●

●●

●●●

●●●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●●●●

●●●

●●●●

●●

●●●●

●●

●●●●

●●

●●●

●●●●●●

●●●●●●

●●●●

●●

●●

●●●●

●●●●●

●●●●●

●●●

●●●

●●●●●●●

●●●●

●●

●●●●●

●●

●●●

●●●

●●●

●●

●●●●●

●●●●●●

●●●●●●

●●●●

●●

●●●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●●●

●●●

●●●●

●●●●●

●●●●

●●●

●●●

●●●

●●

●●

●●●

●●●●

●●

●●

●●●●

●●●●●

●●

●●●

●●●●●●●●

●●●●

●●

●●

●●

●●●●

●●●●●

●●●●●●

●●

●●●

●●

●●●●●

●●

●●

●●●●●●

●●●●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●●●

●●●

●●

●●

●●●●

●●●

●●

●●●●●●●

●●

●●●

●●●

●●

●●●

●●

●●

●●●

●●

●●●●

●●●●

●●

●●●●●

●●●●●●

●●●●●

●●●●

●●

●●●●●

●●●●●

●●

●●●

●●●●●●

●●●

●●●

●●●●●●

●●●●●

●●●●●

●●●●●●●●

●●●

●●●●●

●●●

●●

●●

●●

●●●

●●●

●●●

●●

●●●

●●●●

●●●

●●●●●

●●●●

●●●●●●

●●

●●

●●●●●

●●●

●●

●●●

●●

●●●

●●

●●●●●

●●

●●●●●●●●●●●●

●●●

●●●●●

●●

●●●●

●●●●●

●●●●

●●●●●

●●●●

●●●●●

●●

●●●

●●●●●

●●●●●●

●●

●●●●

●●●

●●●

●●

●●●

●●

●●●●●

●●●

●●●

●●

●●●●

●●●●

●●

●●●●●●

●●●

●●●●●●

●●●

●●

●●●●●●

●●●●●●

●●●●●

●●

●●

●●●

●●

●●●●●

●●

●●●

●●●●●

●●●●●

●●●●●

●●●●●

●●●●●

●●

●●●

●●

●●

●●●

●●

●●

●●●

●●●●●●●

●●●●●●

●●●●●●

●●●●

●●

●●

●●●

●●●●●●

●●

●●●

●●●●●●

−2 0 2

−3

−2

−1

01

2

Exponential decrease model

Theoretical Quantiles

Sam

ple

Qua

ntile

s

●●●

●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●●

●●●

●●

●●●

●●

●●●●●

●●

●●●

●●●●

●●

●●●

●●●●

●●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●●●●

●●●●

●●●

●●●●●

●●

●●●●

●●●●●

●●

●●●●●

●●●

●●●●

●●●

●●●

●●

●●

●●●

●●●

●●

●●●

●●

●●●

●●●

●●●

●●

●●●●●●

●●●●

●●

●●

●●●●

●●

●●

●●●●

●●●

●●

●●●

●●●●●●

●●

●●●●

●●

●●●

●●●●●

●●●●●

●●●●●

●●●●

●●●●

●●

●●●●

●●

●●●●

●●●

●●●

●●●●

●●

●●●●

●●

●●●

●●

●●●●●●

●●

●●●

●●

●●●●

●●

●●

●●●

●●●

●●

●●

●●●

●●

●●●●●

●●●

●●

●●●

●●●

●●

●●

●●●●●●

●●

●●●●

●●

●●●●

●●

●●●

●●

●●●

●●●●

●●

●●●●●

●●

●●●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●●

●●●

●●●

●●

●●●

●●●●●

●●

●●●●

●●●●●●

●●●●●●

●●●●●

●●●●●●

●●●●

●●●●

●●●●

●●

●●●

●●

●●●

● ●

●●●

●●

●●

●●

●●●●

●●●

●●●

●●

●●

●●

●●●

●●●●●

●●●●

●●●

●●

●●

●●

●●

●●●

●●

●●●●

●●●

●●

●●●●

●●

●●●

●●

●●●●●

●●

●●●

●●

●●●

●●

●●●●

●●

●●●

●●●●

●●

●●

●●●●

●●●●●

●●

●●

●●●

●●

●●●

●●

●●●

●●

●●●

●●

●●

●●●●

●●●●

●●

●●●●●

●●●

●●●

●●

●●●

●●

●●

●●

●●

●●●

●●●

●●

●●●●

●●●●

●●

●●

●●●

●●

●●

●●

●●●

●●●●

●●●●●

●●

●●

●●●●

●●

●●●●●

●●●●●

●●

● ●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●●●

●●●

●●●

●●

●●●●

●●●●

●●

●●●

●●●

●●

●●●

●●●●

●●

●●

●●●●

●●

●●●●

●●

●●●

●●●●●●●●

●●●

●●

●●●●

●●●●

●●

●●

●●●●●●●●●●●

●● ●●●●

●●

●●●●

●●

●●●●

●●●●

●●

●●●

●●

●●

●●●●

●●●●●

●●●●●●

●●●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●●

●●

●●●●● ●●●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●●●

●●●●●

●●

●●●

●●●

●●●

●●●●●●

●●●

●●

●●

●●●●

●●

●●

●●

●●●

●●

●●

●●●●

●●●●

●●●

●●●

●●●

●●●●●

●●

●●

●●

●●●

●●●●

●●●●●●

●●●●

●●●

●●

●●●

●●

●●

●●●

●●

●●●

●●

●●●

●●●●●

●●

●●

●●

●●

●●●●●●●●●●●●●

●●●

●●

●●●●

●●

●●●●

●●

●●●●

●●●●●

●●●●

●●

●●●●●●●●●●

●●●●●●●

●●●●

●●●●●●

●●●●●

●●●●●

●●

●●●●

●●

●●

●●

●●●

●●

●●●

●●

●●●

●●●

●●

●●●

●●●●

●●

●●

●●

●●

●●●●

●●●●●

●●

●●

●●●

●●

●●

●●●

●●

●●●●

●●●●●●

●●●

●●●●

●●●●

●●●

●●●●●●

●●●●●

●●●

●●●

●●●●●●

●●●

●●●

●●

●●●●

●●

●●●

●●●●●●

●●●●●

●●●●●●

●●●●●

●●●●● ●●●

●●●

●●●●●●

●●

●●●●

●●●

●●

●●●●●

●●●●

●●

●●●●

●●

●●●

●●●

●●

●●

●●●●●

●●

●●

●●●●●●●

●●●●

●●●●●

●●●

●●●●●

●●●

●●●

●●●

●●

●●●

●●●●●●

●●

●●

●●●

●●●

●●

●●

●●●

●●●

●●

●●●●

●●

●●●●

●●

●●●

●●

●●●●

●●

●●●●

●●●

●●

●●

●●

●●

●●●

●●

●●●

●●●

●●●● ●

●●

●●●

●●

●●

●●●

●●

●●

●●●●●●

●●●

●●●●●●

●●●

●●●●

●●

●●

●●●

●●

●●

●●●

●●●●●

●●●

●●

●●

●●●

●●●●

●●

●●

●●●●

●●

●●●●●●

●●

●●●●

●●●●

●●

●●●●●

●●●●

●●●

●●●●

●●●

●●●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●●●

●●

●●●

●●

●●●●●●●

●●●

●●

●●●

●●

●●●

●●

●●●

●●●●

●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●●●

●●

●●

●●●●●

●●

●●

●●●●

●●●●●

●●●●●

●●●●●

●●

●●●●

●●

●●●

●●●

●●

●●

●●●

●●

●●●

● ●●

●●●●

●●●

●●

●●●

●●●

●●

●●●

●●

●●

●●●●●

●●

●●●●

●●

●●●●

●●

●●

●●

●●●●

●●

●●

●●●●

●●

●●●●●

●●●●●●

●●

●●●●

●●●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●●

●●

●●●●

●●●●●

●●●●●●

●●●

●●●●

●●●

●●

●●

●●

● ●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●●●●●

●●●●●

●●

●●●

●●●

●●●●

●●

●●

●●

●●●

●●

●●●●

●●

●●●●

●●

●●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●●

●●●●

●●

●●●

●●

●●●●

●●

●●●

●●●●●

●●

●●

●●●

●●

●●

●●●

●●

●●●

●●●●

●●

●●●

●●●

●●●

●●●

●●

●●●

●●

●●

●●

●●

●●●

●●

●●●●●

●●●

●●●

●●●●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●●●

●●●●●

●●●●

●●●

●●●

●●●

●●

●●

●●●

●●●●

●●

●●

●●●●

●●●●●

●●

●●●

●●●●●

●●

●●●

●●

●●

●●

●●

●●

●●●●

●●●●●

●●

●●●

●●

●●●●

●●●

●●

●●●●●

●●●●

●●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●●●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●

●●

●●●

●●

●●●●

●●

●●●

●●●●●

●●

●● ●

●●●

●●

●●●

●●

●●

●●●

●●

●●●

●●●●●●

●●

●●●

●●●●●●

●● ●

●●

●●

●●●●

●●●

●●

●●

●●●

●●●●

●●●

●●

●●●●

●●●

●●

●●

●●●●

●●

●●●●

●●

●●●●

●●●●●●

●●

●●

●●

●●●●●●

●●

●●

●●●

●●

●●

●●●

●●

●●●●

●●●●●●

●●

●●

●●●●●

●●

●●●●

●●●●●

●●●●

●●

●●●

●●●

●●

●●●

●●

●●●

●●

●●●

●●●●●

●●●

●●●

●●●

●●

●●

●●●

●●

●●●●

●●●

●●

●●

●●

●●

●●●●

●●

●●●●●

●●

●●●●●●●

●●

●●●●

●●●●●

●●●●●

●●

●●

●●●

●●

●●●●●

●●

●●

●●●●●

●●●●●

●●

●●●

●●●●●

●●●●●●●

●●●

●●

●●

●●●

●●●●

●●●

●●

●●●●●

●●●●●

●●●●●●

●●●●●

●●

●●●

●●●●●

●●

●●●

●●●●

●●

−2 0 2

−1.

5−

1.0

−0.

50.

00.

51.

01.

5

Diggle model

Theoretical Quantiles

Sam

ple

Qua

ntile

s

qqnorm(resid(mExp),main="Exponential decrease model")

qqnorm(resid(mGauss),main="Diggle model")

DSL (MATH) AS / SmB Day 5 51 / 60

Page 52: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Semi-variogram: γ(h) = 12var

(X (t + h)− X (t)

)Exponential decrease model

Distance

Sem

ivar

iogr

am

0.1

0.2

0.3

0.4

0.5

0.6

2 4 6 8 10

● ●● ● ●

Diggle model

Distance

Sem

ivar

iogr

am

0.2

0.4

0.6

0.8

1.0

2 4 6 8 10

●●

● ●●

plot(Variogram(mExp),ylim=c(0,0.7))

plot(Variogram(mGauss),ylim=c(0,1.1))

DSL (MATH) AS / SmB Day 5 52 / 60

Page 53: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Choice of repeated measurements modelResidual and normal quantile plots acceptable for all models

Model Compound symmetry Exponential decrease Diggle

AIC 3172 1397 1514

Akaike Information Criterion (AIC) clearly prefers the exponentialdecrease model, which we describe as:

“An ANOVA with random effect of plant and residual errorscorrelated within plants. The errors consist of an independentcomponent and a component with exponential decreasingcorrelation. For the fixed effects we used the concatenation ofthe full factorial design of (treatment,age,provenance) and thefull factorial design of (treatment,block)”.

DSL (MATH) AS / SmB Day 5 53 / 60

Page 54: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Overview of steps in a repeated measurements analysis

List and classify the variables in the design.I Done (see slide 44).

Make plots of individual, and perhaps averaged, response profiles.I Done (see slides 39 and 40).

Choose and validate a correlation structure.I Done (see slides 50 to 53).

Test on fixed effects: Done as usual for ANOVA and ANCOVAmodels.

I Remember to refit models using maximum likelihood (method="ML").I Unfortunately the drop1() function does not work for lme-objects. So

this has to be done by hand (see R guide Section 9.5.3).I Automatic model selection based on AIC may be done using

stepAIC() from the MASS-package.

Report estimates and conclusions from the final model (as usual, e.g.using the emmeans-package as seen on next slide).

DSL (MATH) AS / SmB Day 5 54 / 60

Page 55: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Visualization of estimated marginal means

N'Kundi Nobéré Samé

Kolangal Komodiguili Koumadiobo Liptougou

2 4 6 8 1012 2 4 6 8 1012 2 4 6 8 1012

2 4 6 8 1012

4

8

12

16

4

8

12

16

age

Dia

met

er

Treatment

1

2

3

my.emm <- as.data.frame(emmeans(mExp.final,~factor(age)|Treatment:Provenance))

ggplot(my.emm) +

geom_line(aes(x=age,y=emmean^(3/2),group=Treatment,col=Treatment)) +

geom_errorbar(aes(x=age,ymin=lower.CL^(3/2),ymax=upper.CL^(3/2),col=Treatment)) +

facet_wrap(.~Provenance) +

scale_x_continuous(breaks=seq(2,12,2)) +

ylab("Diameter")

DSL (MATH) AS / SmB Day 5 55 / 60

Page 56: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Questions?

And then a break!?

After the break we discuss analysis of summary measures as an“easy” alternative to repeated measurements models.

DSL (MATH) AS / SmB Day 5 56 / 60

Page 57: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Analysis of Summary measuresAn alternative to the repeated measurements analysis discussed above

Idea:I Reduce the curve for each subject to a single value.I Analyze this summary measure as usual (ANOVA, regression, . . . ).

As summary measures we could for example use:I Average response over time.I Area under curve (AUC, often used in medicine).I Slope of curve (rate of increase).I Maximal response.I Position (e.g. time) of maximal response.I Halving time since maximal response.I Curvature: fit α + β ∗ time + γ ∗ time2 for each individual and use γ.

Note: The summary measures should be computed for each subject — noton the average profiles!

DSL (MATH) AS / SmB Day 5 57 / 60

Page 58: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Principles for choosing summary measures

Select a measure that addresses the problem under investigation.

Do not choose summary measures on the basis of visual inspection ofthe treatment differences — this is cheating.

I But it is OK to plot all profiles in one graph and select “typicalfeatures” of the curves for further investigation.

You may analyze more than one summary measure. If so, then choosesome that reflect different aspects of the curves. For example:

I AUC and average response is NOT a good combination.I AUC and rate of increase might be a good combination.

But be aware of the associated multiple testing problem.

DSL (MATH) AS / SmB Day 5 58 / 60

Page 59: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Analysis of summary measures: Pros and Cons

Advantages:I Simple analysis, which is more easily communicated.I Often powerful analysis if the summary measure is chosen appropriately.I Model validation more easy and transparent.

Disadvantages:I Each curve is reduced to a single value — loss of information?I Which summary measure should be used?I No investigation of the “temporal” structure, which might be

important for the problem under investigation.

DSL (MATH) AS / SmB Day 5 59 / 60

Page 60: Bo Markussen bomar@math.kuweb.math.ku.dk/~pdq668/SmB/material/day5_handout.pdf · 2019-12-13 · Random e ects & Repeated measurements Bo Markussen bomar@math.ku.dk Department of

Todays exercises

Exercise 5.1:I Read the exercise text, and discuss items 1 and 2 with your neighbours.I Before you continue with the statistical analysis we discuss the usage of

the explanatory variables in plenum.I And I’ll make the factor diagram for you.I In exercise 1.5 this dataset was analysed using a bunch of T-tests.

Exercise 5.2:I The block factor round with 3 levels should be used with random

effect.I This violates the “rules of thumb” that factors with less than 5 levels

can be used with fixed effect. However, this is also a matter of taste.Moreover, this also allows you to try a model with more than onerandom effect.

Exercise 5.3:I You might remember this dataset as Data Example 3 in Exercise 1.2.

DSL (MATH) AS / SmB Day 5 60 / 60