qua.design {DoE.base} | R Documentation |
The function allows to switch between qualitative and quantitative factors and different contrast settings.
qua.design(design, quantitative = NA, contrasts = character(0), ...) change.contr(design, contrasts=contr.treatment)
design |
an experimental design,
data frame of class design |
quantitative |
can be
EITHER one of the single entries NA for setting all factors to the default coding for class design (cf. details), “all” for making all factors quantitative (=numeric), “none” for making all factors qualitative (=factor) OR an unnamed vector of length nfactors
with an entry TRUE , NA or FALSE for each factor,
where TRUE makes a factor into a numeric variable,
and FALSE makes it into a factor with treatment contrasts, and NA
reinstates the default factor settings;OR a named vector (names from the factor names of the design) with an entry TRUE , NA or FALSE for each named factor
(implying no change for the omitted factors)
|
contrasts |
only takes effect for factors for which quantitative is FALSE ;the default character(0) does not change any contrasts vs.~the previous
or default contrasts.For customizing, a character string OR a character vector with a contrast name entry for each factor OR a named character vector of arbitrary length from 1 to number of factors can be given; the names must correspond to names of factors to be modified, and entries must be names of contrast functions. The contrast functions are then applied to the respective factors with the correct number of levels. Possible contrast function names include (at least) contr.FrF2 (for number of levels a power of 2 only),
contr.helmert ,
contr.treatment ,
contr.SAS ,
contr.sum ,
contr.poly .
CAUTION: Function qua.design checks whether the contrast names
actually define a function, but it is not checked
whether this function is a valid contrast function.
|
... |
currently not used |
With function qua.design
, option quantitative
has the following implications:
An experimental factor for which quantitative is TRUE
is recoded into a numeric variable.
An experimental factor for which quantitative is NA
is recoded into an R-factor
with the default contrasts given below.
An experimental factor for which quantitative is FALSE is recoded into an R-factor
with treatment contrasts (default) or with custom contrasts as indicated by the
contrasts
parameter.
If the intention is to change contrasts only, function change.contr
is a convenience interface to function qua.design
.
The default contrasts for factors in class design
objects
(exception: purely quantitative design types like lhs or rsm designs)
depend on the number and content of levels:
2-level experimental factors are coded as R-factors with -1/1 contrasts,
experimental factors with more than two quantitative (=can be coerced to numeric) levels are
coded as R factors with polynomial contrasts (with scores the numerical levels of the factor),
and qualitatitve experimental factors with more than two levels are coded
as R factors with treatment contrasts.
Note that, for 2-level factors, the default contrasts from function qua.design
differ from the default contrasts with which the factors were generated in case of
functions fac.design
or oa.design
. Thus, for recreating
the original state, it may be necessary to explicity specify the desired contrasts.
Function change.contr
makes all factors qualitative. Per default, treatment
contrasts (cf. contr.treatment
)
are assigned to all factors. The default contrasts can of course be modified.
Warning: It is possible to misuse these functions especially for designs that have been
combined from several designs. For example, while setting factors in an lhs design
(cf. lhs.design
) to
qualitative is prevented, if the lhs design has been crossed with another design of a different
type, it would be possible to make such a nonsensical modification.
A data frame of class design
; the element quantitative
of attribute design.info
,
the data frame itself and the desnum
attribute are modified as appropriate.
Although testing of this function has progressed, it is still somewhat experimental.
Ulrike Groemping
~put references to the literature/web site here ~
## usage with all factors treated alike y <- rnorm(12) plan <- oa.design(nlevels=c(2,6,2)) lm(y~.,plan) lm(y~., change.contr(plan)) ## with treatment contrasts instead plan <- qua.design(plan, quantitative = "none") lm(y~.,plan) plan <- qua.design(plan, quantitative = "none", contrasts=c(B="contr.treatment")) lm(y~.,plan) plan <- qua.design(plan, quantitative = "none") lm(y~.,plan) plan <- qua.design(plan, quantitative = "all") lm(y~.,plan) plan <- qua.design(plan) ## NA resets to default state lm(y~.,plan) ## usage with individual factors treated differently plan <- oa.design(factor.names = list(liquid=c("type1","type2"), dose=c(0,10,50,100,200,500), temperature=c(10,15))) str(undesign(plan)) ## Not run: ## would cause an error, since liquid is character and cannot be reasonably coerced to numeric plan <- qua.design(plan, quantitative = "all") ## End(Not run) plan <- qua.design(plan, quantitative = "none") str(undesign(plan)) plan <- qua.design(plan, quantitative = c(dose=TRUE,temperature=TRUE)) str(undesign(plan)) ## reset all factors to default plan <- qua.design(plan, quantitative = NA) str(undesign(plan)) desnum(plan) ## add a response y <- rnorm(12) plan <- add.response(plan,y) ## set dose to treatment contrasts plan <- qua.design(plan, quantitative = c(dose=FALSE), contrasts=c(dose="contr.treatment")) str(undesign(plan)) desnum(plan)