Learn R Programming

ScottKnott (version 1.2-0)

MaxValue: Algorithm for Pre-order Path in Binary Decision Tree

Description

Builds groups of means, according to the method of Scott & Knott.

Usage

MaxValue(g,
           means,
           mMSE,
           dfr, 
           sig.level,
           k,
           group,
           ngroup,
           markg,
           g1=g,
           sqsum=rep(0, g1))

Arguments

g
A vector of length 1 giving the upper limit of the possible groups.
means
A vector of the group of treatments means in decresing order.
mMSE
A vector of length 1 giving the MSE divided by the number of replications.
dfr
A vector of length 1 giving the degrees of freedom of MSE.
sig.level
A vector of length 1 giving the level of significance of the test.
k
A vector of length 1 giving the lower limit of the possible groups.
group
A vector of the same length as means marking the groups generated.
ngroup
A vector of length 1 giving the number of groups generated.
markg
A vector of the same length as means marking the upper limit of the last group generated before the process goes on recursively.
g1
A vector of length 1 which keeps, during the whole process, the value of the initial g.
sqsum
A vector of length 1 giving the sum of the square between groups.

Value

  • An vector with the groups of means.

Details

The function MaxValue builds groups of means, according to the method of Scott & Knott. Basically it is an algorithm for pre-order path in binary decision tree. Every node of this tree, represents a different group of means and, when the algorithm reaches this node it takes the decision to either split the group in two, or form a group of means. If the decision is to divide then this node generates two children and the algorithm follows for the node on the left, if, on the other hand, the decision is to form a group, then it returns to the parent node of that node and follows to the right node. In this way it follows until the last group is formed, the one containing the highest (or the least) mean. In case that the highest (or the least) mean becomes itself a group of one element, the algorithm continues to the former group. In the end, each node without children represents a group of means.

References

Ramalho M.A.P., Ferreira D.F., Oliveira A.C. 2000. Experimentacao em Genetica e Melhoramento de Plantas. Editora UFLA. Scott R.J., Knott M. 1974. A cluster analysis method for grouping mans in the analysis of variance. Biometrics, 30, 507-512.

See Also

SK

Examples

Run this code
##
## Examples: Completely Randomized Design (CRD)
##

data(CRD1)

av      <- with(CRD1,
                aov(y ~ x,
                    data=dfm))              # Doing an ANOVA
mm      <- model.tables(av,
                        "means")            # summary tables for model fits
tabs    <- mm$tables[-1]                    # all model means
which   <- names(av$model)[2]
tabs    <- tabs[which]                      # specified group means
nn      <- mm$n[names(tabs)]                # repetions number of specified groups
MSE     <- sum(resid(av)^2)/av$df.residual
tab     <- tabs[[which]]                    # tab=means
means   <- as.vector(tab)
mnumber <- length(means)                    # number of means
nms     <- names(tab)
r       <- nn[[which]]                      # groups and its number of replicates
ord     <- order(means,
                 decreasing=TRUE)
mMSE    <- MSE/r
dfr     <- av$df.residual                   # residual degrees of freedom
means   <- means[ord]                       # decreasing ordered means
g       <- mnumber

## Grouping the means: sig.level=.05
groups  <- MaxValue(g,
                    means,
                    mMSE,
                    dfr,
                    sig.level=.05,
                    1,
                    rep(0, g),
                    0,
                    rep(0, g))

## The result: sig.level=.05
groups


## Grouping the means: sig.level=.10
groups  <- MaxValue(g,
                    means,
                    mMSE,
                    dfr,
                    sig.level=.10,
                    1,
                    rep(0, g),
                    0,
                    rep(0, g))

## The result: sig.level=.10
groups

Run the code above in your browser using DataLab