varcomp
which provides estimates of
variance components, coefficients and the random variables.
The default estimates are MINQUE0, but REML, maximum likelihood and
Winsorized estimates are alternatives.
varcomp(formula, data=<<see below>>, method="minque0", start.var=<<see below>>, tol=<<see below>>, nderiv = 1...)
formula
must contain at
least one factor that is random (see
is.random
).
"minque0"
,
"reml"
,
"ml"
,
and
"winsor"
.
If
"winsor"
is the first string,
then one of the other three may be given as a second string.
You only need to give enough of the beginning of
the string to uniquely identify it.
.Machine$double.eps^0.25
for REML
and
.Machine$double.eps^0.5
for ML.
varcomp
.
The default is 1.
subset
and
na.action
.
"varcomp"
,
which inherits from
"lm"
.
See
varcomp.object
for details.
Models of the form
y = Xa + Zb + e
are fit
by this function,
where
y
is a univariate response,
X
is a known matrix,
a
is an unknown vector of (fixed) coefficients,
Z
is a known matrix representing
one or more random effects,
b
is a vector of unknown random variables,
and
e
is a vector of the unknown errors.
There needs to be a partition of the columns of
Z
such that the submatrices,
Zi
, have only one non-zero entry in each row.
MINQUE0 estimates are computed as in Hartley, Rao, and LaMotte (1978).
Variances components are obtained via unconstrained optimization
using the NETLIB functions
dmnf
,
dmng
,
and
dmnh
(Gay (1983), Dongarra and Grosse (1987)).
The objective function and derivatives are computed using a version
of the W-transformation
(Hemmerle and Hartley (1973), Corbeil and Searle (1976)) that is
numerically stable when the variance component estimates are
small in magnitude (Fraley and Burns (1992)).
The Winsorization method produces robust estimates of the variance
components.
The data are "cleaned" using an initial robust estimate,
and then a standard estimation procedure is performed on the cleaned data.
See Burns (1992) for more information.
The
raov
function produces ANOVA estimates
for balanced random models.
The possible messages, and their meanings, are as follows:
successive parameter values are within a specified tolerance of each other.
tol
argument determines this convergence;
the convergence criteria is relative rather than absolute.
See Gay (1983) for details.varcomp
.)varcomp
.)varcomp
.)
Burns, P. J. (1992).
Winsorized REML estimates of variance components.
Technical Report, Statistical Sciences, Inc.
Corbeil, R. R. and Searle, S. R. (1976).
Restricted maximum likelihood (REML) estimation of variance components in
the mixed model.
Technometrics
18 31-38.
Dongarra, J. J. and Grosse, E. (1987).
Distribution of mathematical software via electronic mail.
Communications of the ACM
30 403-407.
Fraley, C. and Burns, P. J. (1995).
Large-scale estimation of variance and covariance components.
SIAM Journal on Scientific Computing
Vol. 16 No. 1.
Gay, D. M. (1983).
Algorithm 611. Subroutines for Unconstrained Minimization using a
Model/ Trust-Region Approach.
ACM Transactions on Mathematical Software,
9 369-383.
Hartley, H. O., Rao, J. N. K., and LaMotte, L. R. (1978).
A simple "synthesis"-based mathod of variance component estimation.
Biometrics
34 233-242.
Hemmerle, W. J. and Hartley, H. O. (1973).
Computing maximum likelihood estimates for the mixed AOV model using
the W-transformation.
Technometrics
15 819-831.
It should be noted that
varcomp
will not work
for models in which the error variance vanishes.
For example, you cannot put a term in the model
that is equivalent to the residuals.
For example with the
pigment
data,
the formula
Moisture ~ Batch/Sample/Test
will not work
because the variable
Test
is equivalent
to the residuals.
pigment <- pigment # make a local copy of pigment is.random(pigment) <- T # make all factors random varcomp(Moisture ~ Batch/Sample, pigment) varcomp(Moisture ~ Batch/Sample, pigment, method=c("winsor", "r")) rm(pigment) # remove local copy # Example from S-PLUS Guide to Statistics subject <- factor(rep(1:30, each=10)) trueslope <- rnorm(30, mean=1); trueint <- rnorm(30, sd=.5) times <- rchisq(300, 3) scores <- rep(trueint, each=10) + times * rep(trueslope, each=10) + rnorm(300, sd=.35) test.df <- data.frame(subject, times, scores) is.random(test.df) <- T # The following model gives a random slope and intercept for each # subject, plus an overall fixed slope and intercept vc1 <- varcomp(scores ~ times * subject, data=test.df, method="ml") vc1 summary(vc1)