Measures of association in R — Kendall's tau-b and tau-c

前端 未结 9 852

Are there any R packages for the calculation of Kendall\'s tau-b and tau-c, and their associated standard errors? My searches on Google and Rseek have turned up nothing, but su

9条回答
  •  一生所求
    2021-01-30 10:14

    Quite a while, but the 3 functions are implemented in DescTools.

    library(DescTools)
    # example in: 
    # http://support.sas.com/documentation/cdl/en/statugfreq/63124/PDF/default/statugfreq.pdf
    # pp. S. 1821
    tab <- as.table(rbind(c(26,26,23,18,9),c(6,7,9,14,23)))
    
    # tau-a
    KendallTauA(tab, conf.level=0.95)
    tau_a    lwr.ci    ups.ci 
    0.2068323 0.1771300 0.2365346 
    
    # tau-b
    KendallTauB(tab, conf.level=0.95)
        tau_b    lwr.ci    ups.ci 
    0.3372567 0.2114009 0.4631126 
    
    # tau-c
    > StuartTauC(tab, conf.level=0.95)
         tauc    lwr.ci    ups.ci 
    0.4110953 0.2546754 0.5675151 
    
    # alternative for tau-b:
    d.frm <- Untable(tab, dimnames = list(1:2, 1:5))
    cor(as.numeric(d.frm$Var1), as.numeric(d.frm$Var2),method="kendall")
    [1] 0.3372567
    
    # but no confidence intervalls for tau-b! Check:
    unclass(cor.test(as.numeric(d.frm$Var1), as.numeric(d.frm$Var2), method="kendall"))
    

提交回复
热议问题