library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
# data
Response = c(0.445,0.624,0.360,0.493,0.513,0.693,0.534,0.675,0.578,0.786,0.622,0.755,0.814,0.902,0.869,0.902)
C <- factor(rep(c("1","2"), each = 8))
A <- factor(rep(c("1","2"), each = 4, times = 2))
L <- factor(rep(c("1","2"), each = 2, times = 4))
M <- factor(rep(c("1","2"), times = 8))
temp <- cbind(C,A,L,M,Response) %>% as.matrix()
temp
##       C A L M Response
##  [1,] 1 1 1 1    0.445
##  [2,] 1 1 1 2    0.624
##  [3,] 1 1 2 1    0.360
##  [4,] 1 1 2 2    0.493
##  [5,] 1 2 1 1    0.513
##  [6,] 1 2 1 2    0.693
##  [7,] 1 2 2 1    0.534
##  [8,] 1 2 2 2    0.675
##  [9,] 2 1 1 1    0.578
## [10,] 2 1 1 2    0.786
## [11,] 2 1 2 1    0.622
## [12,] 2 1 2 2    0.755
## [13,] 2 2 1 1    0.814
## [14,] 2 2 1 2    0.902
## [15,] 2 2 2 1    0.869
## [16,] 2 2 2 2    0.902
# Anova table
lm.result1 <- lm(Response ~ C*A*L*M-C:A:L:M)
anova(lm.result1)
## Analysis of Variance Table
## 
## Response: Response
##           Df   Sum Sq  Mean Sq    F value   Pr(>F)   
## C          1 0.223493 0.223493 21159.0592 0.004376 **
## A          1 0.095945 0.095945  9083.5562 0.006679 **
## L          1 0.001314 0.001314   124.4083 0.056924 . 
## M          1 0.074939 0.074939  7094.8225 0.007558 **
## C:A        1 0.004001 0.004001   378.7515 0.032683 * 
## C:L        1 0.004935 0.004935   467.2249 0.029431 * 
## A:L        1 0.004258 0.004258   403.0828 0.031683 * 
## C:M        1 0.001828 0.001828   173.0237 0.048305 * 
## A:M        1 0.002783 0.002783   263.4379 0.039174 * 
## L:M        1 0.002889 0.002889   273.5207 0.038446 * 
## C:A:L      1 0.001958 0.001958   185.3787 0.046674 * 
## C:A:M      1 0.003278 0.003278   310.3018 0.036101 * 
## C:L:M      1 0.000127 0.000127    11.9822 0.179038   
## A:L:M      1 0.000046 0.000046     4.3136 0.285666   
## Residuals  1 0.000011 0.000011                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# delete non-significant factor
#Anova table
lm.result2 <- lm(Response~C*A*L*M-C:A:L:M-C:L:M-A:L:M)
anova(lm.result2)
## Analysis of Variance Table
## 
## Response: Response
##           Df   Sum Sq  Mean Sq  F value    Pr(>F)    
## C          1 0.223493 0.223493 3670.080 9.909e-06 ***
## A          1 0.095945 0.095945 1575.560 3.518e-05 ***
## L          1 0.001314 0.001314   21.579  0.018808 *  
## M          1 0.074939 0.074939 1230.611 5.094e-05 ***
## C:A        1 0.004001 0.004001   65.695  0.003925 ** 
## C:L        1 0.004935 0.004935   81.041  0.002894 ** 
## A:L        1 0.004258 0.004258   69.915  0.003587 ** 
## C:M        1 0.001828 0.001828   30.011  0.011961 *  
## A:M        1 0.002783 0.002783   45.694  0.006614 ** 
## L:M        1 0.002889 0.002889   47.443  0.006269 ** 
## C:A:L      1 0.001958 0.001958   32.154  0.010864 *  
## C:A:M      1 0.003278 0.003278   53.822  0.005233 ** 
## Residuals  3 0.000183 0.000061                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lm.result2$coefficients
## (Intercept)          C2          A2          L2          M2       C2:A2 
##   0.4430625   0.1402500   0.0662500  -0.0811250   0.1828750   0.1647500 
##       C2:L2       A2:L2       C2:M2       A2:M2       L2:M2    C2:A2:L2 
##   0.1145000   0.1095000   0.0145000   0.0045000  -0.0537500  -0.0885000 
##    C2:A2:M2 
##  -0.1145000