getMM {VCA}R Documentation

Overparameterized Design Matrices

Description

Function getMM constructs overparameterized design matrices from a model formula and a data.frame.

Usage

getMM(form, Data, keep.order = TRUE)

Arguments

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

Details

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

Author(s)

Andre Schuetzenmeister andre.schuetzenmeister@roche.com

Examples

## 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)


[Package VCA version 1.5.1 Index]