library(FrF2)
## Warning: package 'FrF2' was built under R version 4.1.2
## Loading required package: DoE.base
## Loading required package: grid
## Loading required package: conf.design
## Registered S3 method overwritten by 'DoE.base':
##   method           from       
##   factorize.factor conf.design
## 
## Attaching package: 'DoE.base'
## The following objects are masked from 'package:stats':
## 
##     aov, lm
## The following object is masked from 'package:graphics':
## 
##     plot.design
## The following object is masked from 'package:base':
## 
##     lengths
response <- c(7.037,16.867,13.876,17.273,11.846,4.368,9.36,15.653)
des.resp<-FrF2(nfactors=4,resolution=3,randomize=FALSE)
des.resp<-add.response(des.resp,response)
des.resp
##    A  B  C  D response
## 1 -1 -1 -1 -1    7.037
## 2  1 -1 -1  1   16.867
## 3 -1  1 -1  1   13.876
## 4  1  1 -1 -1   17.273
## 5 -1 -1  1  1   11.846
## 6  1 -1  1 -1    4.368
## 7 -1  1  1 -1    9.360
## 8  1  1  1  1   15.653
## class=design, type= FrF2
DanielPlot(des.resp,half=TRUE)

MEPlot(des.resp,show.alias=TRUE)### it looks like factor D has large effect on response.

design<-FrF2(nfactors=6,resolution=5,randomize=FALSE,blocks=2,nruns=16)
## Warning in FrF2(nfactors = 6, resolution = 5, randomize = FALSE, blocks = 2, :
## resolution is ignored, if nruns is given.
summary(design)### all the block1 is -1 and block2 is 1 , as two factor effect AB is confounded with the blocks.
## Call:
## FrF2(nfactors = 6, resolution = 5, randomize = FALSE, blocks = 2, 
##     nruns = 16)
## 
## Experimental design of type  FrF2.blocked 
## 16  runs
## blocked design with  2  blocks of size  8 
## 
## Factor settings (scale ends):
##    A  B  C  D  E  F
## 1 -1 -1 -1 -1 -1 -1
## 2  1  1  1  1  1  1
## 
## Design generating information:
## $legend
## [1] A=A B=B C=C D=D E=E F=F
## 
## $`generators for design itself`
## [1] E=ABC F=ABD
## 
## $`block generators`
## [1] ACD
## 
## 
## Alias structure:
## $fi2
## [1] AB=CE=DF AC=BE    AD=BF    AE=BC    AF=BD    CD=EF    CF=DE   
## 
## Aliased with block main effects:
## [1] none
## 
## The design itself:
##   run.no run.no.std.rp Blocks  A  B  C  D  E  F
## 1      1         1.1.1      1 -1 -1 -1 -1 -1 -1
## 2      2         4.1.2      1 -1 -1  1  1  1  1
## 3      3         5.1.3      1 -1  1 -1 -1  1  1
## 4      4         8.1.4      1 -1  1  1  1 -1 -1
## 5      5        10.1.5      1  1 -1 -1  1  1 -1
## 6      6        11.1.6      1  1 -1  1 -1 -1  1
## 7      7        14.1.7      1  1  1 -1  1 -1  1
## 8      8        15.1.8      1  1  1  1 -1  1 -1
##    run.no run.no.std.rp Blocks  A  B  C  D  E  F
## 9       9         2.2.1      2 -1 -1 -1  1 -1  1
## 10     10         3.2.2      2 -1 -1  1 -1  1 -1
## 11     11         6.2.3      2 -1  1 -1  1  1 -1
## 12     12         7.2.4      2 -1  1  1 -1 -1  1
## 13     13         9.2.5      2  1 -1 -1 -1  1  1
## 14     14        12.2.6      2  1 -1  1  1 -1 -1
## 15     15        13.2.7      2  1  1 -1 -1 -1 -1
## 16     16        16.2.8      2  1  1  1  1  1  1
## class=design, type= FrF2.blocked 
## NOTE: columns run.no and run.no.std.rp  are annotation, 
##  not part of the data frame
design<-FrF2(nfactors=7,resolution=3,randomize=FALSE,blocks=4,nruns=32)
## Warning in FrF2(nfactors = 7, resolution = 3, randomize = FALSE, blocks = 4, :
## resolution is ignored, if nruns is given.
summary(design)### it does not  confounding with any two factor interactions.
## Call:
## FrF2(nfactors = 7, resolution = 3, randomize = FALSE, blocks = 4, 
##     nruns = 32)
## 
## Experimental design of type  FrF2.blocked 
## 32  runs
## blocked design with  4  blocks of size  8 
## 
## Factor settings (scale ends):
##    A  B  C  D  E  F  G
## 1 -1 -1 -1 -1 -1 -1 -1
## 2  1  1  1  1  1  1  1
## 
## Design generating information:
## $legend
## [1] A=A B=B C=C D=D E=E F=F G=G
## 
## $`generators for design itself`
## [1] F=ABC G=ABD
## 
## $`block generators`
## [1] ACD ABE
## 
## 
## Alias structure:
## $fi2
## [1] AB=CF=DG AC=BF    AD=BG    AF=BC    AG=BD    CD=FG    CG=DF   
## 
## Aliased with block main effects:
## [1] none
## 
## The design itself:
##   run.no run.no.std.rp Blocks  A  B  C  D  E  F  G
## 1      1         1.1.1      1 -1 -1 -1 -1 -1 -1 -1
## 2      2         7.1.2      1 -1 -1  1  1 -1  1  1
## 3      3        10.1.3      1 -1  1 -1 -1  1  1  1
## 4      4        16.1.4      1 -1  1  1  1  1 -1 -1
## 5      5        20.1.5      1  1 -1 -1  1  1  1 -1
## 6      6        22.1.6      1  1 -1  1 -1  1 -1  1
## 7      7        27.1.7      1  1  1 -1  1 -1 -1  1
## 8      8        29.1.8      1  1  1  1 -1 -1  1 -1
##    run.no run.no.std.rp Blocks  A  B  C  D  E  F  G
## 9       9         2.2.1      2 -1 -1 -1 -1  1 -1 -1
## 10     10         8.2.2      2 -1 -1  1  1  1  1  1
## 11     11         9.2.3      2 -1  1 -1 -1 -1  1  1
## 12     12        15.2.4      2 -1  1  1  1 -1 -1 -1
## 13     13        19.2.5      2  1 -1 -1  1 -1  1 -1
## 14     14        21.2.6      2  1 -1  1 -1 -1 -1  1
## 15     15        28.2.7      2  1  1 -1  1  1 -1  1
## 16     16        30.2.8      2  1  1  1 -1  1  1 -1
##    run.no run.no.std.rp Blocks  A  B  C  D  E  F  G
## 17     17         3.3.1      3 -1 -1 -1  1 -1 -1  1
## 18     18         5.3.2      3 -1 -1  1 -1 -1  1 -1
## 19     19        12.3.3      3 -1  1 -1  1  1  1 -1
## 20     20        14.3.4      3 -1  1  1 -1  1 -1  1
## 21     21        18.3.5      3  1 -1 -1 -1  1  1  1
## 22     22        24.3.6      3  1 -1  1  1  1 -1 -1
## 23     23        25.3.7      3  1  1 -1 -1 -1 -1 -1
## 24     24        31.3.8      3  1  1  1  1 -1  1  1
##    run.no run.no.std.rp Blocks  A  B  C  D  E  F  G
## 25     25         4.4.1      4 -1 -1 -1  1  1 -1  1
## 26     26         6.4.2      4 -1 -1  1 -1  1  1 -1
## 27     27        11.4.3      4 -1  1 -1  1 -1  1 -1
## 28     28        13.4.4      4 -1  1  1 -1 -1 -1  1
## 29     29        17.4.5      4  1 -1 -1 -1 -1  1  1
## 30     30        23.4.6      4  1 -1  1  1 -1 -1 -1
## 31     31        26.4.7      4  1  1 -1 -1  1 -1 -1
## 32     32        32.4.8      4  1  1  1  1  1  1  1
## class=design, type= FrF2.blocked 
## NOTE: columns run.no and run.no.std.rp  are annotation, 
##  not part of the data frame
desi <- FrF2(nfactors = 6,nruns = 16,generators = c("ABC","ACD"), randomize = FALSE)
desi
##     A  B  C  D  E  F
## 1  -1 -1 -1 -1 -1 -1
## 2   1 -1 -1 -1  1  1
## 3  -1  1 -1 -1  1 -1
## 4   1  1 -1 -1 -1  1
## 5  -1 -1  1 -1  1  1
## 6   1 -1  1 -1 -1 -1
## 7  -1  1  1 -1 -1  1
## 8   1  1  1 -1  1 -1
## 9  -1 -1 -1  1 -1  1
## 10  1 -1 -1  1  1 -1
## 11 -1  1 -1  1  1  1
## 12  1  1 -1  1 -1 -1
## 13 -1 -1  1  1  1 -1
## 14  1 -1  1  1 -1  1
## 15 -1  1  1  1 -1 -1
## 16  1  1  1  1  1  1
## class=design, type= FrF2.generators
summary(desi)### a) 1/4 fraction of 2^6 design is used, in which there are 2^4 equals to 16 runs are present.
## Call:
## FrF2(nfactors = 6, nruns = 16, generators = c("ABC", "ACD"), 
##     randomize = FALSE)
## 
## Experimental design of type  FrF2.generators 
## 16  runs
## 
## Factor settings (scale ends):
##    A  B  C  D  E  F
## 1 -1 -1 -1 -1 -1 -1
## 2  1  1  1  1  1  1
## 
## Design generating information:
## $legend
## [1] A=A B=B C=C D=D E=E F=F
## 
## $generators
## [1] E=ABC F=ACD
## 
## 
## Alias structure:
## $fi2
## [1] AB=CE    AC=BE=DF AD=CF    AE=BC    AF=CD    BD=EF    BF=DE   
## 
## 
## The design itself:
##     A  B  C  D  E  F
## 1  -1 -1 -1 -1 -1 -1
## 2   1 -1 -1 -1  1  1
## 3  -1  1 -1 -1  1 -1
## 4   1  1 -1 -1 -1  1
## 5  -1 -1  1 -1  1  1
## 6   1 -1  1 -1 -1 -1
## 7  -1  1  1 -1 -1  1
## 8   1  1  1 -1  1 -1
## 9  -1 -1 -1  1 -1  1
## 10  1 -1 -1  1  1 -1
## 11 -1  1 -1  1  1  1
## 12  1  1 -1  1 -1 -1
## 13 -1 -1  1  1  1 -1
## 14  1 -1  1  1 -1  1
## 15 -1  1  1  1 -1 -1
## 16  1  1  1  1  1  1
## class=design, type= FrF2.generators
### b)
aliasprint(desi)
## $legend
## [1] A=A B=B C=C D=D E=E F=F
## 
## $main
## character(0)
## 
## $fi2
## [1] AB=CE    AC=BE=DF AD=CF    AE=BC    AF=CD    BD=EF    BF=DE
### c) 
res <- c(0.0167,0.0062,0.0041,0.0073,0.0047,0.0219,0.0121,0.0255,0.0032,0.0078,0.0043,0.0186,0.0110,0.0065,0.0155,0.0093,0.0128,0.0066,0.0043,0.0081,0.0047,0.0258,0.0090,0.0250,0.0023,0.0158,0.0027,0.0137,0.0086,0.0109,0.0158,0.0124,0.0149,0.0044,0.0042,0.0039,0.0040,0.0147,0.0092,0.0226,0.0077,0.0060,0.0028,0.0158,0.0101,0.0126,0.0145,0.0110,0.0185,0.0020,0.0050,0.0030,0.0089,0.0296,0.0086,0.0169,0.0069,0.0045,0.0028,0.0159,0.0158,0.0071,0.0145,0.0133)
A <- rep(desi$A,4)
B <- rep(desi$B,4)
C <- rep(desi$C,4)
D <- rep(desi$D,4)
E <- rep(desi$E,4)
F <- rep(desi$F,4)
model <- aov(res~A*B*C*D*E*F)
summary(model)### Process Variables A,C,E,F affect average camber
##             Df    Sum Sq   Mean Sq F value   Pr(>F)    
## A            1 0.0002422 0.0002422  27.793 3.17e-06 ***
## B            1 0.0000053 0.0000053   0.614  0.43725    
## C            1 0.0005023 0.0005023  57.644 9.14e-10 ***
## D            1 0.0000323 0.0000323   3.712  0.05995 .  
## E            1 0.0001901 0.0001901  21.815 2.45e-05 ***
## F            1 0.0009602 0.0009602 110.192 5.05e-14 ***
## A:B          1 0.0000587 0.0000587   6.738  0.01249 *  
## A:C          1 0.0000803 0.0000803   9.218  0.00387 ** 
## B:C          1 0.0000527 0.0000527   6.053  0.01754 *  
## A:D          1 0.0000239 0.0000239   2.741  0.10431    
## B:D          1 0.0000849 0.0000849   9.739  0.00305 ** 
## C:D          1 0.0000622 0.0000622   7.139  0.01027 *  
## D:E          1 0.0000088 0.0000088   1.007  0.32062    
## A:B:D        1 0.0000000 0.0000000   0.005  0.94291    
## B:C:D        1 0.0000481 0.0000481   5.523  0.02293 *  
## Residuals   48 0.0004183 0.0000087                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
### d)
sd <- c(24.418,20.976,4.083,25.025,22.410,63.639,16.029,39.42,26.725,50.341,7.681,20.083,31.12,29.51,6.75,17.45)
exp <- aov(sd~A*B*C*D*E*F,data = desi)
halfnormal(exp,ME.partial = TRUE)### process variables A and B affect the variability in camber measurements.
## 
## The following effects are completely aliased:
##  [1] A:E         B:E         C:E         A:F         B:F         C:F        
##  [7] D:F         E:F         A:B:C       A:C:D       A:B:E       A:C:E      
## [13] B:C:E       A:D:E       B:D:E       C:D:E       A:B:F       A:C:F      
## [19] B:C:F       A:D:F       B:D:F       C:D:F       A:E:F       B:E:F      
## [25] C:E:F       D:E:F       A:B:C:D     A:B:C:E     A:B:D:E     A:C:D:E    
## [31] B:C:D:E     A:B:C:F     A:B:D:F     A:C:D:F     B:C:D:F     A:B:E:F    
## [37] A:C:E:F     B:C:E:F     A:D:E:F     B:D:E:F     C:D:E:F     A:B:C:D:E  
## [43] A:B:C:D:F   A:B:C:E:F   A:B:D:E:F   A:C:D:E:F   B:C:D:E:F   A:B:C:D:E:F
## 
## Significant effects (alpha=0.05, Lenth method):
## [1] B1 A1

###e)
MEPlot(aov(res~A*B*C*D*E*F),show.alias=TRUE)

### A is big,B is big,C is small,D is small,E is small,F is big.
#a) 4
#b) 4
#c)A,B,C,D=1,-0.5,-0.5,5
#D)ABCD
#(a) the generator IS -ABC
#(b)the generator IS BC 
#(c)4
desig<-FrF2(nfactors=7,resolution=3,randomize=FALSE)
fold.design(desig, columns = 1)
##     A  B  C     fold  D  E  F  G
## 1  -1 -1 -1 original  1  1  1 -1
## 2   1 -1 -1 original -1 -1  1  1
## 3  -1  1 -1 original -1  1 -1  1
## 4   1  1 -1 original  1 -1 -1 -1
## 5  -1 -1  1 original  1 -1 -1  1
## 6   1 -1  1 original -1  1 -1 -1
## 7  -1  1  1 original -1 -1  1 -1
## 8   1  1  1 original  1  1  1  1
## 9   1 -1 -1   mirror  1  1  1 -1
## 10 -1 -1 -1   mirror -1 -1  1  1
## 11  1  1 -1   mirror -1  1 -1  1
## 12 -1  1 -1   mirror  1 -1 -1 -1
## 13  1 -1  1   mirror  1 -1 -1  1
## 14 -1 -1  1   mirror -1  1 -1 -1
## 15  1  1  1   mirror -1 -1  1 -1
## 16 -1  1  1   mirror  1  1  1  1
## class=design, type= FrF2.folded
design.info(desig)$aliased$main
## [1] "A=BD=CE=FG" "B=AD=CF=EG" "C=AE=BF=DG" "D=AB=CG=EF" "E=AC=BG=DF"
## [6] "F=AG=BC=DE" "G=AF=BE=CD"