aovremm: ANOVA with random effects using the Moments method.

aovremmR Documentation

ANOVA with random effects using the Moments method.

Description

Print the ANOVA table with random effects and compute the classical point estimations of the variance components using the Moments method.

Usage

aovremm(formula, data = NULL, ...)

Arguments

formula

A formula specifying the model.

data

A data frame in which the variables specified in the formula will be found. If missing, the variables are searched for in the standard way.

...

Arguments to be passed to other functions.

Value

A list

See Also

aov, lmer, aovreml.

Examples

##---- 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)))
  }

RcmdrPlugin.TeachStat documentation built on Nov. 14, 2023, 5:08 p.m.