0% found this document useful (0 votes)
66 views8 pages

Manova

The document discusses using MANOVA to compare three types of apple trees based on circumference and height, and performing a factorial experiment with two factors (rotational speed and lubricant) and two response variables (force and tension) on a 2x4 design repeated four times.

Uploaded by

Darkos134
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views8 pages

Manova

The document discusses using MANOVA to compare three types of apple trees based on circumference and height, and performing a factorial experiment with two factors (rotational speed and lubricant) and two response variables (force and tension) on a 2x4 design repeated four times.

Uploaded by

Darkos134
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Lab 7: MANOVA with R

Spring 2020 - Multivariate Data Analysis

Example 6.1
compare three different types of apple trees
– X1: circumference
– X2: height
ex6.1<-read.csv("./data/Example6-1.csv")
head(ex6.1) ] types
## type X1 X2 SSFSSDTSSE
## 1 1 11.1 2.57 SST SSE
SSB =
-

## 2 1 11.9 2.93
## 3 1 10.9 2.87
## 4 1 12.5 3.84
## 5 1 11.1 3.03
W ✓
eric -
ae

## 6 1 10.8 2.34 a-
-

µ →
n<-nrow(ex6.1)
n1<-sum(ex6.1$type==1); S1<-var(ex6.1[ex6.1$type==1,-1])
n2<-sum(ex6.1$type==2); S2<-var(ex6.1[ex6.1$type==2,-1])
n3<-sum(ex6.1$type==3); S3<-var(ex6.1[ex6.1$type==3,-1])
SST- Tot .
/ v. eine -

T<-(n-1)*var(ex6.1[,-1]) →
E<-(n1-1)*S1+(n2-1)*S2+(n3-1)*S3 → SSE
B<-T-E
nehm
ich
det(E)/det(B+E)

Ins
on
In -
ma
-

,
## [1] 0.9034644 se
EE ,
(
test.manova<-manova(cbind(X1,X2)~factor(type),data=ex6.1)
summary(test.manova,test=c("Wilks"))

## Df Wilks approx F num Df den Df Pr(>F)


## factor(type) 2 0.90346 0.5207 4 40 0.721
## Residuals 21
Calculate Pillai’s trace, Hotelling Lawley Trace, Roy’s greatest root of example 6.1
lambda<-eigen(solve(E)%*%B)$values
prod(1/(1+lambda)) # Wilk's lambda → other -
ay
he denkt
## [1] 0.9034644

summary(test.manova,test=c("Wilks"))

## Df Wilks approx F num Df den Df Pr(>F)


## factor(type) 2 0.90346 0.5207 4 40 0.721
## Residuals 21
to e.k-l.hn
sum(lambda/(1+lambda)) # Pillai's trace
→ der →
## [1] 0.09660179

summary(test.manova,test=c("Pillai"))

## Df Pillai approx F num Df den Df Pr(>F)


## factor(type) 2 0.096602 0.5329 4 42 0.7122
## Residuals 21
to cakd.tn
sum(lambda)# Hotelling Lawley Trace der way

## [1] 0.1067771

summary(test.manova,test=c("Hotelling-Lawley"))

## Df Hotelling-Lawley approx F num Df den Df Pr(>F)


## factor(type) 2 0.10678 0.50719 4 38 0.7307
## Residuals 21
to kalten
lambda[1] # Roy's greatest root

other way
-

## [1] 0.1060861

summary(test.manova,test=c("Roy"))

## Df Roy approx F num Df den Df Pr(>F)


## factor(type) 2 0.10609 1.1139 2 21 0.3469
## Residuals 21

⇒ c- -
nat rejct H .
Example 6.6
2*4 factorial design, repeated 4 times
– factor 1: rotational speed (A1,A2)
– factor 2: lubricant (B1, B2, B3, B4)
– variables
X1: force
X2: tension
ex6.6<-read.csv("./data/Example6-6.csv")
head(ex6.6) 4 Hr s -

t.ms z ,
-

## rotation lubricant X1 X2
## 1 A1 B1 7.80 90.4
## 2 A1 B1 7.10 88.9
## 3 A1 B1 7.89 85.9 h
## 4 A1 B1 7.82 88.8 mini .

Jo
-
## 5 A2 B1 7.12 85.1
/
-

a now
## 6 A2 B1 7.06 89.0
Xn
summary(aov(X1~rotation+lubricant+rotation*lubricant,data=ex6.6))

rot .li
## Df Sum Sq Mean Sq F value Pr(>F)
diftrace
.
: - ,
## rotation 1 1.205 1.2051 5.907 0.0229 * -

## lubricant 3 1.694 0.5647 2.768 0.0637 .


## rotation:lubricant 3 0.132 0.0441 0.216 0.8841
## Residuals 24 4.897 0.2040
one
way
## --- O
✓ er
~

## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 •

Xe
summary(aov(X2~rotation+lubricant+rotation*lubricant,data=ex6.6)) / for
##
## rotation
Df Sum Sq Mean Sq F value
1 614.3
Pr(>F)
614.3 20.019 0.000158 ***
- tot . tdfkrnm
##
##
lubricant 3
rotation:lubricant 3
74.9
32.2
25.0
10.7
0.813 0.499018
0.350 0.789277
:
~
rotation
## Residuals 24 736.4 30.7
## ---
o V -
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
M
.
n

ex6.6.manova<-manova(cbind(X1,X2)~rotation+lubricant+rotation*lubricant,data = e
\ x6.6) - -

summary(ex6.6.manova,test=c("Wilks"))

##
## rotation
Df Wilks approx F num Df den Df
1 0.47396 12.7636 2 23
Pr(>F)
0.0001867 ***
→ dfhn
## lubricant 3 0.69158 1.5524 6 46 0.1827862
## rotation:lubricant 3 0.93193 0.2751 6 46 0.9458304
## Residuals 24
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(ex6.6.manova,test=c("Pillai"))
-

## Df Pillai approx F num Df den Df Pr(>F)


## rotation 1 0.52604 12.7636 2 23 0.0001867 ***
## lubricant 3 0.31410 1.4905 6 48 0.2015936
## rotation:lubricant 3 0.06853 0.2838 6 48 0.9418287
## Residuals 24
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

summary(ex6.6.manova,test=c("Roy")) → only used


,
⇒ less
sigif.lt
## Df Roy approx F num Df den Df Pr(>F) ist - bin
## rotation 1 1.10988 12.7636 2 23 0.0001867 ***
## lubricant 3 0.41810 3.3448 3 24 0.0359080 *
## rotation:lubricant 3 0.06505 0.5204 3 24 0.6722819
## Residuals 24
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

summary(ex6.6.manova,test=c("Hotelling")) → -
se des & dz
## Df Hotelling-Lawley approx F num Df den Df Pr(>F)
## rotation 1 1.10988 12.7636 2 23 0.0001867 ***
## lubricant 3 0.43775 1.6051 6 44 0.1684454
## rotation:lubricant 3 0.07256 0.2660 6 44 0.9498087
## Residuals 24
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Example 6.7
Three groups of rabbits were injected with tuberculosis bacteria to obtain relevant data on
the growth of tuberculosis bacteria according to their physical condition.
– Three groups
G1: control group
G2:New Vaccination function degradation group
G3: Metabolic active group
– variables
X1: TB cirrhosis number

ß
PS
X2: TB size.
-
o

ex6.7<-read.csv("./data/Example6-7.csv") g-
]

§ ]
head(ex6.7)

## group X1 X2
µ JU
## 1 G1 24.0 3.5
§
## 2 G1 13.0 3.5 - -

Ms
Nsu
## 3 G1 12.2 4.0
=

Ho
Ms
## 4 G1 14.0 4.0
## 5 G1 22.2 3.6 : .

agil
!
"
## 6 G1 16.1 4.3
" t Hihi "

:
.
## one-way ANOVA
## X1
X1.anova<-aov(X1~group,data = ex6.7)
summary(X1.anova)

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


## group 2 1828 914.2 13.04 0.000437 ***
## Residuals 16 1122 70.1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

TukeyHSD(X1.anova)

## Tukey multiple comparisons of means


## 95% family-wise confidence level
##
## Fit: aov(formula = X1 ~ group, data = ex6.7)
##
## $group
##
##
diff lwr upr p adj
G2-G1 -9.728571 -21.27627 1.819123 0.1065031 93891
##
##
G3-G1 15.294286 2.64442 27.944151 0.0171551
G3-G2 25.022857 12.37299 37.672723 0.0002960 35
& § d. Heut


⑤ ⑤
## X2
X2.anova<-aov(X2~group,data = ex6.7)
summary(X2.anova)

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


## group 2 10.039 5.020 11.99 0.000658 ***
## Residuals 16 6.698 0.419
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

TukeyHSD(X2.anova)

## Tukey multiple comparisons of means


## 95% family-wise confidence level
##
## Fit: aov(formula = X2 ~ group, data = ex6.7)
##
## $group
##
##
##
diff lwr upr p adj
G2-G1 -1.3714286 -2.263798 -0.4790591 0.0030071
G3-G1 -1.6542857 -2.631827 -0.6767440 0.0013155 3 d. Ahnt

## G3-G2 -0.2828571 -1.260399 0.6946846 0.7399202

## groupwise mean vector and covariance matrix


colMeans(ex6.7[ex6.7$group=="G1",-1])

}
## X1 X2
## 18.485714 4.014286

var(ex6.7[ex6.7$group=="G1",-1])

## X1 X2
## X1 38.041429 1.5135714
## X2 1.513571 0.3647619

Er
colMeans(ex6.7[ex6.7$group=="G2",-1])

## X1 X2
## 8.757143 2.642857

var(ex6.7[ex6.7$group=="G2",-1])

## X1 X2
## X1 7.2795238 0.9321429
## X2 0.9321429 0.4761905

93
}
colMeans(ex6.7[ex6.7$group=="G3",-1])

## X1 X2
## 33.78 2.36

var(ex6.7[ex6.7$group=="G3",-1])
## X1 X2

-0
## X1 212.412 -9.001 ; -
stand of ni - L - -
it
µ
## X2 -9.001 0.413 groß
library(ggplot2)
ggplot(ex6.7,aes(X1,X2,color=group))+geom_text(aes(label=group))

↳ ⇒

s .
5h53
.
-

~ c -
go.rs
\
Me - or -

## one-way MANOVA
fit<-manova(cbind(X1,X2)~group,data = ex6.7)
summary(fit,test="Wilks")

## Df Wilks approx F num Df den Df Pr(>F)


## group 2 0.1495 11.897 4 30 6.582e-06 ***
## Residuals 16
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

summary(fit,test="Pillai")

## Df Pillai approx F num Df den Df Pr(>F)


## group 2 1.2259 12.668 4 32 2.744e-06 ***
## Residuals 16
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

summary(fit,test="Roy")

## Df Roy approx F num Df den Df Pr(>F)


## group 2 1.7098 13.679 2 16 0.0003439 ***
## Residuals 16
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

summary(fit,test="Hotelling")

## Df Hotelling-Lawley approx F num Df den Df Pr(>F)


## group 2 3.1783 11.124 4 28 1.577e-05 ***
## Residuals 16
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Ho :
M .
=
MEN ]

t Ho
Hi
'

n .

Ho

=3 reject

You might also like