| lm and aov method for class design objects {DoE.base} | R Documentation | 
lm and aov methods for class design objects
Description
Methods for automatic linear models for data frames of class design
Usage
lm(formula, ...)
## Default S3 method:
lm(formula, data, subset, weights, na.action, method = "qr", 
    model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, 
    contrasts = NULL, offset, ...)
## S3 method for class 'design'
lm(formula, ..., response=NULL, degree=NULL, FUN=mean, 
    use.center=NULL, use.star=NULL, use.dummies=FALSE)
aov(formula, ...)
## Default S3 method:
aov(formula, data = NULL, projections = FALSE, qr = TRUE,
    contrasts = NULL, ...)
## S3 method for class 'design'
aov(formula, ..., response=NULL, degree=NULL, FUN=mean, 
    use.center=FALSE)
## S3 method for class 'lm.design'
print(x, ...)
## S3 method for class 'lm.design'
summary(object, ...)
## S3 method for class 'lm.design'
coef(object, ...)
## S3 method for class 'summary.lm.design'
print(x, ...)
## S3 method for class 'aov.design'
print(x, ...)
## S3 method for class 'aov.design'
summary(object, ...)
## S3 method for class 'summary.aov.design'
print(x, ...)
lm.design
summary.lm.design
aov.design
summary.aov.design
Arguments
| formula |  for the default method, cf. documentation for  | 
| ... |  further arguments to functions  | 
| response |  character string giving the name of the response variable 
(must be among the responses of  For the default  | 
| degree |  degree for the formula; if  | 
| FUN |  function for the  | 
| use.center | 
 | 
| use.star | 
 | 
| use.dummies | 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). | 
| projections | logical indicating whether the projections should be returned; for orthogonal arrays, these are helpful, as they provide the estimated deviation from the overall average attributed to each particular factor; it is not recommended to use them with unbalanced designs | 
| x |  object of class  | 
| object |  object of class  | 
| lm.design | a class that is identical in content to class  | 
| summary.lm.design | a class that is identical in content to class  | 
| data |  like in  | 
| subset |  like in  | 
| weights |  like in  | 
| na.action |  like in  | 
| method |  like in  | 
| model |  like in  | 
| y |  like in  | 
| qr |  like in  | 
| singular.ok |  like in  | 
| contrasts |  like in  | 
| offset |  like in  | 
Details
The aov and lm methods for class design 
conduct a default linear model analysis for data frames of 
class design that do contain at least one response.
The intention for providing default analyses is to support convenient quick inspections. In many cases, there will be good reasons to customize the analysis, for example by including some but not all effects of a certain degree. Also, it may be statistically more wise to work with mixed models for some types of design. The default analyses must not be taken as a statistical recommendation!
The choice of default analyses 
has been governed by simplicity: It uses fixed effects only and does either 
main effects models (degree=1, default for pb and oa designs), 
models with main effects and 2-factor interactions (degree=2, 
default for most designs) or second order models (that contain 
quadratic effects in addition to the 2-factor interactions, unchangeable default 
for designs with quantitative variables). The degree parameter can be used 
to modify the degree of interactions. If blocks are 
present, the block main effect is always entered as a fixed effect without interactions. 
Designs with center points are per default analysed without the center points; the main 
reason for this is convenient usage of functions DanielPlot, 
MEPlot and IAPlot from package FrF2. 
With the use.center option, this default can be changed; in this case, significance 
of the center point indicator implies that there are one or more quadratic effect(s) 
in the model.
Designs with repeated measurements (repeat.only=TRUE) and parameter 
designs of long format are treated by aggregate.design 
with aggregation function FUN (default: means are calculated) 
before applying a linear model.
For designs with repeated measurements (repeat.only=TRUE) and parameter 
designs of wide format, the default is to use the first aggregated response, 
if the design has been aggregated already. For a so far unaggregated design, 
the default is to treat the design by aggregate.design, 
using the function FUN (default: mean) and then use the first response. 
The defaults can be overridden by specifying response: Here, 
response can not only be one of the current responses but also a column name 
of the responselist element of the design.info attribute of the 
design (i.e. a response name from the long version of the design).
The implementation of the formulae is not done in functions lm.design or 
aov.design themselves 
but based on the method for function formula (formula.design).
The print methods prepend the formula and the number of experimental runs 
underlying the analysis to the default printout. 
The purpose of this is meaningful output in case a call from 
inside function lm.design or aov.design 
(methods for functions lm and aov ) 
does not reveal enough information, and another pointer that center points have been 
omitted or repeated measurements aggregated over. The coef method for objects 
of class lm.design suppresses NA coefficients, i.e. 
returns valid coefficients only. For aov objects, this is the default 
anyway.
Value
The value for the lm functions is a linear model object, 
exactly like for function lm, 
except for the added class lm.design in case of the method for class design, 
and an added list element WholePlotEffects for split plot designs.
The value for the aov functions is an aov object, 
exactly like for function aov, 
and an added list element WholePlotEffects for split plot designs.
The value of the summary functions for class lm.design and 
aov.design respectively
is a linear model or aov summary, exactly like documented in summary.lm 
or summary.aov, 
except for the added classes summary.lm.design or summary.aov.design, 
and an added list element WholePlotEffects (for summary.lm.design) 
or attribute (for summary.aov.design) for split plot designs.
The print functions return NULL; they are used for their side effects only.
Warning
 The generics for lm and aov replace the functions 
from package stats. For normal use, this is not an issue, because their 
default methods are exactly the functions from package stats.
 
However, when programming on the language (or when using a package that relies on 
such constructs), you may see unexpected results. 
For example, match.call(lm) returns a different result, depending on 
whether or not package DoE.base is loaded. This can be avoided by 
explicitly requesting e.g. match.call(stats::lm), which always works 
in the same way.
Please report any additional issues that you may experience.
Note
The package is currently subject to intensive development; most key functionality is now included. Some changes to input and output structures may still occur.
Author(s)
Ulrike Groemping
See Also
 See also the information on class design 
and its formula method formula.design 
Examples
  oa12 <- oa.design(nlevels=c(2,2,6))
  ## add a few variables to oa12
  responses <- cbind(y=rexp(12),z=runif(12))
  oa12 <- add.response(oa12, responses)
  ## want treatment contrasts rather than the default
  ## polynomial contrasts for the factors 
  oa12 <- change.contr(oa12, "contr.treatment")
  linmod.y <- lm(oa12)
  linmod.z <- lm(oa12, response="z")
  linmod.y
  linmod.z
  summary(linmod.y)
  summary(linmod.z)
  
## examples with aggregation
  plan <- oa.design(nlevels=c(2,6,2), replications=2, repeat.only=TRUE)
  y <- rnorm(24)
  z <- rexp(24)
  plan <- add.response(plan, cbind(y=y,z=z))
  lm(plan)
  lm(plan, response="z")
  lm(plan, FUN=sd)
  ## wide format
  plan <- reptowide(plan)
  plan
  design.info(plan)$responselist
  ## default: aggregate variables for first column of responselist
  lm(plan)
  ## request z variables instead (z is the column name of response list)
  lm(plan, response="z") 
  ## force analysis of first z measurement only
  lm(plan, response="z.1")
  ## use almost all options 
  ## (option use.center can only be used with center point designs 
  ##          from package FrF2)
  summary(lm(plan, response="z", degree=2, FUN=sd))