This function provides a reasonable default formula for linear model analyses of class design objects with response(s). Per default, the resulting formula refers to the first response in the design and is of design-type specific nature.
# S3 method for design
formula(x, ..., response=NULL, degree=NULL, FUN=NULL, 
      use.center=NULL, use.star=NULL, use.dummies=FALSE)a formula
an object of class design
further arguments to function formula
character string giving the name of the response variable 
          (must be among the numeric columns from x) 
          OR
          integer number giving the position of the response in element 
          response.names of attribute design.info
degree of the model (1=main effects only, 2=with 2-factor interactions and quadratic effects, 3=with 3-factor interactions and up to cubic effects, ...
function for the aggregate.design method; 
        this must be an unquoted function name or NULL;
        This option is relevant for repeated measurement designs 
        and parameter designs in long format only
NULL or logical indicating whether center points are to be used +
        in the analysis; 
        if NULL, the default is FALSE for pb and FrF2 designs with 
        center points and TRUE for ccd designs; the option is irrelevant 
        for all other design types.
NULL or logical indicating whether the star portion of a CCD design 
        is to be used in the analysis (ignored for all other types of designs).
logical indicating whether the error dummies of a Plackett Burman design are to be used in the formula (ignored for all other types of designs).
Ulrike Groemping
Function formula creates an appropriate formula for many kinds of 
objects, e.g. for data frames (try e.g. formula(swiss)). Function 
as.formula uses function formula, but cannot take any additional 
arguments.
The method for class design objects modifies the way a data frame 
would normally be treated by the formula function. This also carries through 
to default linear models.
Without the additional arguments, the function creates the formula with the first 
response from the response.names element of the design.info attribute. 
The default degree depends on the type of design: it is
1 for oa and pb
2 for all other design types
degree does not have an effect for response surface designs 
  (types bbd, bbd.blocked and ccd) and latin hypercube designs (type lhs), 
  where the function always creates the formula for a full second order model including quadratic 
  effects.
Where degree does have an effect, it is the exponent of the sum of all experimental factors, 
i.e. it refers to the degree of interactions, not to powers of the variables themselves 
(e.g. (A+B+C)^2 for degree 2).
For designs with a block variable (types FrF2.blocked, bbd.blocked and ccd) 
the block variable enters the formula as a main effect factor without any interactions.
For 2-level designs with center points (types FrF2.center or pb.center), 
the formula contains an indicator variable center for the center points 
that can is used for checking whether quadratic effects are needed.
For designs with repeated measurements (repeat.only and parameter designs, 
the default is to analyse aggregated responses. For more detail, 
see the documentation of lm.design.
For optimal designs, the formula is the model formula used in optimizing the design.
See also formula and lm.design
  ## indirect usage via function lm.design is much more interesting
  ## cf help for lm design!
   my.L18 <- oa.design(ID=L18, 
       factor.names = c("one","two","three","four","five","six","seven"), 
       nlevels=c(3,3,3,2,3,3,3))
   y <- rnorm(18)
   my.L18 <- add.response(my.L18, y)
   formula(my.L18)
   lm(my.L18)
Run the code above in your browser using DataLab