# NOT RUN {
##---- 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)))
}
# }
Run the code above in your browser using DataLab