Pharmaceutical Sciences, University of Copenhagen

Written examination : Test exam January 2013

Name of course: Statistical Design and Analysis of Experiments

Course code : F0910-B2-2E12 (former FFKKA9041)

Aids and facilities allowed: All usual (books, notes, solutions to exercises etc.)

Henrik

This questionnaire is answered by participant no.

Instructions: The questionnaire consists of three so-called essay-problems and 15 multiple

choice questions for which only one answer should be given for each question.

Answers to the essay problems are written in the present word-document template.

The answers to the multiple choice questions are given in the in the table below. If more than one answer to a multiple choice question is given, the question is considered ”not answered”.

The multiple choice questions are distributed over different problems with numbering IV,

V,...,XIII written in the text. The numbering of the individual questions is given as (1),(2),...,(15) in the text.

Fill in the following table with your answers to the multiple choice questions:

Problems / IV / V / VI / VII / VIII / IX / X / XI / XII / XII
Questions / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 / 9 / 10 / 11 / 12 / 13 / 14 / 15
Answers / 4 / 3 / 3 / 4 / 5 / 3 / 2 / 4 / 5 / 2 / 2 / 2 / 3 / 3 / 4

Your answers to the essay problems count 50% and your multiple choice answers count another 50% when your performance is evaluated.

Write your answers to the essay problems on the following pages.

The answers start here:

(If you want to write some of your answers “by hand” you can use the IT-paper and put it directly into your document)

Problem I:

rm(list=ls())

Data1<-read.table("data1.txt",header=TRUE,dec=".")

Data1

attach(Data1)

Oper<-as.factor(Oper)

Type<-as.factor(Type)

Week<-as.factor(Week)

contrasts(Oper)<-"contr.sum"

contrasts(Type)<-"contr.sum"

contrasts(Week)<-"contr.sum"

model1<-lm(Weight~Oper+Type+Week)

anova(model1)

model2<-lm(Weight~Type+Week)

anova(model2)

summary(model2)

Type4 <- -(-3.125+4.625+16.875)

Type4

Se<-sqrt(40.36)

Se

Sw<-sqrt((479.42-40.36)/4)

Sw

plot(model2$fitted.values,model2$residuals)

# Here save the plot as a png figure and import it into your

# answering document.

> Data1

Weight Oper Type Week

1 109 AL 1 19

2 121 SH 2 19

3 132 OL 3 19

4 105 KK 4 19

5 95 SH 1 22

6 94 OL 2 22

7 110 KK 3 22

8 76 AL 4 22

9 115 OL 1 24

10 125 KK 2 24

11 136 AL 3 24

12 84 SH 4 24

13 109 KK 1 29

14 119 AL 2 29

15 130 SH 3 29

16 102 OL 4 29

Analysis of Variance Table

Response: Weight

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

Oper 3 47.25 15.75 0.2991 0.82530 # EMS = 4*s2(Oper)+s2(error)

Type 3 2614.25 871.42 16.5459 0.00263 ** # EMS = 4*phi(Type)+s2(error)

Week 3 1438.25 479.42 9.1028 0.01189 * # EMS = 4*s2(Week)+s2(error)

Residuals 6 316.00 52.67 # EMS = s2(error)

> anova(model2)
Analysis of Variance Table
Response: Weight
Df Sum Sq Mean Sq F value Pr(>F)
Type 3 2614.25 871.42 21.590 0.0001899 ***
Week 3 1438.25 479.42 11.878 0.0017544 **
Residuals 9 363.25 40.36
---
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 110.125 1.588 69.337 1.36e-13 ***
Type1 -3.125 2.751 -1.136 0.285311
Type2 4.625 2.751 1.681 0.127014
Type3 16.875 2.751 6.134 0.000172 ***
Week1 6.625 2.751 2.408 0.039361 *
Week2 -16.375 2.751 -5.952 0.000215 ***
Week3 4.875 2.751 1.772 0.110138
########################################################################
# Do the following on paper and paste into your answering document

#

Type4 <- -(-3.125+4.625+16.875)

Type4

Se<-sqrt(40.36)

Se

Sw<-sqrt((479.42-40.36)/4)

Sw

Type4 <- -(-3.125+4.625+16.875) = -18.375

Se = 6.35 (residual standard afvigelse)

EMS(Week) = 4*s2(Week)+s2(error)

Sw = 10.48 (standardafvidelse mellem Weeks)

########################################################################

The plot looks OK.

You can write your further comments her, fx.

Problem II

rm(list=ls())

Data2<-read.table("data2.txt",header=TRUE,dec=".")

Data2

attach(Data2)

contrasts(Fung)<-"contr.sum"

contrasts(Ster)<-"contr.sum"

contrasts(Batch)<-"contr.sum"

model1<-lm(Resid~Fung+Ster+Fung:Ster+Ster:Batch+Fung:Ster:Batch)

anova(model1)[,1:3]

Finalmodel<-lm(Resid~Fung+Ster+Ster:Batch)

anova(Finalmodel)[,1:3]

summary(Finalmodel)

Data2<-read.table("data2.txt",header=TRUE)
> Data2
Resid Fung Ster Batch
1 21 A T1 B1
. . . . .
44 9 B T1 B2
45 19 B T2 B3
46 10 B T2 B4
47 32 B F B5
48 35 B F B6
> attach(Data2)
> contrasts(Fung) <-"contr.sum"
> contrasts(Ster) <-"contr.sum"
> contrasts(Batch) <-"contr.sum"
> # Model : Y = mu + Fung+Ster+Fung*Ster+Batch(Ster)+Batch*Fung(Ster)+error
> model1<-lm(Resid~Fung+Ster+Fung:Ster+Ster:Batch+Fung:Ster:Batch)
> anova(model1)[,1:3]
Df Sum Sq Mean Sq
Fung 1 776.02 776.02
Ster 2 2538.79 1269.40
Fung:Ster 2 5.04 2.52
Ster:Batch 3 219.81 73.27
Fung:Ster:Batch 3 101.56 33.85
Residuals 36 854.25 23.73
> ################################################################################
> # Do the EMS table on paper and paste into your answering document, that is fastest:
> # EMS Fung = 24*phi(Fung) +4*s2(Batch*Fung(Ster))+s2(error)
> # EMS Ster = 16*phi(Ster)+8*s2(Batch(Ster))+4*s2(Batch*Fung(Ster))+s2(error)
> # EMS Fung:Ster = 8*phi(Fung:Ster) +4*s2(Batch*Fung(Ster))+s2(error)
> # EMS Batch(Ster) = 8*s2(Batch(Ster))+4*s2(Batch*Fung(Ster))+s2(error)
# EMS Batch*Fung(Ster) = +4*s2(Batch*Fung(Ster))+s2(error)
> # EMS error = +s2(error)
################################################################################
> Finalmodel<-lm(Resid~Fung+Ster+Ster:Batch)
> anova(Finalmodel)[,1:3]
Df Sum Sq Mean Sq
Fung 1 776.02 776.02
Ster 2 2538.79 1269.40
Ster:Batch 3 219.81 73.27
Residuals 41 960.85 23.44
################################################################################
> # The following is best made on paper separately using the anova table and then
> # pasted into your answering document.
> # F(Batch*fung(Ster))=33.85/23.73
> # Test (Batch*Fung(Ster))
> p1<-1-pf(33.85/23.73,3,36); p1 # not significant remove Batch*Fung(Ster)
[1] 0.251017
> # pool to new residual MS
> nys2<-(101.56+854.25)/39 # new residual
> # Test (Batch(Ster))
> p2<-1-pf(73.27/nys2,3,39);p2 # significant p=0.04
[1] 0.04256264
> # Test (Fung*Ster)
> p3<-1-pf(2.52/73.27,2,3); p3 # far from significant (F<1)
[1] 0.9665667
> # both Fung and Ster highly significant
> ################################################################################
> # Reduced model : Y = mu + Fung+Ster+Batch(Ster)+error
> ################################################################################
> summary(lm(Resid~Fung+Ster)) # Estimate fixed effects in model without
Call:
lm(formula = Resid ~ Fung + Ster)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 25.3958 0.7477 33.966 < 2e-16 ***
Fung1 4.0208 0.7477 5.378 2.74e-06 ***
Ster1 9.9792 1.0574 9.438 3.86e-12 ***
Ster2 -7.1458 1.0574 -6.758 2.59e-08 ***

# ESTIMATES:

Fung2 = -Fung1 = -4.0208

Ster3 = -(Ster1+Ster2) = -2.8334

> s2B = (73.27-nys2)/8; sqrt(s2B) # = variance(Batch(Ster))

[1] 2.468857

Var(B(Ster)) = 2.468857

Problem III

rm(list=ls())

Data3<-read.table("data3.txt",header=TRUE,dec=".")

Data3

attach(Data3)

AB<-A*B; AC<-A*C; AD<-A*D; BC<-B*C; BD<-B*D; CD<-C*D

#

# Remember all variables are [-1,+1] so fx AB will also be [-1,+1].

#

# Do regression with [-1,+1]-variables in the usual way as asked for in text:

#

model3<-lm(Y~A+B+C+D+E+F+G+AB+AC+AD+BC+BD+CD+Batch)

anova(model3)

qqnorm(model3$coefficients[2:15],datax=TRUE) # 15 terms in model

# the plot shows 6 significant terms: E, AB, B, A, Batch and C.

# (The plot is not asked for in the problem.)

Do the following on paper and paste into your document:

s2<-6.56

Fcrit<-qf(0.95,1,12) # Crirical F-value for alfa=0.05 and 1 and 12 df.

Fcrit

MScrit<-s2*Fcrit

MScrit # sums of squares (with 1 df) > MScrit are significant

# Significant effects are: A, B, C, E, AB and Batch (from anova table)

Finmodel3<-lm(Y~A+B+C+E+AB+Batch)

anova(Finmodel3)

summary(Finmodel3)

Code A B C D E F G Batch Y

1 (1) -1 -1 -1 -1 -1 -1 -1 1 45.0

2 a 1 -1 -1 -1 1 1 -1 -1 45.1

3 b -1 1 -1 -1 1 -1 1 -1 45.6

4 ab 1 1 -1 -1 -1 1 1 1 60.3

5 c -1 -1 1 -1 -1 1 1 -1 41.0

6 ac 1 -1 1 -1 1 -1 1 1 54.3

7 bc -1 1 1 -1 1 1 -1 1 52.1

8 abc 1 1 1 -1 -1 -1 -1 -1 58.5

9 d -1 -1 -1 1 1 1 1 -1 33.4

10 ad 1 -1 -1 1 -1 -1 1 1 54.9

11 bd -1 1 -1 1 -1 1 -1 1 56.6

12 abd 1 1 -1 1 1 -1 -1 -1 48.9

13 cd -1 -1 1 1 1 -1 -1 1 44.0

14 acd 1 -1 1 1 -1 1 -1 -1 53.8

15 bcd -1 1 1 1 -1 -1 1 -1 56.3

16 abcd 1 1 1 1 1 1 1 1 60.7

> attach(Data3)

> AB<-A*B; AC<-A*C; AD<-A*D; BC<-B*C; BD<-B*D; CD<-C*D

> model3<-lm(Y~A+B+C+D+E+F+G+AB+AC+AD+BC+BD+CD+Batch)

> anova(model3)

Analysis of Variance Table

Response: Y

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

A 1 244.141 244.141 738.4216 0.02342 *

B 1 284.766 284.766 861.2949 0.02168 *

C 1 59.676 59.676 180.4934 0.04730 *

D 1 2.806 2.806 8.4858 0.21052

E 1 111.831 111.831 338.2401 0.03458 *

F 1 1.266 1.266 3.8280 0.30080

G 1 0.391 0.391 1.1815 0.47349

AB 1 45.226 45.226 136.7883 0.05430 .

AC 1 1.756 1.756 5.3100 0.26066

AD 1 2.641 2.641 7.9868 0.21651

BC 1 0.141 0.141 0.4253 0.63210

BD 1 1.756 1.756 5.3100 0.26066

CD 1 7.701 7.701 23.2911 0.13007

Batch 1 128.256 128.256 387.9187 0.03230 *

Residuals 1 0.331 0.331

# Do the following on paper and paste it into your answering document:

> s2<-6.56

> Fcrit<-qf(0.95,1,12)

> Fcrit

[1] 4.747225

> MScrit<-s2*Fcrit

> MScrit # sums of squares (with 1 df) > MScrit are significant

[1] 31.1418

> # Significant effects are: A, B, C, E, AB and Batch (from anova table)

Finmodel3<-lm(Y~A+B+C+E+AB+Batch)

summary(Finmodel3)

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 50.6562 0.3612 140.250 2.42e-16 ***

A 3.9062 0.3612 10.815 1.86e-06 ***

B 4.2187 0.3612 11.680 9.69e-07 ***

C 1.9312 0.3612 5.347 0.000464 ***

E -2.6437 0.3612 -7.320 4.47e-05 ***

AB -1.6813 0.3612 -4.655 0.001194 **

Batch 2.8313 0.3612 7.839 2.60e-05 ***

Do the following on paper and paste it into your answering document:

A-effect=+2*3.9=7.8

B-effect=+8.4

C-effect=+3.9

E-effect=-5.3

You can write your further comments here, fx.

I have only put a few comments or conclusions in my document. To the exam I expect some (very) brief comments such as, for example, “The factor.. is significant” and the like.You can summarize your answers on the IT-paper and paste them into your answer.

1