如何從 p 值矩陣中獲得緊湊的字母顯示? (How to get a compact letter display from a matrix of p-values?)


問題描述

如何從 p 值矩陣中獲得緊湊的字母顯示? (How to get a compact letter display from a matrix of p‑values?)

考慮這個數據,我們有幾個組,每個組有 10 個觀察值,我們執行 pairwise.t.test()

set.seed(123)
data <‑ data.frame(group = rep(letters[1:18], each = 10),
                   var = rnorm(180, mean = 2, sd = 5))
ttres <‑ pairwise.t.test(x=data$var, g=data$group, p.adjust.method = "none")#just to make sure i get some sigs for the example

您可以返回一個矩陣此測試的 p 值如下所示:

pmat <‑ as.matrix(ttres$p.value)

有了這樣的相關矩陣形狀的結果,我們如何從結果中獲得緊湊的字母顯示?我的意思是我希望以字母的形式獲得輸出,顯示哪些組不同,哪些組不同。我的意思是我希望生成 multcomp 包中的 cld 函數用於 tukeys 測試:https://www.rdocumentation。


參考解法

方法 1:

You can use the functions fullPTable() and multcompLetters(), found in the library(rcompanion) and library(multcompView).

Here is how I would solve your problem:


library(rcompanion)
library(multcompView)
set.seed(123)
data <‑ data.frame(group = rep(letters[1:18], each = 10),
                   var = rnorm(180, mean = 2, sd = 5))

PT <‑ pairwise.t.test(x=data$var, g=data$group, p.adjust.method = "none")#just to make sure i get some sigs for the example
PT = PT$p.value
PT1 = fullPTable(PT)
multcompLetters(PT1,
                compare="<",
                threshold=0.05,
                Letters=letters,
                reversed = FALSE)

(by RyanAndy)

參考文件

  1. How to get a compact letter display from a matrix of p‑values? (CC BY‑SA 2.5/3.0/4.0)

#matrix #R #data-visualization






相關問題

BLAS 子程序 dgemm、dgemv 和 ddot 不適用於標量? (BLAS subroutines dgemm, dgemv and ddot doesn't work with scalars?)

為什麼我們需要維護自己的矩陣來轉換遊戲對象? (Why we need to maintain our own matrices to transform Game objects?)

R 高斯消除和 qr 分解 (R Gaussian Elimination and qr factorization)

生成尺寸為 8x8 的正定矩陣 (Generating Positive definite matrix of dimensions 8x8)

替代在此 Ruby 代碼中使用基於時間間隔分配標籤的巨型 if/else (Alternative to using a giant if/else in this Ruby code that assigns labels based on the time interval)

如何創建一個行矩陣,其元素是我的 while 循環的迭代 (How to create a row matrix whose elements are the iterations of my while loop)

在Matlab中找到矩陣中相同元素的開始索引和結束索引 (Find the Start Index and End Index of the same Element in a Matrix in Matlab)

用 Matlab 寫一個方程(矩陣大小) (writing an equation with Matlab (Matrix size))

使用 numpy 或 pandas 從元組列表中為二元組創建頻率矩陣 (Create a frequency matrix for bigrams from a list of tuples, using numpy or pandas)

如何在循環和 if 語句中使用遞歸公式 (How to use recursive formula in loop and if statement)

如何從 p 值矩陣中獲得緊湊的字母顯示? (How to get a compact letter display from a matrix of p-values?)

刺激基質上的液體流動 (Stimulating Liquid Flow on Matrix)







留言討論