lm method for class design objects {DoE.base} | R Documentation |
Method for automatic linear models for data frames of class design
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=FALSE) ## S3 method for class 'lm.design': print(x, ...) ## S3 method for class 'lm.design': summary(object, ...) ## S3 method for class 'summary.lm.design': print(x, ...) lm.design summary.lm.design
formula |
for the default method, cf. documentation for lm
in package stats;cr
for the class design method, a data frame of S3 class
design |
... |
further arguments to functions lm ,
print.lm or print.summary.lm |
response |
character string giving the name of the response variable
(must be among the responses of x ;
for wide format repeated measurement or parameter designs,
response can also be among the column names of the responselist
element of the design.info attribute) OR integer number giving the position of the response in element response.names of attribute design.info
For the default NULL , the first available response variable
is used; for wide format designs, this is an aggregation of the variables
given in first column from the responselist
element of the design.info attribute of x .
|
degree |
degree for the formula; if NULL ,
the default for the formula method is used |
FUN |
function for the aggregate.design method;
this must be an unquoted function name;This option is relevant for repeated measurement designs and parameter designs in long format only |
use.center |
logical indicating whether center points are to be used +
in the analysis; relevant for pb and FrF2 designs with
center points only;the default FALSE allows application of analysis from package
FrF2-package (e.g. function IAPlot )
|
x |
object of class lm or summary.lm ,for lm.default like in lm |
object |
object of class lm.design created by function lm.design |
lm.design |
a class that is identical in content to class lm ;
its purpose is to call a specific print method that provides slightly more
detail than the standard printout for linear models |
summary.lm.design |
a class that is identical in content to class summary.lm ;
its purpose is to call a specific print method that provides slightly more
detail than the standard summary for linear models |
data |
like in lm |
subset |
like in lm |
weights |
like in lm |
na.action |
like in lm |
method |
like in lm |
model |
like in lm |
y |
like in lm |
qr |
like in lm |
singular.ok |
like in lm |
contrasts |
like in lm |
offset |
like in lm |
The lm
method for class design
conducts 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 function lm.design
itself
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
(method for function lm
)
does not reveal enough information, and another pointer that center points have been
omitted or repeated measurements aggregated over.
The value for the lm
functions is a linear model object,
exactly like for function lm
,
except for the added class lm.design
.
The value of the summary
function for class lm.design
is a linear model summary, exactly like documented in summary.lm
,
except for the added class lm.design
.
The print functions return NULL
; they are used for their side effects only.
The package is currently subject to intensive development; most key functionality is now included. Some changes to input and output structures may still occur.
Ulrike Groemping
See also the information on class design
and its formula method formula.design
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))