User Tools

Site Tools


anova

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
Next revisionBoth sides next revision
anova [2018/10/19 07:54] – [F and t value] hkimscilanova [2020/05/20 15:51] – [Example 2] hkimscil
Line 375: Line 375:
 ====== Post hoc test ====== ====== Post hoc test ======
 [[Post hoc test]] [[Post hoc test]]
 +<code>> adata <- read.csv("https://datascienceplus.com/wp-content/uploads/2017/08/tyre.csv")
 +> adata
 +        Brands  Mileage
 +1       Apollo 32.99800
 +2       Apollo 36.43500
 +3       Apollo 32.77700
 +4       Apollo 37.63700
 +5       Apollo 36.30400
 +6       Apollo 35.91500
 +7       Apollo 34.70000
 +8       Apollo 32.37900
 +9       Apollo 33.63100
 +10      Apollo 36.41900
 +11      Apollo 36.43000
 +12      Apollo 34.83600
 +13      Apollo 38.32800
 +14      Apollo 30.62300
 +15      Apollo 32.57500
 +16 Bridgestone 33.52300
 +17 Bridgestone 31.99500
 +18 Bridgestone 35.00600
 +19 Bridgestone 27.87900
 +20 Bridgestone 31.29700
 +21 Bridgestone 31.06200
 +22 Bridgestone 34.83800
 +23 Bridgestone 33.97600
 +24 Bridgestone 32.55200
 +25 Bridgestone 30.88100
 +26 Bridgestone 28.14400
 +27 Bridgestone 29.18400
 +28 Bridgestone 33.07500
 +29 Bridgestone 32.36500
 +30 Bridgestone 30.92500
 +31        CEAT 34.44565
 +32        CEAT 32.80658
 +33        CEAT 33.41499
 +34        CEAT 36.86118
 +35        CEAT 36.97277
 +36        CEAT 35.08145
 +37        CEAT 34.95412
 +38        CEAT 33.47516
 +39        CEAT 30.42748
 +40        CEAT 36.13392
 +41        CEAT 34.78336
 +42        CEAT 36.11675
 +43        CEAT 41.05000
 +44        CEAT 32.16845
 +45        CEAT 32.72624
 +46      Falken 39.59600
 +47      Falken 38.93700
 +48      Falken 36.12400
 +49      Falken 37.69500
 +50      Falken 36.58600
 +51      Falken 35.96700
 +52      Falken 36.73700
 +53      Falken 34.31000
 +54      Falken 40.25200
 +55      Falken 37.38200
 +56      Falken 40.66300
 +57      Falken 37.09500
 +58      Falken 38.00500
 +59      Falken 37.75600
 +60      Falken 37.26500
 +>
 +</code>
 +
 +<code>> fmod.tire <- aov(Mileage~Brands, data=adata)
 +> summary(fmod.tire)
 +            Df Sum Sq Mean Sq F value   Pr(>F)    
 +Brands        256.3   85.43   17.94 2.78e-08 ***
 +Residuals   56  266.6    4.76                     
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +</code>
 +<code>
 +> TukeyHSD(fmod.tire)
 +  Tukey multiple comparisons of means
 +    95% family-wise confidence level
 +
 +Fit: aov(formula = Mileage ~ Brands, data = adata)
 +
 +$Brands
 +                          diff        lwr       upr     p adj
 +Bridgestone-Apollo -3.01900000 -5.1288190 -0.909181 0.0020527
 +CEAT-Apollo        -0.03792661 -2.1477456  2.071892 0.9999608
 +Falken-Apollo       2.82553333  0.7157143  4.935352 0.0043198
 +CEAT-Bridgestone    2.98107339  0.8712544  5.090892 0.0023806
 +Falken-Bridgestone  5.84453333  3.7347143  7.954352 0.0000000
 +Falken-CEAT         2.86345994  0.7536409  4.973279 0.0037424
 +>
 +> tapply(adata$Mileage, adata$Brands, mean)
 +     Apollo Bridgestone        CEAT      Falken 
 +   34.79913    31.78013    34.76121    37.62467 
 +
 +</code>
 +
 ====== F and t value ====== ====== F and t value ======
 $$ F = t^{2}$$ $$ F = t^{2}$$
Line 421: Line 518:
  
 ====== Example ====== ====== Example ======
 +가설. 단어맞히기 게임에서 첫글자를 힌트로 주거나, 마지막 글자를 힌트로 주거나, 힌트를 주지 않은 세 그룹 간에 틀린 단어의 숫자에 차이가 있을 것이다. 
 +
 |  |First Letter \\ Condition 1 \\ X<sub>1</sub>|Last Letter \\ Condition 2 \\ X<sub>2</sub>|No Letter \\ Condition 3 \\ X<sub>3</sub> | |  |First Letter \\ Condition 1 \\ X<sub>1</sub>|Last Letter \\ Condition 2 \\ X<sub>2</sub>|No Letter \\ Condition 3 \\ X<sub>3</sub> |
 | | 15 | 21 | 28 | | | 15 | 21 | 28 |
Line 433: Line 532:
 | | 41 | 21 | 15 | | | 41 | 21 | 15 |
 | T  | 180  | 240  | 270  | | T  | 180  | 240  | 270  |
-| n  | 10  |  10  | 10  | +| n  | 10  | 10  | 10  | 
-| Mean  | $\overline{X_1}$ = 18  | $\overline{X_2}$ = 24  | $\overline{X_3}$ = 27  | +| Mean  | 18  | 24  | 27  | 
-Total  $ T_1 = 180 $  $ T_2 = 240 $ $ T_3 270 $  | +Mean%%^%%2  324  576  729  | 
-| $\sum{(X_i)^2}$  | 3888  | 5868  | 7614  |+| b $n*(mean)^2 | 3240  | 5760  | 7290  | 
 +a = $\sum{(X_i)^2}$  | 3888  | 5868  | 7614  
 +| a-b = Var.within  | 648  | 108  | 324  | $f = $1080   |
  
 +\begin{eqnarray*}
 +a & = & \sum (X_i)^2 = 17370 \\
 +b & = & \overline{X_{total}} = 23 \\
 +c & = & \overline{X}^2 = 529 \\
 +d & = & N = 30 \\
 +e & = & SS_{total} = \sum {(X_i)^2} = a - (d * c) = 1500 \\
 +f & = & SS_{within} = 648 + 108+ 324 = 1080 \\
 +g & = & SS_{between} = e - f = 420  
 +\end{eqnarray*}
  
-$\sum (X_i)^2 17370 $ \+| m.total = Mean.total $= \$ 23  ||| 
-$\overline{X_{total}} = 23 $ \\ +| m.within = Mean.each.group  | 18  | 24  | 27  | 
-$\overline{X}^2 = 529 \\+| o = m.total - m.within  | 5   | -1  | -4  | 
 +| o%%^%% | 25  | 1  | 16  | 
 +| n  | 10  | 10  | 10  | 
 +| o%%^%%2 * n | 250  | 10  | 160  | 
 +| sum  | $g \; 420  |||
  
-$ G = ? $ \\ 
-$ G^2 = ? $ \\ 
-$ \sum {(X_i)^2} = 17370 $ \\  
-\\ 
-$ k =  $ \\ 
-$ n =  $ \\ 
-$ N =  $ \\ 
-\\ 
-$ df_{total} = $ \\  
-$ df_{between} = $ \\ 
-$ df_{within} = $ \\ 
  
-<code>x1 <- c(15, 20, 14, 13, 18, 16, 13, 12, 18, 41)+\begin{eqnarray*} 
 +k & = & 3 \\ 
 +n & = & 10 \\ 
 +N & = & 30 \\ 
 +\end{eqnarray*} 
 + 
 +\begin{eqnarray*} 
 +e' & = & df_{between} =  \\ 
 +f' & = & df_{within} =   \\ 
 +g' & = & df_{total} =  \\  
 +\end{eqnarray*} 
 + 
 +|          | SS   | df    | MS  | F   | 
 +| between  | $e = \;$ 420   | $e' = \;$ 2 | 210  |  210/40 = 5.25  | 
 +| within   | $f = \;$ 1080  | $f' = \;$ 27 | 40  |   | 
 +| total    | $g = \;$ 1500  | $g' = \;$ 29 |     | 
 + 
 +F<sub>crit</sub>(2, 27) =  3.35 
 +F<sub>cal</sub> = 5.25 
 + 
 +F<sub>cal</sub> > F<sub>crit</sub> 이므로 3집단 간의 평균은 통계학적으로 의미가 있는 차이를 가지고 있다. 
 +====== Example 2 ====== 
 +<code> 
 +x1 <- c(15, 20, 14, 13, 18, 16, 13, 12, 18, 41)
 x2 <- c(21, 25, 29, 18, 26, 22, 26, 24, 28, 21) x2 <- c(21, 25, 29, 18, 26, 22, 26, 24, 28, 21)
 x3 <- c(28, 30, 32, 28, 26, 30, 25, 36, 20, 15) x3 <- c(28, 30, 32, 28, 26, 30, 25, 36, 20, 15)
 </code> </code>
  
-<code>> data.frame(x1,x2,x3)+<code>> xc <- data.frame(x1,x2,x3)
    x1 x2 x3    x1 x2 x3
 1  15 21 28 1  15 21 28
Line 509: Line 635:
  
 <code> <code>
-> colnames(xs[1]) <- "wrong" +> colnames(xs)  <- c("wrong""condition")
-> colnames(xs[2]) <- "cond"+
 </code> </code>
  
-<code># cf+<code> 
 +# cf
 # lengthofelements <- length(x1) # lengthofelements <- length(x1)
 # varofvariable <- var(x1)</code> # varofvariable <- var(x1)</code>
  
 <code> <code>
-df_x1 +df.total <- length(xs$wrong) - 1 
-df_x2 +ss.total <- var(xs$wrong)*df_tot 
-df_x3+var.total <- ss.total/df.total 
 +var.total.r <- var(xs$wrong)
  
-ss_x1 +df.x1 <- length(x1)-1 
-ss_x2 +df.x2 <- length(x2)-1 
-ss_x3+df.x3 <- length(x3)-1 
 +ss.x1 <- var(x1)*df.x1 
 +ss.x2 <- var(x2)*df.x2 
 +ss.x3 <- var(x3)*df.x3
  
-df_bet +ss.within <- ss.x1 + ss.x2 + ss.x3 
-ss_bet+df.within <- df.x1 + df.x2 + df.x3 
 +ss.between <- ss.total - ss.within 
 +df.between <- df.total - df.within
  
-df_tot +ms.between <- ss.between/df.between 
-ss_tot+ms.within <- ss.within/df.within 
 +f.value <- ms.between/ms.within
  
-df_with +ss.between 
-ss_with+df.between
  
-df_bet +ss.within 
-ss_bet+df.within
  
-</code>+ms.between 
 +ms.within 
 + 
 +f.value 
 + 
  
-<code> 
-df_tot <- length(xs$ind) - 1 
-ss_tot <- var(xs$values)*df_tot 
-var_tot <- var(xs$values) 
  
-df_x1 <- length(x1)-1 
-df_x2 <- length(x2)-1 
-df_x3 <- length(x3)-1 
-ss_x1 <- var(x1)*df_x1 
-ss_x2 <- var(x2)*df_x2 
-ss_x3 <- var(x3)*df_x3 
 </code> </code>
 ====== E.G. 1 (R) ====== ====== E.G. 1 (R) ======
anova.txt · Last modified: 2022/09/30 09:02 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki