aovremm | R Documentation |
Print the ANOVA table with random effects and compute the classical point estimations of the variance components using the Moments method.
aovremm(formula, data = NULL, ...)
formula |
A formula specifying the model. |
data |
A data frame in which the variables specified in the |
... |
Arguments to be passed to other functions. |
A list
aov
, lmer
, aovreml
.
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (formula, data = NULL, ...)
{
ANOV <- aov(formula, data, ...)
.ANOV <- summary(ANOV)
cat("-------------------------------")
cat("\n", gettext("ANOVA table", domain = "R-RcmdrPlugin.TeachStat"),
":\n", sep = "")
print(.ANOV)
cat("\n-------------------------------\n\n")
.sighat2 <- .ANOV[[1]]$`Mean Sq`[2]
.vars <- all.vars(formula)
.groups <- data[[.vars[2]]][!is.na(data[[.vars[1]]])]
.n <- length(.groups)
.ni <- table(.groups)
.c <- (.n^2 - sum(.ni^2))/(.n * (length(.ni) - 1))
.sighatalph2 <- (.ANOV[[1]]$`Mean Sq`[1] - .sighat2)/.c
if (.sighatalph2 < 0)
warning("Estimation of any variance component is not positive. The variance
component model is inadequate.")
.prop <- .sighatalph2/(.sighatalph2 + .sighat2)
estim <- c(.sighat2, .sighatalph2, .prop)
names(estim) <- c("var (Error)", "var (Effect)", "% var (Effect)")
cat("\n", gettext("Components of Variance", domain = "R-RcmdrPlugin.TeachStat"),
":\n", sep = "")
print(estim)
return(invisible(list(model = ANOV, estimation = estim)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.