getMM | R Documentation |
Function getMM
constructs overparameterized design matrices from a model formula and a data.frame.
getMM(form, Data, keep.order = TRUE)
form |
(formula) with or without response specifying the model to be fit |
Data |
(data.frame) with the data |
keep.order |
(logical) TRUE = terms in 'form' should keep their positions, otherwise main effects come first and all interactions will be put into increasing order |
This function constructs the overparameterized design matrix for a given dataset 'Data' according to
the model formula 'form'. Each combination of factor-levels and or numeric variables is identified
and accounted for by a separate column. See examples for differences compared to function 'model.matrix' (stats).
This type of design matrix is used e.g. in constructing A-matrices of quadratic forms in y
expressing
ANOVA sums of squares as such. This is key functionality of functions anovaVCA
and anovaMM
used e.g. in constructing the coefficient matrix C
whose inverse is used in solving for ANOVA Type-1 based
variance components..
Andre Schuetzenmeister andre.schuetzenmeister@roche.com
## Not run:
# load example data (CLSI EP05-A2 Within-Lab Precision Experiment)
data(dataEP05A2_3)
tmpData <- dataEP05A2_3[1:10,]
# check out the differences
getMM(~day+day:run, tmpData)
model.matrix(~day+day:run, tmpData)
# adapt factor variables in 'tmpData'
tmpData$day <- factor(tmpData$day)
# check out the differences now
getMM(~day+day:run, tmpData)
model.matrix(~day+day:run, tmpData)
# numeric covariate 'cov'
tmpData2 <- dataEP05A2_3[1:10,]
tmpData2$cov <- 10+rnorm(10,,3)
model.matrix(~day*cov, tmpData2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.