Function getCmatrix
computes the coefficient matrix used in equating observed ANOVA sum of squares (or mean squares) to their expected values
as linear combination of the unobservable, true variance components. This "can be viewed in some sense as a special form of the method of moments"
approach (Searle et al. 1992, "Variance Components", p. 173).
getCmatrix(form, Data, DF = NULL, type = c("MS", "SS"), digits = 12L,
MM = NULL)
(formula) object specifying the random model
(data.frame) containing all variables in 'form'
(numeric) vector with the degrees of freedom for each VC, if not specified it will be determined automatically by refitting 'form' to 'Data'
(character) "MS" = mean squares coefficient matrix "SS" = sum of squares coefficient matrix
(integer) numeric tolerance expressed in number of digits. This is used for testing whether a value is equal to zero (round(x,digits) == 0).
(Matrix) object referring to the overparameterized model matrix of the full model, if provided, it does not need to be computed twice
Functions implements the algorithm for finding coefficient-matrix \(C\) of a method of moments approach to ANOVA-estimation
of variance components (VC), given in the first reference. Matrix \(C\) corresponds to the coefficient matrix equating
expected ANOVA mean squares (MS) to observed values as linear combinations of the unknown VCs to be estimated.
The most computationally expensive parts of the algorithm were implemented in C
, speeding up things a significantly.
Consider formulas: \(m_{MS} = Cs\) and \(m_{SS} = Ds\), where \(m_{MS}\) and \(m_{SS}\) are a column-vectors of observed ANOVA MS-, respectively, ANOVA SS-values, \(C\) and \(D\) are coefficient matrices, equating \(m_{MS}\), respectively, \(m_{SS}\) to linear combinations of VCs \(s\), which are to be estimated. Once matrix \(C\) or \(D\) is found, pre-multiplying \(s\) with its inverse gives ANOVA-estimators of VCs. This function implements the algorithm described in the first reference, the "Abbreviated Doolittle and Square Root Methods". One can convert matrices \(C\) and \(D\) into the other by multiplying/dividing each element by the respective degrees of freedom (DF) associated with the corresponding factor in the model. If \(\diamond\) denotes the operator for element-wise multiplication of two matrices of the same order (Hadamard-product), \(d\) is the column vector of DFs, and \(M\) is a \(r \times r\) quadratic matrix with \(M = d1_r^{T}\), \(1_r^{T}\) being the transpose of a column-vector of ones with \(r\) elements, then holds: \(M = D \diamond M\).
Gaylor,D.W., Lucas,H.L., Anderson,R.L. (1970), Calculation of Expected Mean Squares by the Abbreviated Doolittle and Square Root Methods. Biometrics 26(4):641-655
# NOT RUN {
data(dataEP05A2_1)
C_ms <- getCmatrix(y~day/run, dataEP05A2_1, type="MS")
C_ms
C_ss <- getCmatrix(y~day/run, dataEP05A2_1, type="SS")
C_ss
aov.tab <- anova(lm(y~day+day:run, dataEP05A2_1))
aov.tab
apply(C_ss, 2, function(x) x/aov.tab[,"Df"])
# }
Run the code above in your browser using DataLab