Commit a7aea667 by Eric Coissac

start to implement permutation anova...

parent 1b31e9e8
......@@ -5,7 +5,7 @@
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
anova.pm = function(m,...) {
anova.pm = function(m, permutations = how(nperm = 999),...) {
mf = m$model
coef = m$coefficients
......@@ -23,8 +23,8 @@ anova.pm = function(m,...) {
cors = m$cov / outer(sdxy,sdxy)
print(reponse)
print(explicatives)
#print(reponse)
#print(explicatives)
cors.Y = cors[reponse,explicatives]
......@@ -63,3 +63,32 @@ anova.pm = function(m,...) {
return(result)
}
#' Generate permutation matrix according to a schema.
#'
#' The permutation schema is defined using the `how` function.
#' The implementation of this function is currectly extraced
#' from the VEGAN package and just copied pasted here to avoid
#' dependency on an hidden vegan function.
#'
getPermuteMatrix = function (perm, N, strata = NULL)
{
if (length(perm) == 1) {
perm <- how(nperm = perm)
}
if (!missing(strata) && !is.null(strata)) {
if (inherits(perm, "how") && is.null(getBlocks(perm)))
setBlocks(perm) <- strata
}
if (inherits(perm, "how"))
perm <- shuffleSet(N, control = perm)
else {
if (!is.integer(perm) && !all(perm == round(perm)))
stop("permutation matrix must be strictly integers: use round()")
}
if (is.null(attr(perm, "control")))
attr(perm, "control") <- structure(list(within = list(type = "supplied matrix"),
nperm = nrow(perm)), class = "how")
perm
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment