User Tools

Site Tools


c:ms:2023:w07_anova_note

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
c:ms:2023:w07_anova_note [2023/04/18 22:27] – [R square or Eta] hkimscilc:ms:2023:w07_anova_note [2023/06/04 21:38] (current) – [Post hoc test] hkimscil
Line 125: Line 125:
  
 </code> </code>
-=====Output ======+ 
 +===== ANOVA in R: Output =====
 <code> <code>
 > # > #
Line 417: Line 418:
  
 </code> </code>
-====== R square or Eta ====== 
-SS toal  
-  * = Y 변인만으로 Y를 예측했을 때의 오차의 제곱 
-  * Y 변인만으로 = Y의 평균을 가지고 Y값을 예측한 것  
-  * 학습 초기에 에러의 제곱의 합으로 설명된 것 
  
-SS between +====== Post hoc test ======
-  * X 변인 (independent variable) 정보가 고려 되었을 때 +
-  * 독립변인이 고려되었을 때 (됨으로써) +
-  * 없어지는 SS total의 불확실 성 +
-  * 혹은 획득되는 <fc #ff0000>설명력</fc>   +
- +
-SS error  +
-  * IV가 고려되었음에도 불구하고  +
-  * 끝까지 남는 error  +
- +
-SS total = SS between + SS within  +
- +
-SS between / SS total = IV 가 kicked in 되었을 때 없어지는 uncertainty = IV 의 설명력 = <fc #ff0000>R square value</fc> +
- +
-즉, IV로 uncertainty 가 얼마나 없어질까? 라는 아이디어 +
- +
-이를 살펴보기 위해 +
- +
-<code> +
-ss.tot +
-ss.bet +
-r.sq <- ss.bet / ss.tot +
-r.sq +
- +
-# then . . . .  +
- +
-lm.res <- lm(values ~ group, data = comb3) +
-summary(lm.res) +
-anova(lm.res) +
-</code> +
-===== output ===== +
- +
- +
-<code> +
-> ss.tot +
-[1] 2666 +
-> ss.bet +
-[1] 416 +
-> r.sq <- ss.bet / ss.tot +
-> r.sq +
-[1] 0.156039 +
->  +
-> # then . . . .  +
->  +
-> lm.res <- lm(values ~ group, data = comb3) +
-> summary(lm.res) +
- +
-Call: +
-lm(formula = values ~ group, data = comb3) +
- +
-Residuals: +
-    Min      1Q  Median      3Q     Max  +
--16.020  -2.783   1.476   4.892  12.148  +
- +
-Coefficients: +
-            Estimate Std. Error t value Pr(>|t|)     +
-(Intercept)   26.000      1.768   14.71   <2e-16 *** +
-groupb        -2.000      2.500   -0.80   0.4279     +
-groupc        -7.000      2.500   -2.80   0.0075 **  +
---- +
-Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 +
- +
-Residual standard error: 7.071 on 45 degrees of freedom +
-Multiple R-squared:  0.156, Adjusted R-squared:  0.1185  +
-F-statistic:  4.16 on 2 and 45 DF,  p-value: 0.02199 +
- +
-> anova(lm.res) +
-Analysis of Variance Table +
- +
-Response: values +
-          Df Sum Sq Mean Sq F value  Pr(>F)   +
-group      2    416     208    4.16 0.02199 * +
-Residuals 45   2250      50                   +
---- +
-Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 +
->  +
->  +
-</code> +
-====== Post hoc ======+
 [[:post hoc test]] [[:post hoc test]]
 <code> <code>
Line 516: Line 434:
 d.bc d.bc
  
-se  +mse (ms within) from the a.res.sum output 
-from the a.res.sum output+# a.res.sum == summary(aov(values ~ group, data=comb3))
 a.res.sum  a.res.sum 
 # mse = 50 # mse = 50
 mse <- 50  mse <- 50 
 +# 혹은 fansy way from comb3 data.frame
 +# 15 는 각 그룹의 df
 +sse.ch <- sum(tapply(comb3$values, comb3$group, var)*15)
 +sse.ch
 +mse.ch <- sse.ch/45
 +mse.ch
  
 se <- sqrt(mse/length(A)) se <- sqrt(mse/length(A))
Line 549: Line 473:
 TukeyHSD(a.res, conf.level=.95) TukeyHSD(a.res, conf.level=.95)
 </code> </code>
-output  
  
 +<code>
 +plot(TukeyHSD(a.res, conf.level=.95), las = 2)
 +</code>
 +
 +<code>
 +pairwise.t.test(comb3$values, comb3$group, p.adj = "bonf")
 +</code>
 +===== post hoc test: output =====
 <code> <code>
 > m.a > m.a
Line 626: Line 557:
  
 </code> </code>
 +
 +{{:c:ms:2023:pasted:20230418-223608.png}}
 +====== R square or Eta square ======
 +SS toal 
 +  * = Y 변인만으로 Y를 예측했을 때의 오차의 제곱
 +  * Y 변인만으로 = Y의 평균을 가지고 Y값을 예측한 것 
 +  * 학습 초기에 에러의 제곱의 합으로 설명된 것
 +
 +SS between
 +  * X 변인 (independent variable) 정보가 고려 되었을 때
 +  * 독립변인이 고려되었을 때 (됨으로써)
 +  * 없어지는 SS total의 불확실 성
 +  * 혹은 획득되는 <fc #ff0000>설명력</fc>  
 +
 +SS error 
 +  * IV가 고려되었음에도 불구하고 
 +  * 끝까지 남는 error 
 +
 +SS total = SS between + SS within 
 +
 +SS between / SS total = IV 가 kicked in 되었을 때 없어지는 uncertainty = IV 의 설명력 = <fc #ff0000>R square value</fc>
 +
 +즉, IV로 uncertainty 가 얼마나 없어질까? 라는 아이디어
 +
 +이를 살펴보기 위해
 +
 +<code>
 +ss.tot
 +ss.bet
 +r.sq <- ss.bet / ss.tot
 +r.sq
 +
 +# then . . . . 
 +
 +lm.res <- lm(values ~ group, data = comb3)
 +summary(lm.res)
 +anova(lm.res)
 +</code>
 +
 +===== R square: output =====
 +<code>
 +> ss.tot
 +[1] 2666
 +> ss.bet
 +[1] 416
 +> r.sq <- ss.bet / ss.tot
 +> r.sq
 +[1] 0.156039
 +
 +> # then . . . . 
 +
 +> lm.res <- lm(values ~ group, data = comb3)
 +> summary(lm.res)
 +
 +Call:
 +lm(formula = values ~ group, data = comb3)
 +
 +Residuals:
 +    Min      1Q  Median      3Q     Max 
 +-16.020  -2.783   1.476   4.892  12.148 
 +
 +Coefficients:
 +            Estimate Std. Error t value Pr(>|t|)    
 +(Intercept)   26.000      1.768   14.71   <2e-16 ***
 +groupb        -2.000      2.500   -0.80   0.4279    
 +groupc        -7.000      2.500   -2.80   0.0075 ** 
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Residual standard error: 7.071 on 45 degrees of freedom
 +Multiple R-squared:  0.156, Adjusted R-squared:  0.1185 
 +F-statistic:  4.16 on 2 and 45 DF,  p-value: 0.02199
 +
 +> anova(lm.res)
 +Analysis of Variance Table
 +
 +Response: values
 +          Df Sum Sq Mean Sq F value  Pr(>F)  
 +group      2    416     208    4.16 0.02199 *
 +Residuals 45   2250      50                  
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +
 +</code>
 +
c/ms/2023/w07_anova_note.1681824420.txt.gz · Last modified: 2023/04/18 22:27 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki