2012-11-27 3 views
6

나는 이전 게시물과의 대비를 잘 알고 있으며, 나는 옳은 일을하고 있다고 생각하지만, 기대하는 바가 내게 주어지지 않는다.는 anova에서 대조를 보임

x <- c(11.80856, 11.89269, 11.42944, 12.03155, 10.40744, 
     12.48229, 12.1188, 11.76914, 0, 0, 
     13.65773, 13.83269, 13.2401, 14.54421, 13.40312) 
type <- factor(c(rep("g",5),rep("i",5),rep("t",5))) 
type 
[1] g g g g g i i i i i t t t t t 
Levels: g i t 

내가 실행하면이 "g"내 타입, 내 typei 유형 "g"의 차이이며, "난"을 입력하고 내 typet 그래서 여기

> summary.lm(aov(x ~ type)) 

Call: 
aov(formula = x ~ type) 

Residuals: 
    Min  1Q Median  3Q  Max 
-7.2740 -0.4140 0.0971 0.6631 5.2082 

Coefficients: 
      Estimate Std. Error t value Pr(>|t|)  
(Intercept) 11.514  1.729 6.659 2.33e-05 *** 
typei   -4.240  2.445 -1.734 0.109  
typet   2.222  2.445 0.909 0.381  
--- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 3.866 on 12 degrees of freedom 
Multiple R-squared: 0.3753,  Adjusted R-squared: 0.2712 
F-statistic: 3.605 on 2 and 12 DF, p-value: 0.05943 

내 참조입니다

타입 "g"와 타입 "t"의 차이.

난 "t"

그래서

명암 대비를 typei+typeg 사이 여기서 두개 이상의 콘트라스트의 차이를 볼 수 및 유형과 "t"와 차이를 "I"를 입력하고 입력 싶었

> contrasts(type) <- cbind(c(-1,-1,2),c(0,-1,1)) 
> summary.lm(aov(x~type)) 

Call: 
aov(formula = x ~ type) 

Residuals: 
    Min  1Q Median  3Q  Max 
-7.2740 -0.4140 0.0971 0.6631 5.2082 

Coefficients: 
      Estimate Std. Error t value Pr(>|t|)  
(Intercept) 10.8412  0.9983 10.860 1.46e-07 *** 
type1  -0.6728  1.4118 -0.477 0.642  
type2   4.2399  2.4453 1.734 0.109  
--- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 3.866 on 12 degrees of freedom 
Multiple R-squared: 0.3753,  Adjusted R-squared: 0.2712 
F-statistic: 3.605 on 2 and 12 DF, p-value: 0.05943 

I을 내 참조를 변경하여 두 번째 대조를 시도하면 나는 다른 결과를 얻는다. 나는 내 콘트라스트가 잘못된 것을 이해하지 못한다.

+4

오른쪽 장소는 http://stats.stackexchange.com/입니다. –

답변

7

Refence는 : 통계 질문 http://www.ats.ucla.edu/stat/r/library/contrast_coding.htm

mat <- cbind(rep(1/3, 3), "g+i vs t"=c(-1/2, -1/2, 1),"i vs t"=c(0, -1, 1)) 
mymat <- solve(t(mat)) 
my.contrast <- mymat[,2:3] 
contrasts(type) <- my.contrast 
summary.lm(aov(x ~ type)) 

my.contrast 
>  g+i vs t i vs t 
[1,] -1.3333  1 
[2,] 0.6667  -1 
[3,] 0.6667  0 
> contrasts(type) <- my.contrast 
> summary.lm(aov(x ~ type)) 

Call: 
aov(formula = x ~ type) 

Residuals: 
    Min  1Q Median  3Q Max 
-7.274 -0.414 0.097 0.663 5.208 

Coefficients: 
      Estimate Std. Error t value Pr(>|t|)  
(Intercept) 10.841  0.998 10.86 1.5e-07 *** 
typeg+i vs t 4.342  2.118 2.05 0.063 . 
typei vs t  6.462  2.445 2.64 0.021 * 
--- 
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 3.87 on 12 degrees of freedom 
Multiple R-squared: 0.375, Adjusted R-squared: 0.271 
F-statistic: 3.6 on 2 and 12 DF, p-value: 0.0594 
+0

감사합니다. @liuminzhao. 링크를 더 이상 사용할 수 없습니다. 나는 많은 사람들이이 주제를 다르게 제시한다는 것을 알았다. 행렬을 풀어 나가는 단계가없는 일부도 있습니다. 링크가 더 이상 작동하지 않기 때문에 설명 된 좋은 리소스를 권할 수 있습니까? – Jaynes01

+1

@ Jaynes01 다른 [link] (https://rstudio-pubs-static.s3.amazonaws.com/65059_586f394d8eb84f84b1baaf56ffb6b47f.html)를 찾았습니다. 섹션 * DIY Contrasts *를 확인하십시오. 희망이 도움이됩니다. 요컨대, 그것은 콘트라스트가 직교인지의 여부에 달려 있습니다. 역관계를 수행하는 것이 R의 대비 함수에 대해 더 안전합니다. – liuminzhao

관련 문제