Learn R Programming

blocksdesign (version 3.2)

design: General block and treatment designs.

Description

Constructs D-optimal block and treatment designs for feasible combinations of nested or crossed block factors and feasible linear treatment models.

Usage

design(treatments, blocks = NULL, treatments_model = NULL,
  fix_treatments = TRUE, weighting = 0.5, searches = NULL,
  seed = NULL, jumps = 1)

Arguments

treatments

a single treatment factor or a data frame containing one or more qualitative or quantitative (numeric) level treatment factors.

blocks

a single block factor or a data frame containing one or more qualitative level block factors in the required order of fitting.

treatments_model

a model formula for the required treatments design where the default formula assumes a fully crossed factorial treatment model.

fix_treatments

logical TRUE (default) indicates that the full candidate set is the required treatment set whereas logical FALSE indicates that the required treatment set is obtained by sampling with replacement. Only applicable when treatments and blocks are of equal length.

weighting

a weighting factor between 0 and 1 for weighting the second-order interaction effects of crossed blocks designs where the default weighting is 0.5

searches

the maximum number of local optima searched at each stage of an optimization. The default depends on the design size.

seed

an integer initializing the random number generator. The null default gives an arbitrary random initialization.

jumps

the number of pairwise random treatment swaps used to escape a local maxima. The default is a single swap.

Value

treatments

The treatments included in the design and the replication of each individual treatment

design

The design layout showing the allocation of treatment and block design factors to individual plots.

treatments_model

The fractional size of the treatment design together with the D-efficiency of that fraction.

blocks_model

The blocks sub-model design together with the D-efficiency factor of each successively fitted blocks sub-model.

seed

Numerical seed for random number generator.

searches

Maximum number of searches in each stratum.

jumps

Number of random treatment swaps to escape a local maxima.

Details

The treatments object is a factor or a data frame containing one or more qualitative or quantitative level factors and is the candidate set from which the final treatment design is selected.

The blocks object is a factor or a data frame containing one or more qualitative level block factors where the length of the factors defines the overall size of the required design. The blocks object must be defined even when it is just a single factor with a single factor level.

The blocks object size divided by the treatments object size is the fractional size of the required treatments design. If the fractional treatment design size is nonunity, the treatments design is always chosen from the candidate set by sampling with replacement. If the fractional treatment design size is unity, the method of choosing the treatment design can be determined by the fix_treatments parameter where TRUE (the default) means that the whole candidate set is used while FALSE means that the treatment set is chosen by sampling with replacement.

The design criterion is the ratio of the generalized variance of the full treatment candidate set relative to the generalized variance of the optimized treatment set for the required treatment design (D-optimality). If the required design is a fractional factorial and the candidate set is a full factorial, the candidate set will be orthogonal and any design selected from the candidate set will have a relative efficiency less than or equal to 1. For a quantitative level treatment model, however, a full factorial design may not provide an optimal design and, in that case, the relative efficiency of the optimized design may well exceed 1.

For unstructured treatment designs, the A-efficiency factor is also shown together with an estimated A-efficiency upper-bound, where available.

The design algorithm fits the blocks design by sequentially adding blocks factors in the column order of the blocks data frame. Each block factor is optimized conditional on all preceding block factors remaining fixed but ignoring all succeeding block factors. This method of sequential optimization allows the blocking factors to be fitted in order of importance with the largest and most important blocks fitted first and the smaller and less important blocks fitted subsequently.

For crossed blocks designs, the algorithm applies a differential weighting w to determine the relative importance of the blocks main effects versus the blocks interaction effects. If w = 0 the algorithm fits a simple additive main effects design whereas if w = 1 the algorithm fits a fully crossed blocks design. For intermediate 0 < w < 1, the block factor interaction effects are downweighted relative to the main effects where the smaller the value of w, the greater the downweighting. The default weighting is 0.5 and provided that all block effects are estimable, this weighting will give a design where main block effects are assumed to be of greater importance than block interaction effects.

For example, a design for 4 replicates of 12 treatments arranged in 4 main rows and 4 main columns with 3 sub-columns nested within each main column (see examples) is known to have an optimal Trojan solution with orthogonal main rows, orthogonal main columns and nested sub-columns with A-efficiency 22/31. The default weighting of 0.5 will find an optimal Trojan design whereas a weighting of w = 0 will find an optimal main column blocks design with sub-optimal sub-column blocks while a weighting of w = 1 will find an optimal sub-column blocks design with sub-optimal main column blocks.

Trojan designs are rare and normally it will not be possible to optimise a design for main rows, main columns and rows-by-columns interaction effects simultaneously. In that situation, a suitable choice of weighting parameter can help to find a good compromise design that will give good efficiency on the main effects of rows and columns and on the interaction effects of rows and columns simultaneously.

Outputs:

The principle design outputs comprise:

  • A data frame showing the replication of each individual treatment taken in a standard order.

  • A data frame showing the randomized allocation of treatments to blocks.

  • A table showing the fractional size of the treatment design and the D-efficiency factor of that fraction.

  • A table showing the blocks sub-model design and the D-efficiency factor of each successively fitted blocks sub-model.

References

Cochran W. G. & Cox G. M. (1957) Experimental Designs 2nd Edition John Wiley & Sons.

DURBAN, M., HACKETT, C., MCNICOL, J., NEWTON, A., THOMAS, W., & CURRIE, I. (2003). The practical use of semi-parametric models in field trials, Journal of Agric. Biological and Envir. Stats., 8, 48-66.

Examples

Run this code
# NOT RUN {
## For optimum results, the number of searches may need to be increased in practice.

## 4 replicates of 12 treatments with 16 nested blocks of size 3
# rectangular lattice see Plan 10.10 Cochran and Cox 1957.
treatments = factor(rep(1:12,4))
blocks = data.frame(Main = gl(4,12), Sub = gl(16,3))
design(treatments,blocks)$blocks_model

## 4 x 12 design for 4 replicates of 12 treatments with 16 nested column blocks of size 3
## only an intermediate weighting will ensure an optimal Trojan design 
treatments = factor(rep(1:12,4))
blocks = data.frame(Rows = gl(4,12), Cols = gl(4,3,48), subCols = gl(12,1,48))
# }
# NOT RUN {
design(treatments,blocks,searches=200)$blocks_model
# }
# NOT RUN {
## 4 x 13 Row-and-column design for 4 replicates of 13 treatments 
## Youden design Plan 13.5 Cochran and Cox (1957).
treatments = factor(rep(1:13,4))
blocks = data.frame(Rows = gl(4,13), Cols = gl(13,1,52))
# }
# NOT RUN {
design(treatments,blocks,searches = 700)
# }
# NOT RUN {
## Durban - 272 treatments in a 16 x 34 design with nested rows-and-columns
data(durban) 
durban=durban[c(3,1,2,4,5)]
durban=durban[ do.call(order, durban), ]
treatments=data.frame(gen=durban$gen)
Reps = factor(rep(1:2,each=272))
Rows = factor(rep(1:16,each=34))
Col1 = factor(rep(rep(1:4,c(9,8,8,9)),16))
Col2 = factor(rep(rep(1:8,c(5,4,4,4,4,4,4,5)),16))
Col3 = factor(rep(1:34,16))
blocks = data.frame(Reps,Rows,Col1,Col2,Col3)
# }
# NOT RUN {
design(treatments,blocks,searches=1)$blocks_model
## Finds post-blocked efficiency factors of original design; Durban et al (2003)
blockEfficiencies(treatments,blocks)
# }
# NOT RUN {
## differential replication 
treatments=factor(c(rep(1:12,2), rep(13,12)))
blocks = data.frame(Main = gl(2,18),  Sub = gl(12,3,36))
design(treatments,blocks,searches = 5)

## 48 treatments in 2 replicate blocks of size 48 for a 24 x 4 array 
## with 2 main rows and 3 main columns the cols factor must precede 
## the rows factor otherwise the design will confound one treatment contrast
## in the replicates.rows x columns interactions due to inherent aliasing 
treatments=factor(rep(1:48,2))
blocks = data.frame(Reps = gl(2,48),Cols = gl(3,8,96),Rows = gl(2,24,96))
design(treatments,blocks,searches=5)

## Factorial treatment designs defined by a factorial model equation.

## Main effects of five 2-level factors in a half-fraction of 
## a 2/2/2 nested blocks design
treatments = expand.grid(F1 = factor(1:2), F2 = factor(1:2), F3 = factor(1:2), 
F4 = factor(1:2), F5 = factor(1:2))
blocks = data.frame(b1 = gl(2,8),b2 = gl(4,4),b3 = gl(8,2))
model="F1 + F2 + F3 + F4 + F5"
# }
# NOT RUN {
 repeat {
 z = design(treatments,blocks,treatments_model=model,searches=5)
 if ( z$blocks_model[3,3] == 1) break }
 print(z)
# }
# NOT RUN {
# Second-order model for five qualitative 2-level factors in 4 randomized blocks
treatments = expand.grid(F1 = factor(1:2), F2 = factor(1:2), F3 = factor(1:2), 
F4 = factor(1:2), F5 = factor(1:2))
blocks = data.frame(blocks = gl(4,8))
model = "(F1 + F2 + F3 + F4 + F5)^2"
design(treatments,blocks,treatments_model=model,searches = 10)

# Main effects of five 2-level factors in a half-fraction of 
# a 4 x 4 row-and column design.
treatments = expand.grid(F1 = factor(1:2), F2 = factor(1:2), F3 = factor(1:2), 
F4 = factor(1:2), F5 = factor(1:2))
blocks = data.frame(rows = gl(4,4), cols = gl(4,1,16))
model = "~ F1 + F2 + F3 + F4 + F5"
design(treatments,blocks,treatments_model=model,searches = 50)

# Quadratic regression for three 3-level numeric factor assuming a 10/27 fraction
treatments = expand.grid(A = 1:3, B = 1:3, C = 1:3)
blocks=data.frame(main=gl(1,10))
model = " ~ ( A + B + C)^2 + I(A^2) + I(B^2) + I(C^2)"
design(treatments,blocks,treatments_model=model,searches=5) 

# First-order model for 1/3rd fraction of four qualitative 3-level factors in 3  blocks
treatments = expand.grid(F1 = factor(1:3), F2 = factor(1:3), F3 = factor(1:3), 
F4 = factor(1:3))
blocks = data.frame(main = gl(3,9))
model = " ~ F1 + F2 + F3 + F4"
design(treatments,blocks,treatments_model=model,searches=25)

# Second-order model for a 1/3rd fraction of five qualitative 3-level factors in 3 blocks
treatments = expand.grid(F1 = factor(1:3), F2 = factor(1:3), F3 = factor(1:3), 
F4 = factor(1:3), F5 = factor(1:3))
blocks=data.frame(main=gl(3,27))
model = " ~ (F1 + F2 + F3 + F4 + F5)^2"
# }
# NOT RUN {
design(treatments,blocks,treatments_model=model,searches=500)
# }
# NOT RUN {
# Second-order model for two qualitative and two quantitative level factors in 4 blocks
treatments = expand.grid(F1 = factor(1:2), F2 = factor(1:3), V1 = 1:3, V2 = 1:4)
blocks = data.frame(main = gl(4,18))
model = " ~ F1 + F2 + poly(V1,2) + poly(V2,2) + (poly(V1,1) + F1 + F2):(poly(V2,1) + F1 + F2)"
# }
# NOT RUN {
design(treatments,blocks,treatments_model=model,searches=5)
# }
# NOT RUN {
 
# Plackett and Burman design for eleven 2-level factors in 12 runs 
GF = expand.grid(F1 = factor(1:2,labels=c("a","b")), F2 = factor(1:2,labels=c("a","b")), 
                 F3 = factor(1:2,labels=c("a","b")), F4 = factor(1:2,labels=c("a","b")),
                 F5 = factor(1:2,labels=c("a","b")), F6 = factor(1:2,labels=c("a","b")),
                 F7 = factor(1:2,labels=c("a","b")), F8 = factor(1:2,labels=c("a","b")), 
                 F9 = factor(1:2,labels=c("a","b")), F10= factor(1:2,labels=c("a","b")), 
                 F11= factor(1:2,labels=c("a","b")) )
blocks=data.frame(main=gl(1,12))
model = "~ F1 + F2 + F3 + F4 + F5 + F6 + F7 + F8 + F9 + F10 + F11"
# }
# NOT RUN {
design(GF,blocks,treatments_model=model,searches=25)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab