out_type <- knitr::opts_knit$get("rmarkdown.pandoc.to") r = getOption("repos") r["CRAN"] = "https://cran.rstudio.com/" #r["CRAN"] = "https://cloud.r-project.org/" #r["CRAN"] = "https://ftp.iitm.ac.in/cran/" options(repos = r)
switch(out_type, html = {cat("<p>1. Professor of the Academic Department of Statistics and Informatics of the Faculty of Economics and Planning.National University Agraria La Molina-PERU.</p> <p>2. Department of Mathematics and Statistics, University of Agriculture Faisalabad, Pakistan.</p>")}, latex = cat(" 1. Professor of the Academic Department of Statistics and Informatics of the Faculty of Economics and Planning.National University Agraria La Molina-PERU. 2. Department of Mathematics and Statistics, University of Agriculture Faisalabad, Pakistan. " ) )
knitr::opts_chunk$set( echo = TRUE , comment = "" , fig.cap = "" ) library(agricolae)
\begin{center} \vspace{6pt} \hrule \end{center}
The package agricolae presents special functions for the creation of the field book for experimental designs. Due to the random generation, this package is quite used in agricultural research.
For this generation, certain parameters are required, as for example the name of each treatment, the number of repetitions, and others, according to the design [@CochCox:1992; @kueh:2000; @LeClLeonErwiWarrAndre:1962; @Mont:2002]. There are other parameters of random generation, as the seed to reproduce the same random generation or the generation method (See the reference manual of agricolae).
Important parameters in the generation of design:
| ---------|--------------------------------------------- series: | A constant that is used to set numerical tag blocks , eg number = 2, the labels will be : 101, 102, for the first row or block, 201, 202, for the following , in the case of completely randomized design, the numbering is sequencial. design: | Some features of the design requested agricolae be applied specifically to design.ab(factorial) or design.split (split plot) and their possible values are: "rcbd", "crd" and "lsd". seed: | The seed for the random generation and its value is any real value, if the value is zero, it has no reproducible generation, in this case copy of value of the outdesign\$parameters. kinds: | the random generation method, by default "Super-Duper". first: | For some designs is not required random the first repetition, especially in the block design, if you want to switch to random, change to TRUE. randomization: | TRUE or FALSE. If false, randomization is not performed
Output design:
| ---------|--------------------------------------------- parameters: | the input to generation design, include the seed to generation random, if seed=0, the program generate one value and it is possible reproduce the design. book: | field book statistics: | the information statistics the design for example efficiency index, number of treatments. sketch: | distribution of treatments in the field. The enumeration of the plots | zigzag is a function that allows you to place the numbering of the plots in the direction of serpentine: The zigzag is output generated by one design: blocks, Latin square, graeco, split plot, strip plot, into blocks factorial, balanced incomplete block, cyclic lattice, alpha and augmented blocks. fieldbook: | output zigzag, contain field book.
It generates completely a randomized design with equal or different repetition. "Random" uses the methods of number generation in R.The seed is by set.seed(seed, kinds)
. They only require the names of the treatments and the number of their repetitions and its parameters are:
str(design.crd)
trt <- c("A", "B", "C") repeticion <- c(4, 3, 4) outdesign <- design.crd(trt,r=repeticion,seed=777,serie=0) book1 <- outdesign$book head(book1)
Excel:write.csv(book1,"book1.csv",row.names=FALSE)
It generates field book and sketch to Randomized Complete Block Design. "Random" uses the methods of number generation in R.The seed is by set.seed(seed, kinds)
. They require the names of the treatments and the number of blocks and its parameters are:
str(design.rcbd)
trt <- c("A", "B", "C","D","E") repeticion <- 4 outdesign <- design.rcbd(trt,r=repeticion, seed=-513, serie=2) # book2 <- outdesign$book book2<- zigzag(outdesign) # zigzag numeration print(outdesign$sketch) print(matrix(book2[,1],byrow = TRUE, ncol = 5))
It generates Latin Square Design. "Random" uses the methods of number generation in R.The seed is by set.seed(seed, kinds)
. They require the names of the treatments and its parameters are:
str(design.lsd)
trt <- c("A", "B", "C", "D") outdesign <- design.lsd(trt, seed=543, serie=2) print(outdesign$sketch)
book <- zigzag(outdesign) print(matrix(book[,1],byrow = TRUE, ncol = 4))
A graeco-latin square is a $k \times k$ pattern that permits the study of $k$ treatments simultaneously with three different blocking variables, each at $k$ levels. The function is only for squares of the odd numbers and even numbers (4, 8, 10 and 12). They require the names of the treatments of each factor of study and its parameters are:
str(design.graeco)
trt1 <- c("A", "B", "C", "D") trt2 <- 1:4 outdesign <- design.graeco(trt1,trt2, seed=543, serie=2) print(outdesign$sketch)
book <- zigzag(outdesign) print(matrix(book[,1],byrow = TRUE, ncol = 4))
Such designs are referred to as Youden squares since they were introduced by Youden (1937) after Yates (1936) considered the special case of column equal to number treatment minus 1. "Random" uses the methods of number generation in R. The seed is by set.seed(seed, kinds)
. They require the names of the treatments of each factor of study and its parameters are:
str(design.youden)
varieties<-c("perricholi","yungay","maria bonita","tomasa") r<-3 outdesign <-design.youden(varieties,r,serie=2,seed=23) print(outdesign$sketch) book <- outdesign$book print(book) # field book. print(matrix(as.numeric(book[,1]),byrow = TRUE, ncol = r))
book <- zigzag(outdesign) print(matrix(as.numeric(book[,1]),byrow = TRUE, ncol = r))
Creates Randomized Balanced Incomplete Block Design. "Random" uses the methods of number generation in R. The seed is by set.seed(seed, kinds)
.
They require the names of the treatments and the size of the block and its parameters are:
str(design.bib)
trt <- c("A", "B", "C", "D", "E" ) k <- 4 outdesign <- design.bib(trt,k, seed=543, serie=2) book5 <- outdesign$book outdesign$statistics outdesign$parameters
According to the produced information, they are five blocks of size 4, being the matrix:
outdesign$sketch
It can be observed that the treatments have four repetitions. The parameter lambda has three repetitions, which means that a couple of treatments are together on three occasions. For example, B and E are found in the blocks I, II and V.
book <- zigzag(outdesign) matrix(book[,1],byrow = TRUE, ncol = 4)
They require the names of the treatments, the size of the block and the number of repetitions. This design is used for 6 to 30 treatments. The repetitions are a multiple of the size of the block; if they are six treatments and the size is 3, then the repetitions can be 6, 9, 12, etc. and its parameters are:
str(design.cyclic)
trt <- c("A", "B", "C", "D", "E", "F" ) outdesign <- design.cyclic(trt,k=3, r=6, seed=543, serie=2) book6 <- outdesign$book outdesign$sketch[[1]] outdesign$sketch[[2]]
12 blocks of 4 treatments each have been generated.
book <- zigzag(outdesign) array(book$plots,c(3,6,2))->X t(X[,,1]) t(X[,,2])
SIMPLE and TRIPLE lattice designs. It randomizes treatments in $k \times k$ lattice. They require a number of treatments of a perfect square; for example 9, 16, 25, 36, 49, etc. and its parameters are:
str(design.lattice)
They can generate a simple lattice (2 rep.) or a triple lattice (3 rep.) generating a triple lattice design for 9 treatments $3 \times 3$
trt<-letters[1:9] outdesign <-design.lattice(trt, r = 3, serie = 2, seed = 33, kinds = "Super-Duper") book7 <- outdesign$book outdesign$parameters outdesign$sketch head(book7)
book <- zigzag(outdesign) array(book$plots,c(3,3,3)) -> X t(X[,,1]) t(X[,,2]) t(X[,,3])
Generates an alpha designs starting from the alpha design fixing under the series formulated by Patterson and Williams. These designs are generated by the alpha arrangements. They are similar to the lattice designs, but the tables are rectangular $s$ by $k$ (with $s$ blocks and $k<s$ columns. The number of treatments should be equal to $s \times k$ and all the experimental units $r \times s \times k$ ($r$ replications) and its parameters are:
str(design.alpha)
trt <- letters[1:15] outdesign <- design.alpha(trt,k=3,r=2,seed=543) book8 <- outdesign$book outdesign$statistics outdesign$sketch # codification of the plots A<-array(book8[,1], c(3,5,2)) t(A[,,1]) t(A[,,2])
book <- zigzag(outdesign) A<-array(book[,1], c(3,5,2)) t(A[,,1]) t(A[,,2])
These are designs for two types of treatments: the control treatments (common) and the increased treatments. The common treatments are applied in complete randomized blocks, and the increased treatments, at random. Each treatment should be applied in any block once only. It is understood that the common treatments are of a greater interest; the standard error of the difference is much smaller than when between two increased ones in different blocks. The function design.dau()
achieves this purpose and its parameters are:
str(design.dau)
rm(list=ls()) trt1 <- c("A", "B", "C", "D") trt2 <- c("t","u","v","w","x","y","z") outdesign <- design.dau(trt1, trt2, r=5, seed=543, serie=2) book9 <- outdesign$book with(book9,by(trt, block,as.character))
book <- zigzag(outdesign) with(book,by(plots, block, as.character)) head(book)
For augmented ompletely randomized design, use the function design.crd().
These designs have two factors, one is applied in plots and is defined as trt1 in a randomized complete block design; and a second factor as trt2 , which is applied in the subplots of each plot applied at random. The function design.split() permits to find the experimental plan for this design and its parameters are:
str(design.split)
trt1<-c("A","B","C","D") trt2<-c("a","b","c") outdesign <-design.split(trt1,trt2,r=3,serie=2,seed=543) book10 <- outdesign$book head(book10) p<-book10$trt1[seq(1,36,3)] q<-NULL for(i in 1:12) q <- c(q,paste(book10$trt2[3*(i-1)+1],book10$trt2[3*(i-1)+2], book10$trt2[3*(i-1)+3]))
print(t(matrix(p,c(4,3))))
print(t(matrix(q,c(4,3))))
book <- zigzag(outdesign) head(book,5)
These designs are used when there are two types of treatments (factors) and are applied separately in large plots, called bands, in a vertical and horizontal direction of the block, obtaining the divided blocks. Each block constitutes a repetition and its parameters are:
str(design.strip)
trt1<-c("A","B","C","D") trt2<-c("a","b","c") outdesign <-design.strip(trt1,trt2,r=3,serie=2,seed=543) book11 <- outdesign$book head(book11) t3<-paste(book11$trt1, book11$trt2) B1<-t(matrix(t3[1:12],c(4,3))) B2<-t(matrix(t3[13:24],c(3,4))) B3<-t(matrix(t3[25:36],c(3,4))) print(B1) print(B2) print(B3)
book <- zigzag(outdesign) head(book) array(book$plots,c(3,4,3))->X t(X[,,1]) t(X[,,2]) t(X[,,3])
The full factorial of n factors applied to an experimental design (CRD, RCBD and LSD) is common and this procedure in agricolae applies the factorial to one of these three designs and its parameters are:
str(design.ab)
To generate the factorial, you need to create a vector of levels of each factor, the method automatically generates up to 25 factors and $r$ repetitions.
trt <- c (4,2,3) # three factors with 4,2 and 3 levels.
to crd and rcbd designs, it is necessary to value $r$ as the number of repetitions, this can be a vector if unequal to equal or constant repetition (recommended).
trt<-c(3,2) # factorial 3x2 outdesign <-design.ab(trt, r=3, serie=2) book12 <- outdesign$book head(book12) # print of the field book
book <- zigzag(outdesign) head(book)
factorial $2 \times 2 \times 2$ with 5 replications in completely randomized design.
trt<-c(2,2,2) crd<-design.ab(trt, r=5, serie=2,design="crd") names(crd) crd$parameters head(crd$book)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.