Creates the model matrix X
from the design matrix and the model formula.
Value
A list with the 5 following named elements :
lmpDataList
The initial object: a list with outcomes, design and formula, as outputted by
data2LmpDataList
.modelMatrix
A nxK model matrix specifically encoded for the ASCA-GLM method.
modelMatrixByEffect
A list of p model matrices for each model effect.
effectsNamesUnique
A character vector with the p names of the model effects, each repeated once.
effectsNamesAll
A character vector with the K names of the model effects ordered and repeated as the column names of the model matrix.
Details
In typical ASCA-GLM (ASCA+) analysis, the effects of the GLM model must first be used to transform the design matrix to a model matrix where the design factors encoded usign sum coding commonly used in industrial experimental design. Suppose the design matrix is nxk with n observations and k factors. After the transformation, the model matrix will be of size nxp. For a fator with a levels, the sum coding creates a-1 columns in the model matrix with 0 and 1 for the a-1 first levels and -1 for the last one. p is the total number parameter for each response (outcome) in the ASCA model. More information is available in the article (Thiel et al, 2017) Note that at the moment, only factors can be used as explanatory variables.
References
Thiel M.,Feraud B. and Govaerts B. (2017) ASCA+ and APCA+: Extensions of ASCA and APCA in the analysis of unbalanced multifactorial designs, Journal of Chemometrics
Examples
data("UCH")
resLmpModelMatrix <- lmpModelMatrix(UCH)
head(resLmpModelMatrix$modelMatrix)
#> (Intercept) Hippurate1 Hippurate2 Citrate1 Citrate2 Time1
#> M2C00D2R1 1 1 0 1 0 1
#> M2C00D2R2 1 1 0 1 0 -1
#> M2C02D2R1 1 1 0 0 1 1
#> M2C02D2R2 1 1 0 0 1 -1
#> M2C04D2R1 1 1 0 -1 -1 1
#> M2C04D2R2 1 1 0 -1 -1 -1
#> Hippurate1:Citrate1 Hippurate2:Citrate1 Hippurate1:Citrate2
#> M2C00D2R1 1 0 0
#> M2C00D2R2 1 0 0
#> M2C02D2R1 0 0 1
#> M2C02D2R2 0 0 1
#> M2C04D2R1 -1 0 -1
#> M2C04D2R2 -1 0 -1
#> Hippurate2:Citrate2 Hippurate1:Time1 Hippurate2:Time1 Citrate1:Time1
#> M2C00D2R1 0 1 0 1
#> M2C00D2R2 0 -1 0 -1
#> M2C02D2R1 0 1 0 0
#> M2C02D2R2 0 -1 0 0
#> M2C04D2R1 0 1 0 -1
#> M2C04D2R2 0 -1 0 1
#> Citrate2:Time1 Hippurate1:Citrate1:Time1 Hippurate2:Citrate1:Time1
#> M2C00D2R1 0 1 0
#> M2C00D2R2 0 -1 0
#> M2C02D2R1 1 0 0
#> M2C02D2R2 -1 0 0
#> M2C04D2R1 -1 -1 0
#> M2C04D2R2 1 1 0
#> Hippurate1:Citrate2:Time1 Hippurate2:Citrate2:Time1
#> M2C00D2R1 0 0
#> M2C00D2R2 0 0
#> M2C02D2R1 1 0
#> M2C02D2R2 -1 0
#> M2C04D2R1 -1 0
#> M2C04D2R2 1 0