Anovam {biology} | R Documentation |
~~ A concise (1-5 lines) description of what the function does. ~~
Anovam(object, denoms = "Resid")
object |
~~Describe object here~~ |
denoms |
~~Describe denoms here~~ |
~~ If necessary, more details than the description above ~~
~Describe the value returned If it is a LIST, use
comp1 |
Description of 'comp1' |
comp2 |
Description of 'comp2' |
...
....
~~further notes~~
~Make other sections like Warning with section{Warning }{....} ~
~~who you are~~
~put references to the literature/web site here ~
~~objects to See Also as help
, ~~~
##---- 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 (object, denoms = "Resid") { if (length(object[[1]]) > 1) a <- object[[1]] else { a <- object[[1]][[1]] if (is.null(a)) a <- object[[1]] } var_names <- rownames(a) terms <- grep("^[^ ]", rownames(a)) var_length <- length(var_names) - 1 if (match("summary.aov", class(denoms), nomatch = 0)) { a[length(rownames(a)), "Sum Sq"] <- denoms[[1]]["Residuals", "Sum Sq"] a[length(rownames(a)), "Df"] <- denoms[[1]]["Residuals", "Df"] a[length(rownames(a)), "Mean Sq"] <- denoms[[1]]["Residuals", "Sum Sq"]/denoms[[1]]["Residuals", "Df"] b <- denoms[[1]]["Resid", ] } if (match("list", class(denoms), nomatch = 0)) { b <- NULL for (i in 1:length(denoms)) b <- rbind(b, denoms[[i]]) a[length(rownames(a)), "Sum Sq"] <- b[length(denoms), "Sum Sq"] a[length(rownames(a)), "Df"] <- b[length(denoms), "Df"] a[length(rownames(a)), "Mean Sq"] <- b[length(denoms), "Sum Sq"]/b[length(denoms), "Df"] } if (match("anova", class(denoms), nomatch = 0)) { if (dim(denoms)[1] != 1) denoms <- denoms[rownames(denoms)[length(rownames(denoms))], ] b <- denoms bb <- b if (dim(b)[1] == 1) for (i in 1:var_length) bb <- rbind(bb, b) b <- bb a[length(rownames(a)), "Sum Sq"] <- b[var_length, "Sum Sq"] a[length(rownames(a)), "Df"] <- b[var_length, "Df"] a[length(rownames(a)), "Mean Sq"] <- b[var_length, "Sum Sq"]/b[var_length, "Df"] } if (match("character", class(denoms), nomatch = 0)) { b <- a if (length(denoms) == 1 | length(denoms) == length(terms) - 1 | length(denoms) == var_length) { } else stop("The number of denominators is not a function of the number of tests") if (length(denoms) == 1) denoms <- rep(denoms, var_length) if (length(denoms) > length(terms)) terms <- grep("", rownames(a)) b <- a[denoms, ] } for (i in 1:var_length) { if (!is.na(match(i, terms))) j <- match(i, terms) SS <- a[i, "Sum Sq"] MS <- SS/a[i, "Df"] a[i, "F value"] <- f <- MS/b[j, "Mean Sq"] a[i, "Pr(>F)"] <- 1 - pf(f, a[i, "Df"], b[j, "Df"]) } a }