Title: | Construction of Crossover Designs |
---|---|
Description: | Contains functions for the construction of carryover balanced crossover designs. In addition contains functions to check given designs for balance. |
Authors: | Martin Oliver Sailer |
Maintainer: | Bjoern Bornkamp <[email protected]> |
License: | GPL-2 |
Version: | 1.1-2 |
Built: | 2024-11-01 04:54:06 UTC |
Source: | https://github.com/cran/crossdes |
The crossdes package provides functions for the construction of of carryover balanced crossover designs. In addition contains functions to check given designs for balance.
Package: | crossdes |
Type: | Package |
Version: | 1.1-1 |
Date: | 2013-03-18 |
License: | GPL-2 |
The main functions are:get.plan
: Menu-driven selection of crossover designsallcombs
: Construct crossover design with all possible
treatment orderswilliams
: Construct a Williams designwilliams.BIB
: Construct a crossover design based on a
combination of balanced incomplete block designs and Williams designs.des.MOLS
: Construct crossover design based on mutually
orthogonal Latin Squaresbalmin.RMD
: Construct balanced minimal repeated
measurements crossover designisCbalanced
: Check whether a crossover design is balanced
for first order carryover effectsisGYD
: Check whether a crossover design is balanced
Martin Oliver Sailer
Earlier version of the package:
Sailer, O. (2005): crossdes: A package for design and randomization in crossover studies. Rnews 5/2, 24-27.
Overview on cross-over designs:
Jones, B. and Kenward, M.G. (1989): Design and Analysis of Cross-Over Trials. Chapman and Hall, London.
Wakeling, I.N. and MacFie, H.J.H. (1995): Designing consumer trials balanced for first and higher orders of carry-over effect when only a subset of k samples from t may be tested. Food Quality and Preference 6, 299-308.
The function constructs a row-column design with subjects as rows and periods as columns. Each subject gets each treatment at most once. All possible treatment orders are assigned to the subjects.
allcombs(trt, k)
allcombs(trt, k)
trt |
An integer > 1. Number of treatments (products) to be tested. |
k |
An integer |
The design is a carryover balanced generalized Youden design that is uniform on the columns.
The treatments are numbered 1,...,. The entry
of the design corresponds to the treatment the
-th subject gets in the
-th period.
A matrix with rows and
columns representing the experimental design.
Requires the package gtools
.
Oliver Sailer
Patterson, H.D. (1952): The construction of balanced designs for experiments involving sequences of treatments. Biometrika 39, 32-48.
Wakeling, I.N. and MacFie, H.J.H. (1995): Designing consumer trials balanced for first and higher orders of carry-over effect when only a subset of k samples from t may be tested. Food Quality and Preference 6, 299-308.
# Design for 4 treatments assigned in 3 periods. # All possible treatment orders occur. allcombs(4,3)
# Design for 4 treatments assigned in 3 periods. # All possible treatment orders occur. allcombs(4,3)
The function constructs a row-column design with subjects as rows and periods as columns. The design is incomplete, i.e. no subject gets all the treatments. The design is balanced for carryover effects but will in general not be a balanced block design.
balmin.RMD(trt, n, p)
balmin.RMD(trt, n, p)
trt |
An integer >1 giving the number of treatments (products) to be tested. |
n |
An integer >1 giving the number of subjects (assessors) in the study. |
p |
An integer >1 giving the number of periods for each subject. |
A necessary and sufficient condition for the existence of such a design is
that be a positive integer.
In this case
.
In the resulting design the treatments are numbered 1,...,
.
The entry
of the design corresponds to the treatment the
-th subject gets in the
-th period.
A matrix with rows and
columns representing the experimental design.
Oliver Sailer
Afsarinejad, K. (1983): Balanced repeated measurements designs. Biometrika 70, 199-204.
Wakeling, I.N. and MacFie, H.J.H. (1995): Designing consumer trials balanced for first and higher orders of carry-over effect when only a subset of k samples from t may be tested. Food Quality and Preference 6, 299-308.
balmin.RMD(10,30,4) # a balanced minimal RMD balmin.RMD(11,22,6) # another balanced minimal RMD
balmin.RMD(10,30,4) # a balanced minimal RMD balmin.RMD(11,22,6) # another balanced minimal RMD
The design is a balanced incomplete block design with rows as blocks. If one assumes that there is a preperiod, i.e. that each assessor is given the treatment of the fifth period before the experiment starts, then the design is carryover balanced.
data(biertest.d4)
data(biertest.d4)
A matrix with 12 rows corresponding to the assessors, 5 columns corresponding to the five periods.
The five treatments (products) to be tested are numbered 1,...,5.
Kunert, J. (1998): Sensory experiments as crossover studies. Food Quality and Preference 9, 243-253 (design d4).
data(biertest.d4)
data(biertest.d4)
The data comes from a beer testing experiment where assessors had to rate the bitterness of five beers.
data(biertest.dat)
data(biertest.dat)
A matrix with 12 rows corresponding to the assessors, 5 columns corresponding to the five periods.
The possible values for the ratings lie in the interval [0, 12]. Note that the data were reordered after the experiment.
Kunert, J. (1998): Sensory experiments as crossover studies. Food Quality and Preference 9, 243-253 (table 1).
data(biertest.dat)
data(biertest.dat)
The design is a row-column design. It is actually a generalized latin square design that is also carryover balanced.
data(biertest.d4)
data(biertest.d4)
A matrix with 10 rows corresponding to the first 10 assessors in a fictional uniformity trial, 5 columns corresponding to the five periods.
There are five products to be tested, numbered 1,...,5.
Kunert, J. (1998): Sensory experiments as crossover studies. Food Quality and Preference 9, 243-253 (design f2).
data(biertest.f2)
data(biertest.f2)
The function constructs row-column designs based on complete sets of mutually orthogonal latin squares. Each subject may get each tratment at most once. The design is a generalized Youden design that is also balanced for carryover effects.
des.MOLS(trt, k = trt)
des.MOLS(trt, k = trt)
trt |
A prime power less than 100. The number of treatments (products) to be tested. |
k |
An integer |
A complete set of mutually orthogonal latin squares is constructed using Galois Fields.
The rows of the designs represent the treatment
orders for the subjects. If an incomplete design with columns is needed,
only the first
columns of the designs are
considered.
The treatments are numbered 1,...,
. The entry
of the design corresponds to the treatment the
-th subject gets in the
-th period.
A matrix with rows and
columns representing the experimental design.
Oliver Sailer
Wakeling, I.N. and MacFie, H.J.H. (1995): Designing consumer trials balanced for first and higher orders of carry-over effect when only a subset of k samples from t may be tested. Food Quality and Preference 6, 299-308.
Williams, E. J. (1949): Experimental designs balanced for the estimation of residual effects of treatments. Australian Journal of Scientific Research, Ser. A 2, 149-168.
des.MOLS(7,7) des.MOLS(8,5)
des.MOLS(7,7) des.MOLS(8,5)
The function optBlock
of the library AlgDesign
is used to search for balanced incomplete block designs
(BIBDs). The design is assigned to a matrix where rows represent blocks (subjects) and
columns represent periods.
find.BIB(trt, b, k, iter = 30)
find.BIB(trt, b, k, iter = 30)
trt |
An integer > 1 giving the number of treatments of the design. |
b |
An integer > 1 giving the number of rows (subjects) of the design. |
k |
An integer > 1 giving the number of columns (periods) of the design. |
iter |
The number of iterations of the function |
The function optBlock
tries to find a D-optimal block design for the specified parameters.
The resulting design need not be a BIBD.
The necessary conditions for the existence are that and
positive integers.
They are NOT checked automatically.
Even if they are fulfilled, there need not be a BIBD.
If no BIBD is found, the function is iterated.
If no BIBD is found after
iter
iterations, the search is terminated.
The resulting design should be checked by the user applying isGYD
.
A matrix that represents the experimental design.
As indicated above, the returned design is not necessarily a BIBD design.
Oliver Sailer
Wheeler, R.E. (2004). optBlock. AlgDesign. The R project for statistical computing http://www.r-project.org/
find.BIB(10,30,4) # BIBD find.BIB(3,3,3) # BIBD find.BIB(5,5,3, 100) # There is no BIBD for these parameters # isGYD(find.BIB(5,5,3, 100))
find.BIB(10,30,4) # BIBD find.BIB(3,3,3) # BIBD find.BIB(5,5,3, 100) # There is no BIBD for these parameters # isGYD(find.BIB(5,5,3, 100))
This menu based function constructs simple experimental designs for repeated measurements with one or two block variables. It is assumed that each subject is assigned to each treatment at most once. A maximum number of subjects in the study is also requested. Five possible construction methods available. These construction methods and the characteristics of the resulting designs are described in Wakeling and MacFie (1995). See also Jones and Kenward (1989), Ch. 5, for a discussion of these designs. The function is demonstrated in more detail in Sailer (2005).
get.plan(trt, k = trt, maxsub = 1000)
get.plan(trt, k = trt, maxsub = 1000)
trt |
An integer > 1, giving the number of treatments. |
k |
An integer in {2,..., |
maxsub |
The maximum number of subjects available. |
The five types of designs are: designs based on all possible treatment orders ("all.combin"),
Williams designs ("williams"), designs based on
mutually orthogonal latin squares ("des.MOLS"), a combination of balanced incomplete block designs (BIBDs) and Williams designs
("williams.BIB") by Patterson (1951) and
the balanced minimal designs of Afsarinejad ("balmin.RMD").
Some designs are only available for special combinations of treatment number and number of periods. Other designs
may require too many subjects. Therefore, the possible choices available for the submitted values of ,
and
are determined.
If there is no design available, the parameters may be changed interactively.
If more than one design type is available the user has to choose one. The minimum number of subjects required
for the designs is given and maybe a criterion for selecting a design. All types of designs are balanced for first-order carryover effects.
All types except the balanced minimal RMDs are also balanced block designs.
The user may want to construct a design for a multiple of the minimum number of subjects required to get closer
to the preferred number of subjects.
Once the design is chosen the design is displayed. In practice the
labels for the treatments and subjects should be randomized before the
design is used.
The treatments are numbered 1,...,
. The entry
of the design corresponds to the treatment the
-th subject gets in the
-th period.
A matrix representing the experimental design.
For the construction of designs that combine BIBDs with Williams designs, the function find.BIB
is called
to search for a BIBD. If the necessary conditions for the existence of a BIBD are fulfilled, this approach
always returns a design. This design will however not always be a BIBD!
When using the Patterson approach, please check the resulting design for balance using isGYD
and
isCbalanced
.
It should be noted that this is a computational problem only, not a problem of the theoretical approach of Patterson (1951).
The "All combinations" approach requires the package gtools
.
Oliver Sailer
Afsarinejad, K. (1983): Balanced repeated measurements designs. Biometrika 70, 199-204.
Jones, B. and Kenward, M.G. (1989): Design and Analysis of Cross-Over Trials. Chapman and Hall, London.
Patterson, H.D. (1951): Change-over trials. Journal of the Royal Statistical Society B 13, 256-271.
Patterson, H.D. (1952): The construction of balanced designs for experiments involving sequences of treatments. Biometrika 39, 32-48.
Sailer, O. (2005): crossdes: A package for design and randomization in crossover studies. Rnews 5, 24-27.
Wakeling, I.N. and MacFie, H.J.H. (1995): Designing consumer trials balanced for first and higher orders of carry-over effect when only a subset of k samples from t may be tested. Food Quality and Preference 6, 299-308.
Williams, E. J. (1949): Experimental designs balanced for the estimation of residual effects of treatments. Australian Journal of Scientific Research, Ser. A 2, 149-168.
allcombs
, balmin.RMD
, des.MOLS
,
williams
, williams.BIB
## Not run: get.plan(10,4,60) # "williams.BIB" or "balmin.RMD" get.plan(7,7,7000) # "all.combin", "williams" or "des.MOLS", "williams" requires # only 14 subjects, "all.combin" requires 5040. get.plan(5,5,5) # Increase maxsub ## End(Not run)
## Not run: get.plan(10,4,60) # "williams.BIB" or "balmin.RMD" get.plan(7,7,7000) # "all.combin", "williams" or "des.MOLS", "williams" requires # only 14 subjects, "all.combin" requires 5040. get.plan(5,5,5) # Increase maxsub ## End(Not run)
The function checks whether a block design is balanced for first order carryover effects (residual effects). The user specifies whether there is a preperiod. The design is checked and the left neighbour incidence matrix is given.
isCbalanced(d, preperiod = FALSE)
isCbalanced(d, preperiod = FALSE)
d |
A matrix with entries 1,..., |
preperiod |
Logical flag. TRUE if there is a preperiod. In this case, each subject experiences in the first period the residual effect of the treatment of the last period (i.e. the last period preceeds the first period, i.e. the plots in the last period are left neighbours of the plots in the first period). FALSE if there are no residual effects in the first period. |
The design is said to be carryover balanced (balanced for first order carryover effects), if each treatment is preceeded by all other treatments equally often and if no treatment is preceeded by itself. If the design is balanced, this is stated.
1 |
Logical flag. TRUE if the design is carryover balanced. This is not displayed on the screen. |
2 |
Left neighbour incidence matrix. The |
Oliver Sailer
d1 <- matrix( c(1,2,3,4,1,1,1,1), 4,2) d2 <- matrix( c(1:4,2:4,1,4,1:3,3,4,1,2),ncol=4) d3 <- matrix( rep(1:3,each=2), ncol=2) isCbalanced(d1) isCbalanced(d1,TRUE) isCbalanced(d2) isCbalanced(d3,TRUE)
d1 <- matrix( c(1,2,3,4,1,1,1,1), 4,2) d2 <- matrix( c(1:4,2:4,1,4,1:3,3,4,1,2),ncol=4) d3 <- matrix( rep(1:3,each=2), ncol=2) isCbalanced(d1) isCbalanced(d1,TRUE) isCbalanced(d2) isCbalanced(d3,TRUE)
A function to check a simple block or a row-column design for balance. The rows and columns of the design are blocking variables. It is checked which type of balance the design fulfills. Optionally, incidence and concurrence matrices are given.
isGYD(d, tables=FALSE, type=TRUE)
isGYD(d, tables=FALSE, type=TRUE)
d |
A matrix representing the experimental design. The treatments must be numbered 1,..., |
tables |
Logical flag. If TRUE, incidence matrices are displayed. |
type |
Logical flag. If TRUE, the type of design is displayed. |
A design is said to be a balanced block design if the following three conditions hold:
i) Each treatment appears equally often in the design.
ii) The design is binary in the sense that each treatment appears in each block either or
+1 times
where
is an integer.
iii) The number of concurrences of treatments
and
is the same for all
pairs of distinct treatments
.
Here the blocks are either rows or columns.
A design that has less columns (rows) than treatments is said to be incomplete with respect to rows (columns). A design that is balanced with respect to both rows and columns is called a generalized Youden design (GYD). A GYD for which each treatment occurs equally often in each row (column) is called uniform on the rows (columns). If both conditions hold, it is called a generalized latin square. A design where each treatment occurs exactly once in each row and column is called a latin square.
A list containing information about balance in rows and columns as well as incidence and concurrence matrices for the design.
Oliver Sailer
d1 <- matrix( c(1,2,3,4,1,1,1,1), 4,2) # d1 is not balanced d2 <- matrix( c(1:4,2:4,1,4,1:3,3,4,1,2),ncol=4) # d2 is a latin square d3 <- matrix( rep(1:3,each=2), ncol=2) # d3 is a balanced incomplete block design. d1 isGYD(d1,tables=TRUE) d2 isGYD(d2,tables=TRUE) d3 isGYD(d3,tables=TRUE)
d1 <- matrix( c(1,2,3,4,1,1,1,1), 4,2) # d1 is not balanced d2 <- matrix( c(1:4,2:4,1,4,1:3,3,4,1,2),ncol=4) # d2 is a latin square d3 <- matrix( rep(1:3,each=2), ncol=2) # d3 is a balanced incomplete block design. d1 isGYD(d1,tables=TRUE) d2 isGYD(d2,tables=TRUE) d3 isGYD(d3,tables=TRUE)
The function constructs sets of mutually othogonal latin squares (MOLS) using Galois fields. The construction works for prime powers only.
MOLS(p, n, primpol = GF(p, n)[[2]][1, ])
MOLS(p, n, primpol = GF(p, n)[[2]][1, ])
p |
A prime number less than 100. |
n |
A positive integer. |
primpol |
A primitive polynomial of the Galois Field GF( |
If is a prime power, then
-1 latin squares of order
are constructed.
The elements of the squares are numbered 1,...,
.
These squares are mutually orthogonal, i.e. if any two of them are superimposed, the resulting
array will contain each ordered pair
,
,
in {1,...,
} exactly once.
The squares are in standard order, i.e. the first row is always equal to (1,...,
).
A primitive polynomial may be constructed automatically using the internal function
GF
.
For , an array that contains
-1 latin squares is returned.
Oliver Sailer
Cherowitzo, W.: http://www-math.cudenver.edu/~wcherowi/courses/finflds.html
Street, A.P. and Street, D.J. (1987): Combinatorics of experimental design. Oxford University Press, Oxford.
MOLS(7,1) # 6 mutually orthogonal latin squares of order 7 MOLS(2,3) # 7 mutually orthogonal latin squares of order 8
MOLS(7,1) # 6 mutually orthogonal latin squares of order 7 MOLS(2,3) # 7 mutually orthogonal latin squares of order 8
The function constructs williams designs. Williams designs are row-column designs. They are used if each of the treatments in the study is given to each of the subjects. If the number of treatments to be tested is even, the design is a latin square, otherwise it consists of two latin squares.
williams(trt)
williams(trt)
trt |
An integer > 1, giving the number of treatments in the design. |
The resulting design is a (generalized) latin square that is also balanced for first order carryover effects.
Carryover balance is achieved with very few subjects.
In the experimental design the treatments are numbered 1,...,. The entry
of the design corresponds
to the treatment the
-th subject gets in the
-th period.
A matrix representing the experimental design.
Oliver Sailer
Wakeling, I.N. and MacFie, H.J.H. (1995): Designing consumer trials balanced for first and higher orders of carry-over effect when only a subset of k samples from t may be tested. Food Quality and Preference 6, 299-308.
Williams, E. J. (1949): Experimental designs balanced for the estimation of residual effects of treatments. Australian Journal of Scientific Research, Ser. A 2, 149-168.
williams(3) williams(10)
williams(3) williams(10)
Patterson (1951) combined balanced incomplete block designs (BIBDs) with Williams designs to get carryover balanced generalized Youden designs.
williams.BIB(d)
williams.BIB(d)
d |
A matrix representing a BIBD. Rows represent blocks (subjects). |
For each row of the design, a Williams design is constructed using the treatments of that row.
The rows of the resulting designs are then combined.
The treatments are numbered 1,...,. The entry
of the design corresponds to the treatment the
-th subject gets in the
-th period.
A matrix representing the experimental design.
The resultig design is only balanced properly if the input design actually is a BIBD.
This is NOT checked automatically. You have to do this by yourself, e.g. by applying isGYD
to your design.
BIBDs may be generated using find.BIB
.
Oliver Sailer
Patterson, H.D. (1951): Change-over trials. Journal of the Royal Statistical Society B 13, 256-271.
Wakeling, I.N. and MacFie, H.J.H. (1995): Designing consumer trials balanced for first and higher orders of carry-over effect when only a subset of k samples from t may be tested. Food Quality and Preference 6, 299-308.
get.plan
, isGYD
, find.BIB
, williams
d <- matrix( rep(1:3,each=2), ncol=2) # # check for balance # isGYD(d) williams.BIB(d)
d <- matrix( rep(1:3,each=2), ncol=2) # # check for balance # isGYD(d) williams.BIB(d)