Learn R Programming

ScottKnott (version 1.2-7)

SK: The ScottKnott Clustering Algoritm for Single Experiments

Description

These are methods for objects of class vector, matrix or data.frame joined as default, aov and aovlist for single experiments.

Usage

# S3 method for default
SK(x,
   y=NULL,
   model,
   which,
   id.trim=3,
   error,
   sig.level=.05,
   dispersion=c('mm', 's', 'se'), …)
  # S3 method for aov
SK(x,
   which=NULL, 
   id.trim=3,
   sig.level=.05,
   dispersion=c('mm', 's', 'se'), …)
  # S3 method for aovlist
SK(x,
   which, 
   id.trim=3,
   error,
   sig.level=.05,
   dispersion=c('mm', 's', 'se'), …)

Arguments

x

A design matrix, data.frame or an aov object.

y

A vector of response variable. It is necessary to inform this parameter only if x represent the design matrix.

which

The name of the treatment to be used in the comparison. The name must be inside quoting marks.

model

If x is a data.frame object, the model to be used in the aov must be specified.

id.trim

The number of character to trim the id label.

error

The error to be considered.

sig.level

Level of Significance used in the SK algorithm to create the groups of means. The default value is 0.05.

dispersion

The dispersion to be considered to the means. The possible vaues are: 'mm' = minimum and maximum, 's' = standart deviation, 'se' = standart deviation of the mean.

Potential further arguments (require by generic).

Value

The function SK returns a list of the class SK with the slots:

av

A list storing the result of aov.

groups

A vector of length equal the number of factor levels marking the groups generated.

nms

A vector of the labels of the factor levels.

ord

A vector which keeps the position of the means of the factor levels in decreasing order.

m.inf

A matrix which keeps the means and the dispersion of the factor levels in decreasing order.

sig.level

A vector of length 1 giving the level of significance of the test.

Details

The function SK returns an object of class SK respectivally containing the groups of means plus other necessary variables for summary and plot.

The generic functions summary and plot are used to obtain and print a summary and a plot of the results.

References

Ramalho M.A.P., Ferreira D.F., Oliveira A.C. 2000. Experimenta<e7><e3>o em Gen<e9>tica 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.

Examples

Run this code
# NOT RUN {
  ##
  ## Examples: Completely Randomized Design (CRD)
  ## More details: demo(package='ScottKnott')
  ##
  
  ## The parameters can be: vectors, design matrix and the response variable,
  ## data.frame or aov
  data(CRD2)
  
  ## From: design matrix (dm) and response variable (y)
  sk1 <- with(CRD2,
              SK(x=dm,
                 y=y,
                 model='y ~ x',
                 which='x'))
  summary(sk1)
  plot(sk1,
       col=rainbow(max(sk1$groups)),
       mm.lty=3,
       id.las=2,
       rl=FALSE,
       title='factor levels')
  
  ## From: data.frame (dfm)
  sk2 <- with(CRD2,
              SK(x=dfm,
                 model='y ~ x',
                 which='x',
                 dispersion='s'))
  summary(sk2)
  plot(sk2,
       col=rainbow(max(sk2$groups)),
       id.las=2,
       rl=FALSE)
  
  ## From: aov
  av <- with(CRD2,
             aov(y ~ x,
                 data=dfm))
  summary(av)
  
  sk3 <- with(CRD2,
              SK(x=av,
                 which='x',
                 dispersion='se'))
  summary(sk3)
  plot(sk3,
       col=rainbow(max(sk3$groups)),
       rl=FALSE,
       id.las=2,
       title=NULL)

  ##
  ## Example: Randomized Complete Block Design (RCBD)
  ## More details: demo(package='ScottKnott')
  ##
  
  ## The parameters can be: design matrix and the response variable,
  ## data.frame or aov
  
  data(RCBD)
  
  ## Design matrix (dm) and response variable (y)
  sk1 <- with(RCBD,
              SK(x=dm,
                 y=y,
                 model='y ~ blk + tra',
                 which='tra'))
  summary(sk1)
  plot(sk1)
  
  ## From: data.frame (dfm), which='tra'
  sk2 <- with(RCBD,
              SK(x=dfm,
                 model='y ~ blk + tra',
                 which='tra'))
  summary(sk2)
  plot(sk2,
       mm.lty=3,
       title='Factor levels')
  
  ##
  ## Example: Latin Squares Design (LSD)
  ## More details: demo(package='ScottKnott')
  ##
  
  ## The parameters can be: design matrix and the response variable,
  ## data.frame or aov
  
  data(LSD)
  
  ## From: design matrix (dm) and response variable (y)
  sk1 <- with(LSD,
              SK(x=dm,
                 y=y,
                 model='y ~ rows + cols + tra',
                 which='tra'))
  summary(sk1)
  plot(sk1)
  
  ## From: data.frame
  sk2 <- with(LSD,
              SK(x=dfm,
                 model='y ~ rows + cols + tra',
                 which='tra'))
  summary(sk2)
  plot(sk2,
       title='Factor levels')
  
  ## From: aov
  av <- with(LSD,
             aov(y ~ rows + cols + tra,
                 data=dfm))
  summary(av)
  
  sk3 <- SK(av,
            which='tra')
  summary(sk3)
  plot(sk3,
       title='Factor levels')

  ##
  ## Example: Factorial Experiment (FE)
  ## More details: demo(package='ScottKnott')
  ##
  
  ## The parameters can be: design matrix and the response variable,
  ## data.frame or aov
  
  ## Note: The factors are in uppercase and its levels in lowercase!

  data(FE)
  ## From: design matrix (dm) and response variable (y)
  ## Main factor: N
  sk1 <- with(FE,
              SK(x=dm,
                 y=y,
                 model='y ~ blk + N*P*K', 
                 which='N'))
  summary(sk1)
  plot(sk1,
       title='Main effect: N')

  ## Nested: p1/N
  nsk1 <- with(FE,
               SK.nest(x=dm,
                       y=y,
                       model='y ~ blk + N*P*K',
                       which='P:N',
                       fl1=1))
  summary(nsk1)
  plot(nsk1,
       title='Effect: p1/N')
# }

Run the code above in your browser using DataLab