lecture 5 - random effects modelscr173/sta444_sp17/slides/lec5.pdf · 2017. 2. 1. · 310 330 308...

36
Lecture 5 Random Effects Models Colin Rundel 02/01/2017 1

Upload: others

Post on 04-Sep-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Lecture 5Random Effects Models

Colin Rundel02/01/2017

1

Page 2: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Random Effects Models

2

Page 3: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Sleep Study Data

The average reaction time per day for subjects in a sleep deprivation study. On day0 the subjects had their normal amount of sleep. Starting that night they wererestricted to 3 hours of sleep per night. The observations represent the averagereaction time on a series of tests given each day to each subject.

library(lme4)

sleepstudy %>% tbl_df()## # A tibble: 180 × 3## Reaction Days Subject## <dbl> <dbl> <fctr>## 1 249.5600 0 308## 2 258.7047 1 308## 3 250.8006 2 308## 4 321.4398 3 308## 5 356.8519 4 308## 6 414.6901 5 308## 7 382.2038 6 308## 8 290.1486 7 308## 9 430.5853 8 308## 10 466.3535 9 308## # ... with 170 more rows

3

Page 4: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

EDA

200

300

400

0.0 2.5 5.0 7.5

Days

Rea

ctio

n

Subject

308

309

310

330

331

332

333

334

335

337

349

350

351

352

369

370

371

372

4

Page 5: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

EDA (small multiples)

370 371 372

349 350 351 352 369

332 333 334 335 337

308 309 310 330 331

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

200

300

400

200

300

400

200

300

400

200

300

400

Days

Rea

ctio

n

5

Page 6: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Bayesian Linear Model

## model{## # Likelihood## for(i in 1:length(Reaction)){## Reaction[i] ~ dnorm(mu[i],tau2)## mu[i] <- beta_0 + beta_1*Days[i]#### Y_hat[i] ~ dnorm(mu[i],tau2)## }#### # Prior for beta## beta_0 ~ dnorm(0,1/10000)## beta_1 ~ dnorm(0,1/10000)#### # Prior for sigma / tau2## sigma ~ dunif(0, 100)## tau2 <- 1/(sigma*sigma)## }

6

Page 7: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

MCMC Diagnostics

2000 3000 4000 5000 6000 7000

230

250

270

Iterations

Trace of beta_0

230 240 250 260 270 280

0.00

0.03

0.06

Density of beta_0

N = 5000 Bandwidth = 1.253

2000 3000 4000 5000 6000 7000

68

12

Iterations

Trace of beta_1

6 8 10 12 14 16

0.00

0.15

0.30

Density of beta_1

N = 5000 Bandwidth = 0.2356

2000 3000 4000 5000 6000 7000

4050

Iterations

Trace of sigma

40 45 50 55

0.00

0.10

Density of sigma

N = 5000 Bandwidth = 0.4869

7

Page 8: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Model fit

370 371 372

349 350 351 352 369

332 333 334 335 337

308 309 310 330 331

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

200

300

400

200

300

400

200

300

400

200

300

400

Days

Rea

ctio

n

8

Page 9: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Residuals

−100

−50

0

50

100

150

0.0 2.5 5.0 7.5

Days

resi

d

Subject

308

309

310

330

331

332

333

334

335

337

349

350

351

352

369

370

371

372

9

Page 10: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Residuals by subject

370 371 372

349 350 351 352 369

332 333 334 335 337

308 309 310 330 331

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

−40

−20

0

20

40

0

25

50

75

100

125

−10

0

10

20

−20

0

20

40

60

−90

−60

−30

0

−25

0

25

50

−100

−75

−50

−25

0

−20

0

20

−60

−40

−20

0

20

40

0

10

20

30

−90

−60

−30

0

0

10

20

30

−25

0

25

50

−40

−20

0

20

0

50

100

−100

−50

0

50

100

150

−40

−30

−20

−10

0

−25

0

25

Days

resi

d

10

Page 11: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Random Intercept Model

11

Page 12: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Data coding

sleepstudy = sleepstudy %>%mutate(Subject_index = as.integer(Subject))

sleepstudy[c(1:2,11:12,21:22,31:32),]## Reaction Days Subject Subject_index## 1 249.5600 0 308 1## 2 258.7047 1 308 1## 11 222.7339 0 309 2## 12 205.2658 1 309 2## 21 199.0539 0 310 3## 22 194.3322 1 310 3## 31 321.5426 0 330 4## 32 300.4002 1 330 4

12

Page 13: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Random Intercept Model

Let i represent each observation and j(i) be subject in oberservation i then

Yi = αj(i) + β1 × Days+ ϵi

αj ∼ N (β0, σ2α)

ϵi ∼ N (0, σ2)

β0, β1 ∼ N (0, 10000)

σ, σα ∼ Unif(0, 100)

13

Page 14: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Random Intercept Model - JAGS

## model{## for(i in 1:length(Reaction)) {## Reaction[i] ~ dnorm(mu[i],tau2)## mu[i] <- alpha[Subject_index[i]] + beta_1*Days[i]#### Y_hat[i] ~ dnorm(mu[i],tau2)## }#### for(j in 1:18) {## alpha[j] ~ dnorm(beta_0, tau2_alpha)## }#### sigma_alpha ~ dunif(0, 100)## tau2_alpha <- 1/(sigma_alpha*sigma_alpha)#### beta_0 ~ dnorm(0,1/10000)## beta_1 ~ dnorm(0,1/10000)#### sigma ~ dunif(0, 100)## tau2 <- 1/(sigma*sigma)## }

14

Page 15: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

MCMC Diagnostics

2000 3000 4000 5000 6000 7000

200

280

Iterations

Trace of beta_0

200 220 240 260 280

0.00

0.04

Density of beta_0

N = 5000 Bandwidth = 1.963

2000 3000 4000 5000 6000 7000

811

Iterations

Trace of beta_1

8 9 10 11 12 13 140.

00.

4

Density of beta_1

N = 5000 Bandwidth = 0.1591

15

Page 16: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

2000 3000 4000 5000 6000 7000

2634

Iterations

Trace of sigma

26 28 30 32 34 36 38

0.00

0.20

Density of sigma

N = 5000 Bandwidth = 0.3421

2000 3000 4000 5000 6000 7000

2080

Iterations

Trace of sigma_alpha

20 40 60 80 100

0.00

0.05

Density of sigma_alpha

N = 5000 Bandwidth = 1.48

16

Page 17: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

2000 3000 4000 5000 6000 7000

260

Iterations

Trace of alpha[1]

260 280 300 320

0.00

Density of alpha[1]

N = 5000 Bandwidth = 1.986

2000 3000 4000 5000 6000 7000

140

200

Iterations

Trace of alpha[2]

140 160 180 200

0.00

0.04

Density of alpha[2]

N = 5000 Bandwidth = 2.005

17

Page 18: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Model fit

370 371 372

349 350 351 352 369

332 333 334 335 337

308 309 310 330 331

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

100

200

300

400

500

100

200

300

400

500

100

200

300

400

500

100

200

300

400

500

Days

Rea

ctio

n

18

Page 19: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Residuals by subject

370 371 372

349 350 351 352 369

332 333 334 335 337

308 309 310 330 331

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

−40

−20

0

20

−50

−25

0

25

50

−20

−10

0

10

−25

0

25

50

−60

−30

0

30

60

−50

−25

0

25

−20

0

20

−20

0

20

−50

−25

0

25

50

−20

−10

0

10

−20

0

20

40

−20

−10

0

10

20

−25

0

25

50

−50

−25

0

25

−50

0

50

−100

−50

0

50

100

−20

−10

0

10

20

−25

0

25

50

Days

resi

d

19

Page 20: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Random effects

309

310

335

349

351

370

371

334

330

369

332

331

350

333

372

352

308

337

150 200 250 300 350

alpha

Sub

ject

20

Page 21: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Why not a fixed effect for Subject?

Not going to bother with the Bayesian model here because of all the dummy codingand betas … . . .

l = lm(Reaction ~ Days + Subject - 1, data=sleepstudy)summary(l)#### Call:## lm(formula = Reaction ~ Days + Subject - 1, data = sleepstudy)#### Residuals:## Min 1Q Median 3Q Max## -100.540 -16.389 -0.341 15.215 131.159#### Coefficients:## Estimate Std. Error t value Pr(>|t|)## Days 10.4673 0.8042 13.02 <2e-16 ***## Subject308 295.0310 10.4471 28.24 <2e-16 ***## Subject309 168.1302 10.4471 16.09 <2e-16 ***## Subject310 183.8985 10.4471 17.60 <2e-16 ***## Subject330 256.1186 10.4471 24.52 <2e-16 ***## Subject331 262.3333 10.4471 25.11 <2e-16 ***## Subject332 260.1993 10.4471 24.91 <2e-16 ***## Subject333 269.0555 10.4471 25.75 <2e-16 ***## Subject334 248.1993 10.4471 23.76 <2e-16 ***## Subject335 202.9673 10.4471 19.43 <2e-16 ***## Subject337 328.6182 10.4471 31.45 <2e-16 ***## Subject349 228.7317 10.4471 21.89 <2e-16 ***## Subject350 266.4999 10.4471 25.51 <2e-16 ***## Subject351 242.9950 10.4471 23.26 <2e-16 ***## Subject352 290.3188 10.4471 27.79 <2e-16 ***## Subject369 258.9319 10.4471 24.79 <2e-16 ***## Subject370 244.5990 10.4471 23.41 <2e-16 ***## Subject371 247.8813 10.4471 23.73 <2e-16 ***## Subject372 270.7833 10.4471 25.92 <2e-16 ***## ---## Signif. codes: 0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1#### Residual standard error: 30.99 on 161 degrees of freedom## Multiple R-squared: 0.9907, Adjusted R-squared: 0.9896## F-statistic: 901.6 on 19 and 161 DF, p-value: < 2.2e-16

21

Page 22: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Comparing Model fit

370 371 372

349 350 351 352 369

332 333 334 335 337

308 309 310 330 331

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

200

300

400

200

300

400

200

300

400

200

300

400

Days

Rea

ctio

n

22

Page 23: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

310 330

308 309

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

200

300

400

200

300

400

Days

Rea

ctio

n

23

Page 24: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Random effects vs fixed effects

309

310

335

349

351

370

371

334

330

369

332

331

350

333

372

352

308

337

150 200 250 300 350

alpha

Sub

ject

24

Page 25: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Random Intercept Model (Informative prior for σα)

## model{## for(i in 1:length(Reaction)) {## Reaction[i] ~ dnorm(mu[i],tau2)## mu[i] <- alpha[Subject_index[i]] + beta_1*Days[i]#### Y_hat[i] ~ dnorm(mu[i],tau2)## }#### for(j in 1:18) {## alpha[j] ~ dnorm(beta_0, tau2_alpha)## }#### sigma_alpha ~ dunif(0, 10)## tau2_alpha <- 1/(sigma_alpha*sigma_alpha)#### beta_0 ~ dnorm(0,1/10000)## beta_1 ~ dnorm(0,1/10000)#### sigma ~ dunif(0, 100)## tau2 <- 1/(sigma*sigma)## }

25

Page 26: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Comparing Model fit (Constrainged α)

370 371 372

349 350 351 352 369

332 333 334 335 337

308 309 310 330 331

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

200

300

400

200

300

400

200

300

400

200

300

400

Days

Rea

ctio

n

26

Page 27: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

310 330

308 309

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

200

300

400

200

300

400

Days

Rea

ctio

n

27

Page 28: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Prior Effect on α

Random Intercept (non−informative prior) Random Intercept (informative prior)

150 200 250 300 350 150 200 250 300 350

309

310

335

349

351

370

371

334

330

369

332

331

350

333

372

352

308

337

alpha

Sub

ject

28

Page 29: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Some Distribution Theory (about Y | β0, β1, σ, σα)

29

Page 30: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Random intercept and slope model

30

Page 31: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Model

Let i represent each observation and j(i) be the subject in oberservation ithen

Yi = αj(i) + βj(i) × Days+ ϵi

αj ∼ N (β0, σ2α)

βj ∼ N (β1, σ2β)

ϵi ∼ N (0, σ2)

β0, β1 ∼ N (0, 10000)

σ, σα, σβ ∼ Unif(0, 100)

31

Page 32: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Model - JAGS

## model{## for(i in 1:length(Reaction)) {## Reaction[i] ~ dnorm(mu[i],tau2)## mu[i] <- alpha[Subject_index[i]] + beta[Subject_index[i]]*Days[i]## Y_hat[i] ~ dnorm(mu[i],tau2)## }#### sigma ~ dunif(0, 100)## tau2 <- 1/(sigma*sigma)#### for(j in 1:18) {## alpha[j] ~ dnorm(beta_0, tau2_alpha)## beta[j] ~ dnorm(beta_1, tau2_beta)## }#### beta_0 ~ dnorm(0,1/10000)## beta_1 ~ dnorm(0,1/10000)#### sigma_alpha ~ dunif(0, 100)## tau2_alpha <- 1/(sigma_alpha*sigma_alpha)#### sigma_beta ~ dunif(0, 100)## tau2_beta <- 1/(sigma_beta*sigma_beta)## } 32

Page 33: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Model fit

370 371 372

349 350 351 352 369

332 333 334 335 337

308 309 310 330 331

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

200

300

400

500

200

300

400

500

200

300

400

500

200

300

400

500

Days

Rea

ctio

n

33

Page 34: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Comparison

370 371 372

349 350 351 352 369

332 333 334 335 337

308 309 310 330 331

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

200

300

400

200

300

400

200

300

400

200

300

400

Days

Rea

ctio

n

34

Page 35: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

310 330

308 309

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

200

300

400

200

300

400

Days

Rea

ctio

n

35

Page 36: Lecture 5 - Random Effects Modelscr173/Sta444_Sp17/slides/Lec5.pdf · 2017. 2. 1. · 310 330 308 309 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 200 300 400 200 300 400 Days Reaction 23. Randomeffectsvsfixedeffects

Residuals by subject

370 371 372

349 350 351 352 369

332 333 334 335 337

308 309 310 330 331

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

0.0 2.5 5.0 7.5 0.0 2.5 5.0 7.5

−40

−20

0

20

−30−20−10

01020

−20

−10

0

10

−25

0

25

−10

0

10

20

−40

−20

0

20

−20

−10

0

10

−20

−10

0

10

20

30

−40

−20

0

20

−20

−10

0

10

−10

−5

0

5

10

−10

0

10

20

−40

−20

0

20

40

−40

−20

0

20

−100

−50

0

50

−100

−50

0

50

100

−20

−10

0

10

20

−40

−20

0

20

40

Days

resi

d

36