RDocumentation: cor.test
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    Note that this notebook was automatically generated from an RDocumentation page. It depends on the package and the example code whether this code will run without errors. You may need to edit the code to make things work.

    if(!require('stats')) {
        install.packages('stats')
        library('stats')
    }
    ## Hollander & Wolfe (1973), p. 187f.
    ## Assessment of tuna quality.  We compare the Hunter L measure of
    ##  lightness to the averages of consumer panel scores (recoded as
    ##  integer values from 1 to 6 and averaged over 80 such values) in
    ##  9 lots of canned tuna.
    
    x <- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
    y <- c( 2.6,  3.1,  2.5,  5.0,  3.6,  4.0,  5.2,  2.8,  3.8)
    
    ##  The alternative hypothesis of interest is that the
    ##  Hunter L value is positively associated with the panel score.
    
    cor.test(x, y, method = "kendall", alternative = "greater")
    ## => p=0.05972
    
    cor.test(x, y, method = "kendall", alternative = "greater",
             exact = FALSE) # using large sample approximation
    ## => p=0.04765
    
    ## Compare this to
    cor.test(x, y, method = "spearm", alternative = "g", parameter="degree of freedom")
    cor.test(x, y,                    alternative = "g")
    
    cor.test(~ CONT + INTG,  method = "spearm", data = USJudgeRatings)
    
    ## Formula interface.
    require(graphics)
    pairs(USJudgeRatings)
    cor.test(~ CONT + INTG, data = USJudgeRatings)