snk.test: Student-Newman-Keuls (SNK) procedure

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

This function perforns a SNK post-hoc test of means on the factors of a chosen term of the model, comparing among levels of one factor within each level of other factor or combination of factors.

Usage

1
snk.test(object, term, among = NULL, within = NULL)

Arguments

object

An object of class lm, containing the specified design.

term

Term of the model to be analysed. Use estimates to see the right form to inform it.

among

Specifies the factor which levels will be compared among. Need to be specified if the term to be analysed envolves more than one factor.

within

Specifies the factor or combination of factors that will be compared within level among.

Details

SNK is a stepwise procedure for hypothesis testing. First the sample means are sorted, then the pairwise studentized range (q) is calculated by dividing the differences between means by the standard error, which is based upon the average variance of the two sample.

Value

A list containing the standard error, the degree of freedom and pairwise comparisons among levels of one factor within each level of other(s) factor(s).

Author(s)

Mauricio G. Camargo (camargo.ufpr@gmail.com)
Leonardo Sandrini-Neto (leonardosandrini@gmail.com)

References

Underwood, A.J. 1997. Experiments in Ecology: Their Logical Design and Interpretation Using Analysis of Variance. Cambridge University Press, Cambridge.

See Also

gad, estimates

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library(GAD)
data(rohlf95)
CG <- as.fixed(rohlf95$cages)
MQ <- as.random(rohlf95$mosquito) 
model <- lm(wing ~ CG + CG%in%MQ, data = rohlf95)
gad(model)
##Check estimates to see model structure
estimates(model)
snk.test(model,term = 'CG:MQ', among = 'MQ', within = 'CG')
##
##
##Example using snails dataset
data(snails)
O <- as.random(snails$origin)
S <- as.random(snails$shore)
B <- as.random(snails$boulder)
C <- as.random(snails$cage)
model <- lm(growth ~ O + S + O*S + B%in%S + O*(B%in%S) + C%in%(O*(B%in%S)), 
            data = snails)
gad(model)
##Check estimates to see model structure
estimates(model)
snk.test(model, term = 'O')
snk.test(model,term = 'O:S', among = 'S', within = 'O')
#if term O:S:B were significant, we could try 
snk.test(model, term = 'O:S:B', among = 'B', within = 'O:S')

Example output

Loading required package: matrixStats
Loading required package: R.methodsS3
R.methodsS3 v1.7.1 (2016-02-15) successfully loaded. See ?R.methodsS3 for help.
Analysis of Variance Table

Response: wing
         Df  Sum Sq Mean Sq  F value    Pr(>F)    
CG        2  665.68  332.84   1.7409    0.2295    
CG:MQ     9 1720.68  191.19 146.8781 6.981e-11 ***
Residual 12   15.62    1.30                       
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
$tm
      CG MQ n
CG     0  4 2
CG:MQ  1  1 2
Res    1  1 1

$mse
         Mean square estimates
CG       "Res + CG:MQ + CG"   
CG:MQ    "Res + CG:MQ"        
Residual "Res"                

$f.versus
      F-ratio versus
CG    "CG:MQ"       
CG:MQ "Residual"    


Student-Newman-Keuls test for: CG:MQ 

Standard error = 0.8067
Df = 12 

Pairwise comparisons among levels of: MQ 
within each level of: CG 

Level: cage1 
              m1      m4      m2     m3  
Rank order:   1       2       3      4   
Ranked means: 59      69.2    79.35  83.8
Comparisons:                             
1             4-1 ***                    
2             3-1 *** 4-2 ***            
3             2-1 *** 3-2 *** 4-3 **     

Level: cage2 
              m3      m2      m4      m1  
Rank order:   1       2       3       4   
Ranked means: 50      55.25   64.8    69.8
Comparisons:                              
1             4-1 ***                     
2             3-1 *** 4-2 ***             
3             2-1 *** 3-2 *** 4-3 ***     

Level: cage3 
              m1      m4      m3      m2  
Rank order:   1       2       3       4   
Ranked means: 57.05   63.3    69.55   78.5
Comparisons:                              
1             4-1 ***                     
2             3-1 *** 4-2 ***             
3             2-1 *** 3-2 *** 4-3 ***     
---
Signif. codes: <0.001 '***' <0.01 '**' <0.05 '*' >0.05 'ns'
Analysis of Variance Table

Response: growth
          Df  Sum Sq Mean Sq  F value   Pr(>F)   
O          1 118.582 118.582 109.1874 0.001871 **
S          3  36.360  12.120                     
O:S        3   3.258   1.086   6.5359 0.015201 * 
S:B        8   1.187   0.148   0.8927 0.561821   
O:S:B      8   1.329   0.166   1.4177 0.239629   
O:S:B:C   24   2.813   0.117   1.0430 0.413970   
Residual 192  21.576   0.112                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
$tm
        O S B C n
O       1 4 3 2 5
S       2 1 3 2 5
O:S     1 1 3 2 5
S:B     2 1 1 2 5
O:S:B   1 1 1 2 5
O:S:B:C 1 1 1 1 5
Res     1 1 1 1 1

$mse
         Mean square estimates                  
O        "Res + O:S:B:C + O:S:B + O:S + O"      
S        "Res + O:S:B:C + O:S:B + S:B + O:S + S"
O:S      "Res + O:S:B:C + O:S:B + O:S"          
S:B      "Res + O:S:B:C + O:S:B + S:B"          
O:S:B    "Res + O:S:B:C + O:S:B"                
O:S:B:C  "Res + O:S:B:C"                        
Residual "Res"                                  

$f.versus
        F-ratio versus
O       "O:S"         
S       "No test"     
O:S     "O:S:B"       
S:B     "O:S:B"       
O:S:B   "O:S:B:C"     
O:S:B:C "Residual"    


Student-Newman-Keuls test for: O 

Standard error = 0.0951
Df = 3 
              O1     O2    
Rank order:   1      2     
Ranked means: 2.7017 4.1075
Comparisons:               
1             2-1 **       
---
Signif. codes: <0.001 '***' <0.01 '**' <0.05 '*' >0.05 'ns'

Student-Newman-Keuls test for: O:S 

Standard error = 0.0744
Df = 8 

Pairwise comparisons among levels of: S 
within each level of: O 

Level: O1 
              S1      S3      S2     S4  
Rank order:   1       2       3      4   
Ranked means: 2.1567  2.24    3.17   3.24
Comparisons:                             
1             4-1 ***                    
2             3-1 *** 4-2 ***            
3             2-1 ns  3-2 *** 4-3 ns     

Level: O2 
              S3     S1     S2     S4    
Rank order:   1      2      3      4     
Ranked means: 3.82   3.8467 4.37   4.3933
Comparisons:                             
1             4-1 **                     
2             3-1 ** 4-2 **              
3             2-1 ns 3-2 ** 4-3 ns       
---
Signif. codes: <0.001 '***' <0.01 '**' <0.05 '*' >0.05 'ns'

Student-Newman-Keuls test for: O:S:B 

Standard error = 0.1083
Df = 24 

Pairwise comparisons among levels of: B 
within each level of: O:S 

Level: O1.S1 
              B3     B2    B1  
Rank order:   1      2     3   
Ranked means: 2.01   2.07  2.39
Comparisons:                   
1             3-1 ns           
2             2-1 ns 3-2 *     

Level: O1.S2 
              B3     B1     B2  
Rank order:   1      2      3   
Ranked means: 3.06   3.22   3.23
Comparisons:                    
1             3-1 ns            
2             2-1 ns 3-2 ns     

Level: O1.S3 
              B3     B1    B2  
Rank order:   1      2     3   
Ranked means: 2.1    2.15  2.47
Comparisons:                   
1             3-1 ns           
2             2-1 ns 3-2 *     

Level: O1.S4 
              B3     B2     B1  
Rank order:   1      2      3   
Ranked means: 3.13   3.26   3.33
Comparisons:                    
1             3-1 ns            
2             2-1 ns 3-2 ns     

Level: O2.S1 
              B3     B1     B2 
Rank order:   1      2      3  
Ranked means: 3.78   3.86   3.9
Comparisons:                   
1             3-1 ns           
2             2-1 ns 3-2 ns    

Level: O2.S2 
              B2     B1     B3  
Rank order:   1      2      3   
Ranked means: 4.32   4.38   4.41
Comparisons:                    
1             3-1 ns            
2             2-1 ns 3-2 ns     

Level: O2.S3 
              B3     B1     B2  
Rank order:   1      2      3   
Ranked means: 3.81   3.82   3.83
Comparisons:                    
1             3-1 ns            
2             2-1 ns 3-2 ns     

Level: O2.S4 
              B1     B3     B2  
Rank order:   1      2      3   
Ranked means: 4.25   4.41   4.52
Comparisons:                    
1             3-1 ns            
2             2-1 ns 3-2 ns     
---
Signif. codes: <0.001 '***' <0.01 '**' <0.05 '*' >0.05 'ns'

GAD documentation built on May 2, 2019, 3:01 a.m.