**Software for Exploratory Data Analysis and Statistical Modelling**, and kindly contributed to R-bloggers)

When designing an experiment it is not always possible to generate a regular, balanced design such as a full or fractional factorial design plan. There are usually restrictions of the total number of experiments that can be undertaken or constraints on the factor settings both individually or in combination with each other.

In these scenarios computer generated designs, the optimal designs of a given size, can be identified from a list of candidate factor combinations. The library **AlgDesign** in **R** has facilities for optimal design searches based on the Federov exchange algorithm. An optimality criterion has to be selected by the investigator, currently **D**, **A** or **I**, and this criterion is minimise by searching for an optimal subset of a given size from the candidate design list.

Given the total number of treatment runs for an experiment and a specified model, the computer algorithm chooses the optimal set of design runs from a candidate set of possible design treatment runs. This candidate set of treatment runs usually consists of all possible combinations of various factor levels that one wishes to use in the experiment.

First stage, as always, is to make the package available for use:

library(AlgDesign)

For illustrative purposes consider a four factor experiment, where the factors have 4, 3, 2, and 2 levels each respectively. Using the **expand.grid** function we can create a data frame of all possible combinations of the factor settings:

cand.list = expand.grid(Factor1 = c("A", "B", "C", "D"), Factor2 = c("I", "II", "III"), Factor3 = c("Low", "High"), Factor4 = c("Yes", "No"))

The random number seed is set so that the algorithm can run:

set.seed(69)

The function **optFederov** *calculates an exact or approximate algorithmic design for one of three criteria, using Federov’s exchange algorithm*. The first argument to the function is a formula for the intended model for the data and the **data** argument specifies the list of candidate points:

optFederov( ~ ., data = cand.list, nTrials = 13)

In this example all of the factors in the candidate list appear in the model with a linear term. Quadratic or cubic terms can be included in this formula. The argument **nTrials** specifies the number of design points to select from the candidate list. The output from this function is:

$D [1] 0.226687 $A [1] 7.022811 $Ge [1] 0.718 $Dea [1] 0.676 $design Factor1 Factor2 Factor3 Factor4 3 C I Low Yes 6 B II Low Yes 12 D III Low Yes 16 D I High Yes 19 C II High Yes 21 A III High Yes 25 A I Low No 26 B I Low No 29 A II Low No 35 C III Low No 39 C I High No 44 D II High No 46 B III High No $rows [1] 3 6 12 16 19 21 25 26 29 35 39 44 46

This provides details of the values of the optimality criteria for the design points selected from the candidate list, the row numbers and the levels for the factors for the chosen design points.

**leave a comment**for the author, please follow the link and comment on their blog:

**Software for Exploratory Data Analysis and Statistical Modelling**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...