tinggi <- c(25,28,26,27, 20,22,21,23, 30,32,31,29,
            30,32,31,33, 25,27,26,28, 35,37,36,34,
            28,30,29,31, 23,25,24,26, 33,35,34,32)
pupuk <- factor(rep(c("Organik","Anorganik","Campuran"), each=12))
tanah <- factor(rep(rep(c("Lempung","Pasir","Humus"), each=4), 3))
m1 <- aov(tinggi ~ pupuk * tanah)
summary(m1)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## pupuk        2    152   76.00    45.6 2.20e-09 ***
## tanah        2    488  244.00   146.4 3.22e-15 ***
## pupuk:tanah  4      0    0.00     0.0        1    
## Residuals   27     45    1.67                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction.plot(tanah, pupuk, tinggi, type="b",
                  col=c("red","blue"))

pend <- c(3,4,3.5,4.5,3.8, 6,7,6.5,7.5,6.8, 10,12,11,13,11.5)
puas <- c(6,7,6.5,7,6.8, 8,9,8.5,9,8.8, 9,10,9.5,10,9.8)
metode <- factor(rep(c("SMA","S1","S2"), each=5))
Y <- cbind(pend,puas)

model_manova <- manova(Y ~ metode)
summary(model_manova, test="Wilks")
##           Df     Wilks approx F num Df den Df   Pr(>F)    
## metode     2 0.0080673   55.735      4     22 3.38e-11 ***
## Residuals 12                                              
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qf(0.95, 4, 22)
## [1] 2.816708
summary.aov(model_manova)
##  Response pend :
##             Df  Sum Sq Mean Sq F value    Pr(>F)    
## metode       2 152.292  76.146  121.77 1.072e-08 ***
## Residuals   12   7.504   0.625                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Response puas :
##             Df Sum Sq Mean Sq F value    Pr(>F)    
## metode       2 23.333  11.667  65.543 3.479e-07 ***
## Residuals   12  2.136   0.178                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(heplots)
## Warning: package 'heplots' was built under R version 4.5.3
boxM(Y, metode)
## 
##  Box's M-test for Homogeneity of Covariance Matrices 
## 
## data:  Y by metode 
## Chi-Sq (approx.) = 7.1899, df = 6, p-value = 0.3036