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 = 8L)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$.anovaVCA, getMMdata(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