2015-01-23 6 views
5

p 값만보고하기 때문에 pairwise.t.test 함수에서 t 값을 추출 할 수 있는지 알고 싶습니다. 상당한 주 효과를보고 한 반복 측정 anova를 실행 한 후에 다중 비교에 pairwise.t.test()를 사용했습니다.pairwise.t.test에서 t 값 추출

미리 감사드립니다.

+0

스택 오버플로에 대한 질문과 비슷합니다. – DatamineR

답변

5

이와 같은 것을 알아 내려고 시도 할 때 몇 가지 간단한 시도가 있습니다 (물론 주어진 인스턴스에서 작동한다는 보장은 없습니다). 먼저 시도 할 문서 (?pairwise.t.test)를보고 Value 아래 나열된 내용을 확인하십시오. 이 경우는 말한다 :

시도하는 두 번째 것은 예를 들어 객체를 얻고 변수에 할당하는 오브젝트 클래스 "pairwise.htest"의

, 다음 str(obj)를 실행할 수 있습니다 . 다음은 문서에서 예제를 사용

attach(airquality) 
Month <- factor(Month, labels = month.abb[5:9]) 
obj <- pairwise.t.test(Ozone, Month) 
str(obj) 
List of 4 
$ method   : chr "t tests with pooled SD" 
$ data.name  : chr "Ozone and Month" 
$ p.value  : num [1:4, 1:4] 1 0.000264 0.000195 1 NA ... 
    ..- attr(*, "dimnames")=List of 2 
    .. ..$ : chr [1:4] "Jun" "Jul" "Aug" "Sep" 
    .. ..$ : chr [1:4] "May" "Jun" "Jul" "Aug" 
$ p.adjust.method: chr "holm" 
- attr(*, "class")= chr "pairwise.htest" 

를 불행하게도, 우리는 (예를 들어, 뭔가 $ t.stat 같은)보고 싶은 것을 표시되지 않습니다.

마지막 옵션은 코드를 보는 것입니다. 명령 프롬프트에서 괄호없이 함수 호출을 입력하여 얻을 수 있습니다 :

> pairwise.t.test 
function (x, g, p.adjust.method = p.adjust.methods, pool.sd = !paired, 
    paired = FALSE, alternative = c("two.sided", "less", "greater"), 
    ...) 
{ 
    <code omitted> 
    if (pool.sd) { 
     <code omitted> 
     } 
    } 
    else { 
     <code omitted> 
     compare.levels <- function(i, j) { 
      xi <- x[as.integer(g) == i] 
      xj <- x[as.integer(g) == j] 
      t.test(xi, xj, paired = paired, alternative = alternative, 
       ...)$p.value 
     } 
    } 
    PVAL <- pairwise.table(compare.levels, levels(g), p.adjust.method) 
    ans <- list(method = METHOD, data.name = DNAME, p.value = PVAL, 
     p.adjust.method = p.adjust.method) 
    class(ans) <- "pairwise.htest" 
    ans 
} 

의 핵심 부분은 기본 t- 검정의 p- 값을 유지하는 정의 함수 compare.levels이다. 따라서 질문에 대한 대답은 아니요이 아니므로 t- 통계를 추출 할 수 없습니다.

1

사용자 정의 함수를 작성하여 pairwise.t.test에서 t 값 (및 dfs)을 얻을 수 있습니다. See my previous post.