Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

DoE.base (version 0.6-1)

qua.design: Function to switch between qualitative and quantitative factors and different contrast settings

Description

The function allows to switch between qualitative and quantitative factors and different contrast settings.

Usage

qua.design(design, quantitative = NA, contrasts = character(0), ...)

Arguments

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 a
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 named character vector can be given; the nam
...
currently not used

Value

  • 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.

Details

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. 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. Warning: It is possible to misuse this function especially for designs that have been combined from several designs. For example, while setting factors in an 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.

References

~put references to the literature/web site here ~

Examples

Run this code
## usage with all factors treated alike
plan <- oa.design(nlevels=c(2,6,2))
plan
plan <- qua.design(plan, quantitative = "none")
plan
plan <- qua.design(plan, quantitative = "all")
plan
plan <- qua.design(plan)
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))
## would cause an error, since liquid is character and cannot be reasonably coerced to numeric
plan <- qua.design(plan, quantitative = "all")
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)

Run the code above in your browser using DataLab