Learn R Programming

DoE.base (version 0.6-1)

formula.design: Function to change the default formula for a data frame of class design to involve the correct factors with the desired effects and responses

Description

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.

Usage

## S3 method for class 'design':
formula(x, ..., response=NULL, degree=NULL)

Arguments

x
an object of class design
...
further arguments to function formula
response
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 desi
degree
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, ...

Value

  • a formula

Details

Function link[stats]{formula} creates an appropriate formula for mny kinds of objects, e.g. for data frames (try e.g. formula(swiss)). Function link[stats]{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, as function link[stats]{lm} simply forces its first argument to be a formula via as.formula. 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 designs with types starting with FrF2 (blocked designs receive special treatment, with blocks entering without any interactions)} {will be 2 for response surface designs and lhs designs} {will be the model formula used in optimizing the design for optimal designs}

See Also

See also formula

Examples

Run this code
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