Learn R Programming

VCA (version 1.1.1)

anovaVCA: ANOVA-Type Estimation of Variance Components for Random Models.

Description

This function equates observed ANOVA sums of squares ($SS$) to their expected values and solves the resulting system of linear equations for variance components. ANOVA SS are computed via matrices $A_i$ expressing them as quadratic forms in $y$ as $ss_i = y^{T}A_{i}y$. Matrices $A_i$ are also used to compute the variance-coveriance matrix of variance components (VC).

Usage

anovaVCA(form, Data, NegVC = FALSE, VarVC.method = c("scm", "gb"))

Arguments

form
(formula) specifying the model to be fit, a response variable left of the '~' is mandatory
Data
(data.frame) storing all variables referenced in 'form'
NegVC
(logical) FALSE = negative variance component estimates (VC) will be set to 0 and they will not contribute to the total variance (as done in SAS PROC NESTED, conservative estimate of total variance). The original ANOVA estimates can be found i
VarVC.method
(character) string specifying whether to use the algorithm given in the $1^{st}$ reference ("scm") or in the $2^{nd}$ refernce ("gb"). Method "scm" (Searle, Casella, McCulloch) is the exact algorithm but slower, "gb" (Giesbrecht, Burns) is

Value

  • (object) of class 'VCA'

Details

Function anovaVCA is tailored for performing Variance Component Analyses (VCA) for random models, assuming all VCs as factor variables, i.e. their levels correspond to distinct columns in the design matrix (dummy variables). Any predictor variables are automatically converted to factor variables, since continuous variables may not be used on the right side of the formula 'form'. For diagnostics, a key parameter is "precision", i.e. the accuracy of a quantification method influenced by varying sources of random error. This type of experiments is requested by regulatory authorities to proof the quality of diagnostic test, e.g. quantifying intermediate precision according to CLSI guideline EP5-A2/A3. No, fixed effects are allowed besides the intercept. Whenever fixed effects are part of the model to be analyzed, use function anovaMM instead. Function anovaVCA represents a special form of the "method of moments" approach applicable to arbitrary random models either balanced or unbalanced. The system of linear equations, which is built from the ANOVA-Type 1 sums of squares, is closely related to the method used by SAS PROC VARCOMP, where ANOVA mean squares ($MS$) are used (see getCmatrix). The former can be written as $ss = C * s$ and the latter as $ms = D * s$, where $C$ and $D$ denote the respective coefficient matrices, $s$ the column-vector of variance components (VC) to be estimated/predicted, and $ss$ and $ms$ the column vector of ANOVA sum of squares, respectively, mean squares. Mutliplying element $d_ij$ of matrix $D$ by element $c_in$ of matrix $C$ ($i,j = 1,...,n$), results in matrix $C$. Thus, $C$ can easily be converted to $D$ by the inverse operation. Matrix $D$ is used to estimate total degrees of freedom (DF) according to Satterthwaite (1946). If computing matrices $A_i$ generating ANOVA $SS$ as quadratic forms in $y$, i.e. $ss_i = y' * A_i * y$ has two benefits. It allows obtaing ANOVA $SS$ as well as computing the variance-covariance of VCs. Furthermore, it is much faster than fitting the linear model via lm and calling function anova on the 'lm' object for complex models, where complex refers to the number of columns of the design matrix and the degree of unbalancedness. Degrees of freedom for the $i$-th term are obtained by function anovaDF. Besides the algorithm for obtaining the variance-covariance matrix of VCs described in Searle et. al (1992), which is termed "exact", a $2^{nd}$ option for computing this matrix is implemented, which is described in Giesbrecht and Burns (1985). It can be chosen by setting 'VarVC.method="gb"'.

References

Searle, S.R, Casella, G., McCulloch, C.E. (1992), Variance Components, Wiley New York Giesbrecht, F.G. and Burns, J.C. (1985), Two-Stage Analysis Based on a Mixed Model: Large-Sample Asymptotic Theory and Small-Sample Simulation Results, Biometrics 41, p. 477-486 Satterthwaite, F.E. (1946), An Approximate Distribution of Estimates of Variance Components., Biometrics Bulletin 2, 110-114 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 SAS Help and Documentation PROC MIXED, SAS Institute Inc., Cary, NC, USA SAS Help and Documentation PROC VARCOMP, SAS Institute Inc., Cary, NC, USA

See Also

anovaMM, stepwiseVCA, print.VCA, VCAinference, getCmatrix, ranef, plotRandVar

Examples

Run this code
# load data (CLSI EP05-A2 Within-Lab Precision Experiment)
data(dataEP05A2_2)

# perform ANOVA-estimation of variance components
res <- anovaVCA(y~day/run, dataEP05A2_2)
res

# desing with two main effects (ignoring the hierarchical structure of the design)
anovaVCA(y~day+run, dataEP05A2_2)

# compute confidence intervals, perform F- and Chi-Squared tests
INF <- VCAinference(res, total.claim=3.5, error.claim=2)
INF

### load data from package
data(VCAdata1)

data_sample1 <- VCAdata1[VCAdata1$sample==1,]

### plot data for visual inspection (there is no variance between runs on a day)
varPlot(y~lot/day/run, data_sample1)

### estimate VCs for 4-level hierarchical design (error counted) for sample_1 data
anovaVCA(y~lot/day/run, data_sample1)

### using different model (ignoring the hierarchical structure of the design)
anovaVCA(y~lot+day+lot:day:run, data_sample1)

### same model with unbalanced data
anovaVCA(y~lot+day+lot:day:run, data_sample1[-c(1,11,15),])

### use the numerical example from the CLSI EP05-A2 guideline (p.25)
data(dataEP05A2_example)
res.ex <- anovaVCA(result~day/run, dataEP05A2_example)

### also perform Chi-Squared tests
### Note: in guideline claimed SD-values are used, here, claimed variances are used
VCAinference(res.ex, total.claim=3.4^2, error.claim=2.5^2)

#' # load another example dataset and extract the "sample==1" subset
data(VCAdata1)
sample1 <- VCAdata1[which(VCAdata1$sample==1),]

# generate an additional factor variable and random errors according to its levels
sample1$device <- gl(3,28,252)
set.seed(505)
sample1$y <- sample1$y + rep(rep(rnorm(3,,.25), c(28,28,28)),3)

# fit a crossed-nested design with main factors 'lot' and 'device'
# and nested factors 'day' and 'run' nested below
res1 <- anovaVCA(y~(lot+device)/day/run, sample1)
res1

Run the code above in your browser using DataLab